bitter-ability-32190
07/06/2022, 4:11 PMenough-analyst-54434
07/06/2022, 4:35 PMPYTHONPATH
is scrubbed by the Pex runtime by default. We'd have to set PYTHONPATH
plus one of:
pex --help-variables
...
PEX_INHERIT_PATH: String (false|prefer|fallback)
Allow inheriting packages from site-packages, user site-packages
and the PYTHONPATH. By default, PEX scrubs any non stdlib packages
from sys.path prior to invoking the application. Using 'prefer'
causes PEX to shift any non-stdlib packages before the pex
environment on sys.path and using 'fallback' shifts them after
instead. Using this option is generally not advised, but can help
in situations when certain dependencies do not conform to standard
packaging practices and thus cannot be bundled into PEX files. See
also PEX_EXTRA_SYS_PATH for how to *add* to the sys.path. Default:
false.
bitter-ability-32190
07/06/2022, 4:37 PMThat includes site-packages though, which is not what you wantHow Is it not what I want? I want to subprocess run another file with the same set of deps I'm running with.
enough-analyst-54434
07/06/2022, 4:37 PMbitter-ability-32190
07/06/2022, 4:38 PMPEX_EXTRA_SYS_PATH
to be manifested to subprocess.run([sys.exectuable, ...], ...)
callsenough-analyst-54434
07/06/2022, 4:41 PMsubprocess.run([sys.executable, ...], env={"PYTHONPATH=os.pathsep.join(sys.path), **os.environ})
?bitter-ability-32190
07/06/2022, 4:41 PMenough-analyst-54434
07/06/2022, 4:44 PMbitter-ability-32190
07/06/2022, 4:47 PMenough-analyst-54434
07/06/2022, 4:53 PMbitter-ability-32190
07/06/2022, 4:55 PMenough-analyst-54434
07/06/2022, 5:03 PMAh system site-packages.Even an interpreter found in a random venv will almost always have a site-packages with pip installed for example. So Pex scrubs the site-packages of any interpreter it discovers regardless of its provenance.
It's a "can but my users are throwing bricks and fits because 'this worked in Bazel'".Ok, that counts as a can't in my book. I'll amend the issue.