abundant-autumn-67998
02/27/2023, 6:23 PMpex-tools my-pex.pex venv /here
faster?enough-analyst-54434
02/27/2023, 6:29 PMstat
! There are no low-hanging fruit to speed up venv creation that I'm aware of, but it is not parallelized; so that could be tackled. It would be great though to start with a baseline public shareable case.abundant-autumn-67998
02/28/2023, 5:10 PMPEX_PATH=large.pex pex-tools small.pex venv /venv
. Not sure if this is intended behavior but it does merge the two pexes into the same venv. I'd rather unpack the large pex into a different venv-large
and reuse it because the large pex changes less frequently. Is it possible to "merge" two venvs at runtime?enough-analyst-54434
02/28/2023, 5:12 PMenough-analyst-54434
02/28/2023, 5:19 PMPEX_EXTRA_SYS_PATH
+ some new feature to install a PEX's code in a flat dir (like a site-packages
dir without the surrounding venv).
+ Use PYTHONPATH=large.pex
+ `--non-hermetic-scripts`when installing the venv + add a shim import __pex__
somewhere early in the venv entrypoint code
+ Install large.pex
in a venv that uses --copies
, then point to that venv's python
when building the small.pex
venv and also enable --system-site-packages
enough-analyst-54434
02/28/2023, 5:19 PMenough-analyst-54434
02/28/2023, 5:20 PMenough-analyst-54434
02/28/2023, 5:21 PMPEX_TOOLS=1
a venv for large.pex
and then PEX_EXTRA_SYS_PATH=/large/venv/lib/pythonX.Y/site-packages
when running the small pex venv.enough-analyst-54434
02/28/2023, 5:22 PMpythonX.Y
matches now between large and small.abundant-autumn-67998
02/28/2023, 7:01 PMPEX_EXTRA_SYS_PATH=/large/venv/lib/pythonX.Y/site-packages
seems straightforward. i also need the console scripts but I could just add /large/venv/bin
to the PATH
.enough-analyst-54434
02/28/2023, 7:01 PMenough-analyst-54434
02/28/2023, 7:02 PMenough-analyst-54434
02/28/2023, 7:02 PMenough-analyst-54434
02/28/2023, 7:03 PMPEX_EXTRA_SYS_PATH
won't work, Python knows nothing of that. You'll need PYTHONPATH=large/site-packages:small/site-packages
+ the --non-hermetic-scripts
option to pex-tools ... venv
I think.abundant-autumn-67998
02/28/2023, 7:11 PM/venv/small/pex
still respect the env PYTHONPATH
? not sure how isolated it tries to run.enough-analyst-54434
02/28/2023, 7:14 PM--non-hermetic-scripts
venv tool option to get rid of the -sE
in the python shebang there and in console scripts.abundant-autumn-67998
02/28/2023, 7:41 PM-sE
anyway, but I do see a the -sE
removed from venv/pex
with --non-hermetic-scripts
enough-analyst-54434
02/28/2023, 7:50 PMenough-analyst-54434
02/28/2023, 7:50 PMenough-analyst-54434
02/28/2023, 7:52 PM$ pex cowsay --include-tools -o cowsay.pex
$ PEX_VERBOSE=1 PEX_TOOLS=1 ./cowsay.pex venv here
pex: Laying out PEX zipfile /home/jsirois/dev/pantsbuild/jsirois-pex/cowsay.pex: 0.1ms
pex: Executing installed PEX for /home/jsirois/dev/pantsbuild/jsirois-pex/./cowsay.pex at /home/jsirois/.pex/unzipped_pexes/d4455ae19e928aac33b14fa15e6cfcf00dd81e6b
pex: Testing /usr/bin/python3.10 can resolve PEX at /home/jsirois/.pex/unzipped_pexes/d4455ae19e928aac33b14fa15e6cfcf00dd81e6b: 1.6ms
pex: Using the current interpreter /usr/bin/python3.10 since it matches constraints and PYTHONPATH is not set.
pex: Re-writing /home/jsirois/dev/pantsbuild/jsirois-pex/here/bin/cowsay
pex: Executing PEX_TOOLS venv: 28.9ms
pex: Laying out PEX zipfile /home/jsirois/dev/pantsbuild/jsirois-pex/cowsay.pex: 0.1ms
$ head -1 here/bin/cowsay
#!/home/jsirois/dev/pantsbuild/jsirois-pex/here/bin/python3.10 -sE
enough-analyst-54434
02/28/2023, 7:54 PM$ PEX_TOOLS=1 ./cowsay.pex venv --force --non-hermetic-scripts here
$ head -1 here/bin/cowsay
#!/home/jsirois/dev/pantsbuild/jsirois-pex/here/bin/python3.10
enough-analyst-54434
02/28/2023, 7:55 PMabundant-autumn-67998
02/28/2023, 9:46 PM-sE
in bin/flask
). Possibly an error in testing.enough-analyst-54434
02/28/2023, 9:59 PM