full-toothbrush-7567604/04/2022, 4:17 PM
as an entry point. I want to be able to import and use these 1P and 3P dependencies in code that is run inside of the Docker image. What is the “right way” to do this? I can think of a couple of options:
1. Make a
it in my
RUN pip install …
a. This probably won’t let me take advantage of Pants’ caching for the 3P dependencies 😕, is that right?
2. Make a
and use some fancy logic to “expand” the pex’s
to make my 1P and 3P code importable
a. It looks like I can build the pex in “venv” mode and then activate the venv. That works great in isolation, however, I need this to work inside of an active conda environment in the container, which doesn’t work 😅 (kind of strange i know I know haha)
Thanks in advance and let me know if this question is unclear.
enough-analyst-5443404/04/2022, 4:24 PM
. Make sure your
(or both). Then install your PEX like so: https://pex.readthedocs.io/en/v2.1.75-public-signed/recipes.html#pex-app-in-a-container. Finally, use that venv you installed like any other.
icy-hair-3058604/05/2022, 4:32 PM
enough-analyst-5443404/05/2022, 4:58 PM
options highlighted here 1st create a new venv and then add sources or deps to it. There would have to be a mode where they don't 1st create a new venv, but are just pointed at an existing one. Something like
. That example updates the
PEX_TOOLS=1 /usr/local/bin/python3.10 /my-app.pex venv --update --scope=deps --compile /usr/local
system installed Python 3.10 in this case (i.e.: it would populate
). If you have a need for that sort of feature, definitely file a Pex issue spelling all this out. If you want to try implementing the feature, I'm happy to help guide you.
That would get all the third party dependencies in your PEX file appropriate to the system Python 3.10 interpreter at
PEX_TOOLS=1 /usr/local/bin/python3.10 /my-app.pex repository extract --dest-dir /tmp/pex-deps-dump-wheels
/usr/local/bin/pip3.10 install --no-deps /tmp/pex-deps-dump-wheels/*.whl
extracted as wheels and then installed in the site-packages of that system
icy-hair-3058604/07/2022, 7:04 AM
command that would be perfect :)