pip – How can a Google Cloud Python function access a private Python package?

  1. I'm using the Google Cloud feature with Python. Several other functions are in production.
  2. For this purpose, however, I also created a custom Python package that is available on github as Private Repo.
  3. I have to install the package in the Google function

WHAT HAVE I DONE

  1. I run the Google function locally functions-framework
  2. I have a require.txt that contains a link to the package. This is done by adding the following line to requirements.txt::
    -e git+https://github.com//#egg=
  1. I run pip install -r requirements.txt. And the package was installed successfully.
  2. Now in the Python code of the function with import works and I can access all functions.

CHALLENGES IN PRESSING THE FUNCTION ON THE CLOUD

  1. To transfer the cloud function to the Google Cloud, I issue the following command according to the documentation:
gcloud functions 
  deploy  
  --trigger-http  
  --entry-point  
  --runtime python37 
  --project=

As expected, this issues an error because it doesn't have access to the private repo in Git.

  1. I created a Google Cloud Repository and linked it to the Git repo in the hope that I could somehow specify this in the resources.txt file. Just don't know how.

  2. I tried to set username and password environment variables (not a good idea, because I agree) in the Google Cloud function and these in the requirements.txt how:

    -e git+https://${AUTH_USER}:${AUTH_PASSWORD}@github.com//#egg=

That also gave an error.

Any help or instruction is greatly appreciated.