icy-hair-30586
05/11/2022, 8:10 AMicy-hair-30586
05/11/2022, 8:12 AMcurved-television-6568
05/11/2022, 8:15 AMPYTHONPATH
, or installing your pex
in the container as a venv, and then build and install pyodbc into that, may work..
https://pex.readthedocs.io/en/latest/recipes.html#pex-app-in-a-containericy-hair-30586
05/11/2022, 8:18 AMcurved-television-6568
05/11/2022, 8:20 AMcurved-television-6568
05/11/2022, 8:22 AMenough-analyst-54434
05/11/2022, 2:18 PMPYTHONPATH
as part of its quest to provide isolated environments though; so you must either set PEX_INHERIT_PATH
in your environment to tell your PEX it is OK to let the PYTHONPATH
leak in (See: https://pex.readthedocs.io/en/v2.1.85/api/vars.html#PEX_INHERIT_PATH) or else you can set PEX_EXTRA_SYS_PATH
with the path element to add in directly (See: https://pex.readthedocs.io/en/v2.1.85/api/vars.html#PEX_EXTRA_SYS_PATH).enough-analyst-54434
05/11/2022, 2:21 PMPEX_*
technique ot the installing the PEX in a container approach should work without modifying platform strings. Do not though that in the PEX in a container approach you need to change the 1st example RUN
line from RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /my-app.pex venv --scope=deps --compile /my-app
to RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /my-app.pex venv --pip --scope=deps --compile /my-app
. Without adding that --pip
then created venv will not include pip
to use to install more dependencies with.enough-analyst-54434
05/11/2022, 2:29 PMIs there a way to ignore the platform string only on the pyodbc dependency?No. A PEX is a fully enclosed environment so Pex demands it is able to include all dependencies requested. As such, you can't say, "except for FastAPI". Instead you must take the work you did to build FastAPI from source in the container and save the resulting Linux platform specific FastAPI wheel outside the container. You then make that wheel availale to your build using
[python-repos] repos|indexes
https://www.pantsbuild.org/docs/reference-python-repos (whichever is easier for you to host internally, for most this is a repo
which can be a simple directory with wheels in it that is shared over NFS or sshfs or some other network filesystem or else a simple webserver with index.html generation enabled for the directory with wheels in it). Finally, your platforms
PEXes will now be buildable via Pants and the will include FastAPI since you pre-built the Linux wheel and made it available outside of PyPI.
Its a bit of work to be sure, but does that make sense @icy-hair-30586?icy-hair-30586
05/11/2022, 3:23 PM