echoing-farmer-15630
02/22/2022, 9:09 PMexecution_mode="venv"
, but basically what's happening is that in my virtual environment I can import the namespace package and do a dir
and see lots of stuff; the pex shows the identical dependencies in there, and I can still import the namespace package, but the result is an empty module.
I can post more specifics, but is this a known thing with pexes that can be worked around?enough-analyst-54434
02/22/2022, 9:14 PMpex --help
:
...
--venv-site-packages-copies, --no-venv-site-packages-copies
If --venv is specified, populate the venv site packages using hard links or copies of resolved PEX dependencies instead of symlinks. This can be used to work around problems with tools or libraries that are confused by symlinked source files.
(default: False)
...
But I thought Pants was passing --venv-site-packages-copies
by default due to problems like this. Looking....enough-analyst-54434
02/22/2022, 9:14 PMechoing-farmer-15630
02/22/2022, 9:16 PMechoing-farmer-15630
02/22/2022, 9:16 PMenough-analyst-54434
02/22/2022, 9:18 PMenough-analyst-54434
02/22/2022, 9:18 PM[pex]
venv_use_symlinks = true
If so, that should be reverted. If not I'll have more questions.echoing-farmer-15630
02/22/2022, 9:19 PMechoing-farmer-15630
02/22/2022, 9:19 PM[pex]
heading I should say)enough-analyst-54434
02/22/2022, 9:19 PMenough-analyst-54434
02/22/2022, 9:20 PM~/.cache/pants/named_caches/pex_root/venvs/...
path?echoing-farmer-15630
02/22/2022, 9:20 PMenough-analyst-54434
02/22/2022, 9:21 PMechoing-farmer-15630
02/22/2022, 9:22 PMenough-analyst-54434
02/22/2022, 9:23 PMrepl
? Or an export
venv?enough-analyst-54434
02/22/2022, 9:23 PMechoing-farmer-15630
02/22/2022, 9:23 PMechoing-farmer-15630
02/22/2022, 9:23 PMechoing-farmer-15630
02/22/2022, 9:24 PM-m pytest
for tests etc)enough-analyst-54434
02/22/2022, 9:24 PMenough-analyst-54434
02/22/2022, 9:24 PMechoing-farmer-15630
02/22/2022, 9:24 PMpex_binary
target which I can test independently (and which has this error) and the docker container just relies on it as its entrypoint.enough-analyst-54434
02/22/2022, 9:25 PMenough-analyst-54434
02/22/2022, 9:26 PMPEX_TOOLS=1 ./your.pex info
redacted if needed?echoing-farmer-15630
02/22/2022, 9:26 PMCOPY workers.remote.remote_worker /bin/worker
...and letting Pants do its magic to build the pex and install it.
But the pex still does that outside the container in any case.enough-analyst-54434
02/22/2022, 9:27 PMechoing-farmer-15630
02/22/2022, 9:31 PMbin/activate
gives me the same missing libs, but ...
whoa. OK, first, it's 3rdparty (IBM's qiskit). Second, yeah, there's some weirdness. In the venv, I just see some dist-info stuff:
venvs/90ead2017bd04f8310cd1e14573bd10fcec8e7ac/41e856e498bc4b3ee69c2c959cfa129f9a925ee5 via š v3.9.9 (omni)
⯠find . -name "*qiskit*"
./lib/python3.9/site-packages/pex-ns-pkgs/1/qiskit_aer-0.9.0.dist-info
./lib/python3.9/site-packages/pex-ns-pkgs/1/qiskit_terra-0.18.3.dist-info
./lib/python3.9/site-packages/pex-ns-pkgs/1/qiskit_aer.libs
./lib/python3.9/site-packages/pex-ns-pkgs/1/qiskit
./lib/python3.9/site-packages/pex-ns-pkgs/2/qiskit_ibmq_provider-0.16.0.dist-info
./lib/python3.9/site-packages/pex-ns-pkgs/2/qiskit
...but in the built dist package, I see a lot of the source files for some of those packages, under .deps
, ie
0 Stored 0 0% 1980-01-01 00:00 00000000 .deps/qiskit_terra-0.18.3-cp39-cp39-manylinux2010_x86_64.whl/qiskit/circuit/library/boolean_logic/
645 Defl:N 373 42% 1980-01-01 00:00 4d758fbb .deps/qiskit_terra-0.18.3-cp39-cp39-manylinux2010_x86_64.whl/qiskit/circuit/library/boolean_logic/__init__.py
2644 Defl:N 1070 60% 1980-01-01 00:00 63275574 .deps/qiskit_terra-0.18.3-cp39-cp39-manylinux2010_x86_64.whl/qiskit/circuit/library/boolean_logic/inner_product.py
3858 Defl:N 1467 62% 1980-01-01 00:00 9257cc40 .deps/qiskit_terra-0.18.3-cp39-cp39-manylinux2010_x86_64.whl/qiskit/circuit/library/boolean_logic/quantum_and.py
...which I don't see unpacked in the venv.echoing-farmer-15630
02/22/2022, 9:31 PMenough-analyst-54434
02/22/2022, 9:32 PMls -la
to start to get un-baffled.enough-analyst-54434
02/22/2022, 9:32 PMechoing-farmer-15630
02/22/2022, 9:33 PM... "qiskit_aer-0.9.0-cp39-cp39-m
ā anylinux_2_12_x86_64.manylinux2010_x86_64.whl": "d346d7a5f1f40d0e537d5cdeed409591d957e0a3", "qiskit_ibmq_
ā provider-0.16.0-py3-none-any.whl": "d7e2598eedab1acd9ec10faa9b9d9989f70ca2a0", "qiskit_terra-0.18.3-cp39-
ā cp39-manylinux2010_x86_64.whl": "ddf8328426dcec30bd78ffcb4640f42e7f82ec00",...
echoing-farmer-15630
02/22/2022, 9:34 PMpex_binary(
dependencies=[...],
execution_mode="venv"
)
so I'm glad to fuss around with other options or whatnot.enough-analyst-54434
02/22/2022, 9:35 PMPEX_TOOLS=1 ./my.pex venv right/here
source right/here/bin/activate
enough-analyst-54434
02/22/2022, 9:35 PMechoing-farmer-15630
02/22/2022, 9:36 PMechoing-farmer-15630
02/22/2022, 9:36 PMenough-analyst-54434
02/22/2022, 9:37 PMechoing-farmer-15630
02/22/2022, 9:38 PM--compile
.echoing-farmer-15630
02/22/2022, 9:38 PMechoing-farmer-15630
02/22/2022, 9:39 PMechoing-farmer-15630
02/22/2022, 9:39 PMenough-analyst-54434
02/22/2022, 9:39 PM--collisions-ok
echoing-farmer-15630
02/22/2022, 9:39 PM--compile
created great rage.enough-analyst-54434
02/22/2022, 9:40 PMenough-analyst-54434
02/22/2022, 9:40 PMechoing-farmer-15630
02/22/2022, 9:41 PMenough-analyst-54434
02/22/2022, 9:41 PMPEX_TOOLS=1 /the/python/I/meant my.pex venv ...
if your PEX does not have interpreter constraints (see the pex info you generated to see if it does).enough-analyst-54434
02/22/2022, 9:42 PMechoing-farmer-15630
02/22/2022, 9:43 PM--rm all
was to clean the dest, not delete the pex, but that's great.
So after the warning for the collision I get a pause and then
...
raise cls.NonZeroExit(cmd, process.returncode, stdout, stderr)
pex.executor.Executor.NonZeroExit: received exit code 1 during execution of `['/home/vputz/.pyenv/versions/3.9.9/bin/python3.9', '-s', '-E', '-m', 'compileall', '/tmp/remote_worker']` while trying to execute `['/home/vputz/.pyenv/versions/3.9.9/bin/python3.9', '-s', '-E', '-m', 'compileall', '/tmp/remote_worker']`
echoing-farmer-15630
02/22/2022, 9:44 PMinterpreter_constraints = [">=3.9"]
enough-analyst-54434
02/22/2022, 9:44 PMechoing-farmer-15630
02/22/2022, 9:45 PM/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/tools/commands/venv.py:230: PEXWarning: Encountered collision building venv at /tmp/remote_worker from /home/vputz/projects/forge/dist/workers.remote.remote_worker/remote_worker.pex:
1. /tmp/remote_worker/lib/python3.9/site-packages/dwave/__init__.py was provided by:
sha1:03ed2c399e8fecd324f4e9719168a3ea3fa02900 -> /home/vputz/.pex/installed_wheels/8eefaf7bf166f47206f8e3258b0fb79b819698f8/dwave_preprocessing-0.3.1.post0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl/dwave/__init__.py
sha1:52c2da64768c46c18626ac887b146a01ae869677 -> /home/vputz/.pex/installed_wheels/07e459934624620d022a978475227daa5f972918/dwave_system-1.9.0-py3-none-any.whl/dwave/__init__.py
sha1:764c752b19626766a09406a6d221938432bdf4fb -> /home/vputz/.pex/installed_wheels/cf15b1693c5c3d3dfe1d88b071b5d430f8ea2092/dwave_cloud_client-0.9.2-py3-none-any.whl/dwave/__init__.py
pex_warnings.warn(message)
Traceback (most recent call last):
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/pex.py", line 473, in execute
exit_value = tools.main(pex=PEX(sys.argv[0]))
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/tools/main.py", line 90, in main
result = catch(pex_command.run, pex)
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/commands/command.py", line 130, in catch
return func(*args, **kwargs)
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/tools/commands/venv.py", line 569, in run
pex.interpreter.execute(["-m", "compileall", venv_dir])
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/interpreter.py", line 1190, in execute
stdout, stderr = Executor.execute(cmd, stdin_payload=stdin_payload, env=env, **kwargs)
File "/home/vputz/.pex/unzipped_pexes/b23715185de82b6720330283368463c29b19d760/.bootstrap/pex/executor.py", line 99, in execute
raise cls.NonZeroExit(cmd, process.returncode, stdout, stderr)
pex.executor.Executor.NonZeroExit: received exit code 1 during execution of `['/home/vputz/.pyenv/versions/3.9.9/bin/python3.9', '-s', '-E', '-m', 'compileall', '/tmp/remote_worker']` while trying to execute `['/home/vputz/.pyenv/versions/3.9.9/bin/python3.9', '-s', '-E', '-m', 'compileall', '/tmp/remote_worker']`
enough-analyst-54434
02/22/2022, 9:47 PM/home/vputz/.pyenv/versions/3.9.9/bin/python3.9 -s -E -m compileall /tmp/remote_worker
manually?echoing-farmer-15630
02/22/2022, 9:50 PMenough-analyst-54434
02/22/2022, 9:50 PMechoing-farmer-15630
02/22/2022, 9:51 PMenough-analyst-54434
02/22/2022, 9:51 PMechoing-farmer-15630
02/22/2022, 9:52 PMechoing-farmer-15630
02/22/2022, 9:52 PMechoing-farmer-15630
02/22/2022, 9:52 PM--compile
just tries to byte-compile everything?enough-analyst-54434
02/22/2022, 9:53 PMenough-analyst-54434
02/22/2022, 9:53 PMechoing-farmer-15630
02/22/2022, 9:53 PMenough-analyst-54434
02/22/2022, 9:53 PM--venv-site-packages-copies
since not everyone will have this be a valid workaround for them.echoing-farmer-15630
02/22/2022, 9:53 PMenough-analyst-54434
02/22/2022, 9:54 PMechoing-farmer-15630
02/22/2022, 9:54 PMenough-analyst-54434
02/22/2022, 10:04 PMenough-analyst-54434
02/22/2022, 10:08 PM~/.cache/pants/named_caches/pex_root
. It's probably not useful in most other use cases though.echoing-farmer-15630
02/23/2022, 12:20 AMFROM baselayer as pex
COPY my_pex /pex
# this expands and builds the venv
RUN PEX_TOOLS=1 /pex/my_pex.pex venv --rm all --compile --collisions-ok /venv
# we now start a new layer and copy the venv from the old
FROM baselayer as venv
COPY --from=pex /venv /venv
...
... this really makes a difference in some images; one of mine went from 3.4Gb to 2.43Gb (it includes some hideously big libraries like Torch); another went from 1.33Gb to 1.09Gb, so it's not an insignificant savings!
You can use a tool like dive (https://github.com/wagoodman/dive) to inspect the images and see that the original method leaves the pex "space" in there even though it's deleted.enough-analyst-54434
02/23/2022, 2:48 AM--rm all
IIUC. I am the de-facto Pex group but its also open source! So do you want to take a crack at this?: https://github.com/pantsbuild/pex/blob/v2.1.67/docs/recipes.rstechoing-farmer-15630
02/28/2022, 7:48 PMenough-analyst-54434
02/28/2022, 8:45 PMechoing-farmer-15630
03/01/2022, 3:59 PM