Is there any way to activate the virtual environme...
# general
Is there any way to activate the virtual environment a test is run in for that test execution? I'm dealing with a bunch of horrible things that Flink does that seem to only work if the python interpreter corresponds to one built with a virtual environment. It's running commands from a jvm and bash script like
python -m <some things it expects to be on path>
. When the test is executing,
which python
just points to the system install at
Hmm, when I do
subprocess.check_output(['which', 'python'])
it points back to system
Well, there are a few things getting mixed up here. If you want
adjustment, that's one thing. Your example claimed
was the issue (-m ...)
sys.executable -m ...
should work fine.
Here is the specific part that is unhappy. And yeah, I'm trying to play some
games to get things happy currently.
So, have you tried exporting
? The script you point to succumbs to that.
Just need to hook early enough. Maybe conftest hook. I have 0 clues about flink.
How do you mean export? By environment variable or something else?
Yes, env var. Read the ~1st line of the script you pointed to.
Yeah, mostly good things and then a few things like this that are so broken out of the box. Unfortunately that env var setting didn't affect things and I'm pretty sure it was high up enough
It does work fine from the terminal so I must be doing something slightly wrong in test set up. I'll keep poking. Thanks for the ideas!
Ok, and, at the end of the day, don't forget the
--venv prepend
thing. I think that could be a safe, global, change to all Pants VenvPex setups; so might be worth bugging & fixing.
You could try it and run Pants from sources via your favorite technique to test.
I think I found a suitable workaround for now. Setting
envvar didn't work, but setting
to where my source code and deps are did. So basically copying what they do in
Just checking that you're aware of
which lets you play in the sandbox the test ran in
👍 1