3 ms·
I’m working on GCP mostly using Python and I agree that it would be nice to share a library across services instead of having yet another service. However, pra
by wodenokoto 6y ago
I’m working on GCP mostly using Python and I agree that it would be nice to share a library across services instead of having yet another service.
However, practically speaking:
- I don’t think it is possible to create a Python library that is not publicly available through pypi/pip, but can be installed in cloud functions
- if the library is a service, I only need to update one service to add a new function or fix a bug
- a service can be called by other non Python services.
With that being said it is much, much easier writing code that import a library than call out to a service. And it is also much, much easier to test.
- jacobr1 6y agoYou can, you just need to specify the private repo in your requirements.txt via `--extra-index-url` We use packagecloud.io and inject the relevant token to access our private repo at CI/CD time.
- BerislavLopac 6y ago> I don’t think it is possible to create a Python library that is not publicly available through pypi/pip, but can be installed in cloud functions Of course it is possible. You can set up your own PEP 503 [0] compliant repository, even unreachable outside your VPC, and use pip to install from it. One caveat: on GCF you can -- if I'm not mistaken -- only install Python-only libraries; but if you use Cloud Run you can install anything inside your container. There are servers for hosting your own PEP503 repo, such as devpi [1] -- but ultimately you only need a Web server to serve the file index. [0] https://www.python.org/dev/peps/pep-0503/ https://www.python.org/dev/peps/pep-0503/ [1] https://www.devpi.net/ https://www.devpi.net/