I have a 3rd-party dependency with a CLI that spaw...
# general
r
I have a 3rd-party dependency with a CLI that spawns a subprocess that imports a module from that 3rd-party dependency. If I run the CLI with
pants
, then the subprocess (which is spawned with
sys.executable
- the python executable without any virtual environment) fails because it cannot import that 3rd-party dependency (since it does not have a virtual environment with the 3rd-party dependency). Is there an easy way to preserve dependencies for child subprocesses? To be more specific, I want to run the
dagster
CLI with the
dev
command, which spawns a subprocess here
1
b
How are you running the cli with pants?
r
I have a
pex_binary
target that depends on the
python_requirement
target for the 3rd-party dependency, with the
entry_point
configured to the main module. Is there a better way?
b
You can run the python_requirement directly (as of some version of pants)
Also, if your PEX runs in venv mode I think this issue goes away
r
You can run the python_requirement directly (as of some version of pants)
Yes, in this particular case, that doesn't work because for the command I want to run, the 3rd-party dependency needs another 3rd-party dependency to be installed. For the
pex_binary
target I have both 3rd-party dependencies specified in
dependencies
Also, if your PEX runs in venv mode I think this issue goes away
Yes, that worked! Thank you!
b
I had a similar issue with the Ray package. And yes, 'venv' mode fixed it.
👍 1