functions-framework
requirements.txt
: -e git+https://github.com/<repo>/<project>#egg=<project>
pip install -r requirements.txt
. And the package is successfully installed.import <pkg-name>
works and I am able to access all the functions.gcloud functions \
deploy <function-name> \
--trigger-http \
--entry-point <entry-function> \
--runtime python37 \
--project=<my-project>
As expected this gives an error because it does not have access to the private repo in git.
I created a Google Cloud Repository and linked it to the git repo, hoping that in some way I could specify that in the requirements.txt. Just do not know how.
I tried setting environment variables for username and password (not a good idea, I agree) in Google Cloud Function and specify them in the requirements.txt
as:
-e git+https://${AUTH_USER}:${AUTH_PASSWORD}@github.com/<repo>/<project>#egg=<project>
That too gave an error.
Any help or direction will be greatly appreciated.
While @marian.viadoi was correct in the above comment viz. Google Cloud Function cannot access a private git repo, I have implemented a workaround and sharing just in case it is suitable. Here is what has been done:
python3 setup.py bdist_wheel
dist
folder of it.requirements.txt
I added the line: ./dist/xxxx.whl
to other dependencies required by the cloud functiongcloud deploy ..
This does not answer how to use a private repo in Google Functions (which is not possible), but the above steps ensure that a private package can be easily shared and updated amongst different cloud functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With