dazzling-elephant-33766
02/24/2023, 5:05 PMpsycopg2
package. I’d like the ability to build + deploy my cloud functions from my MacOS machine, however I’m running into current limitations of pants:
16:44:33.76 [WARN] Google Cloud Functions built on macOS may fail to build. If your function uses any third-party dependencies without binary wheels (bdist) for Linux available, it will fail to build. If this happens, you will either need to update your dependencies to only use dependencies with pre-built wheels, or find a Linux environment to run ./pants package. (See <https://realpython.com/python-wheels/> for more about wheels.)
It looks like the only way to get a wheel is via psycopg2-binary
(which works) but the documentation recommends avoiding this in production and instead using the source distribution.
I’m wondering if anyone has any recommendations/advice to work around this limitation?
Is having a Linux pipeline to build/deploy cloud functions really my only option? Or is it possible to temporarily override/replace psycopg2->psycopg2-binary for one-off deployments?happy-kitchen-89482
02/24/2023, 5:18 PMpsycopg2
is an sdist, so it has to be built on the platform you're going to deploy it on. That would be true regardless of which build system was orchestrating the building. However in Pants 2.15.0rc7 you can use the new Environments feature to run the necessary processes in a Docker container on macOS, so you end up with a linux artifact.happy-kitchen-89482
02/24/2023, 5:18 PMhappy-kitchen-89482
02/24/2023, 5:19 PMhappy-kitchen-89482
02/24/2023, 5:19 PMdazzling-elephant-33766
02/24/2023, 5:19 PMhappy-kitchen-89482
02/24/2023, 5:20 PMhappy-kitchen-89482
02/24/2023, 5:20 PMhappy-kitchen-89482
02/24/2023, 5:21 PMdazzling-elephant-33766
02/24/2023, 5:21 PMhappy-kitchen-89482
02/24/2023, 5:21 PMdazzling-elephant-33766
02/24/2023, 5:21 PMdazzling-elephant-33766
02/24/2023, 5:23 PMrequirements.txt
explicitly to GCLOUD, and presumably psycopg2
would be compiled/build at the point of deployment instead.
https://cloud.google.com/functions/docs/writing/specifying-dependencies-python#python38happy-kitchen-89482
02/24/2023, 5:40 PMhappy-kitchen-89482
02/24/2023, 5:41 PMhappy-kitchen-89482
02/24/2023, 5:41 PMhappy-kitchen-89482
02/24/2023, 5:41 PM