https://pantsbuild.org/ logo
s

straight-action-80318

07/20/2022, 9:16 PM
When I spawn subprocesses from my
pex_binary
the subprocesses don’t seem to have the same dependencies available. Do I need to manually set something to propagate environments to spawned processes?
1
b

bitter-ability-32190

07/20/2022, 9:23 PM
Are they Python subprocesses?
s

straight-action-80318

07/20/2022, 9:24 PM
Yeah
b

bitter-ability-32190

07/20/2022, 9:24 PM
If so, this is "fixed" in newer PEX (therefore newer Pants) See https://github.com/pantsbuild/pex/issues/1825 There's also a workaround of setting
PYTHONPATH
in the
env
argument when running the subprocess using
sys,path
s

straight-action-80318

07/20/2022, 9:26 PM
oh nice, timely
do you know what release I need to pick this change up?
b

bitter-ability-32190

07/20/2022, 9:29 PM
I just switched to mobile, so I couldn't tell you immediately. There's also support to use newer PEX in an older Pants, but YMMV
s

straight-action-80318

07/20/2022, 9:33 PM
okay I think this is working with the latest RC that’ll be okay at least for now
thanks!
b

bitter-ability-32190

07/20/2022, 9:34 PM
Hot tip, invoke code using -m and the module name. And make sure the module is in its own string. Then enable Pants string import inference 😉
n

nice-florist-55958

07/21/2022, 1:42 AM
Does this mean we don't need
env={**os.environ, **{“PYTHONPATH”: “:”.join(sys.path)}}
for Popen anymore?
h

happy-kitchen-89482

07/21/2022, 2:30 AM
I believe so
5 Views