Hi, not sure if this is the right place to ask abo...
# general
q
Hi, not sure if this is the right place to ask about Pex but was independently looking into transitioning some of our other workflows to using pex as an intermediate step towards adopting pants & I ran into the following issue: I'm attempting to package dependencies in our
requirements.txt
in a pex file, and the following command succeeds:
Copy code
pex --interpreter-constraint CPython==3.9.12 -r requirements.txt -o test.pex
However, when attempting to run it with
./test.pex
I encounter the following error:
Copy code
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9: can't find '__main__' module in '/path/to/test.pex'
I'm able to produce smaller pex files and run them without a problem (ie.
pex --interpreter-constraint CPython==3.9.12 numpy pandas -o test.pex
), but am encountering this error any time I attempt to include the full requirements. I have confirmed after unzipping
test.pex
that
__main__.py
exists. The pex file is ~700M currently. I came across this issue: https://github.com/pantsbuild/pex/issues/958 and was wondering if this might be related
w
could be… have you tried
--layout packed
as mentioned there?
1
700MB is lower than i would expect to see have this issue, but.
q
Unfortunately I hit the same error w/
--layout packed
Ah, I must have had some other option misconfigured earlier. This succeeds, though it appears to produce a directory instead of a standalone file? Does this function identically to a standalone file from the perspective of the pants jupyter plugin etc?
w
This succeeds, though it appears to produce a directory instead of a standalone file?
correct.
Does this function identically to a standalone file from the perspective of the pants jupyter plugin etc?
it should?… having a
__main__.py
should be picked up by any interpreter
👍 1
ah, mm. but i can’t be certain about the jupyter plugin… may need a tweak there, but try it.
q
Ok I think this makes sense now, thanks for the quick answers @witty-crayon-22786. I'll give the jupyer plugin a spin and see how it does out of the box
w
sure thing. if you have time to report back on the linked issue, that would be appreciated.
q
For sure, will do!
Also @witty-crayon-22786 this is working for me now without
--layout packed
since I realized that the existing
venv/
in my directory was also being included in the pex file (along w/ other extraneous stuff like bazel build directories etc) -- down to a much saner ~25M
👍 1