Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEX_INHERIT_PATH (and maybe other vars) ignored when venv used from cache #1343

Closed
benjyw opened this issue May 2, 2021 · 6 comments · Fixed by #1354
Closed

PEX_INHERIT_PATH (and maybe other vars) ignored when venv used from cache #1343

benjyw opened this issue May 2, 2021 · 6 comments · Fixed by #1354
Assignees
Labels

Comments

@benjyw
Copy link
Collaborator

benjyw commented May 2, 2021

To reproduce:

python -m pex ansicolors --venv -o repro.pex 
./repro.pex

ctrl-D

PEX_INHERIT_PATH=invalid_val ./repro.pex

ctrl-D

expected behavior: Invalid value for PEX_INHERIT_PATH error.
actual behavior: pex runs from cached venv

Expected behavior can be triggered by:

rm -rf ~/.pex/venvs
PEX_INHERIT_PATH=invalid_val ./repro.pex

Obviously the invalid_val thing is just an easy way to show whether PEX_INHERIT_PATH is being inspected. My real goal is to use it with a valid value and have that value take effect...

@jsirois
Copy link
Member

jsirois commented May 3, 2021

Where would you expect the PEX to inherit from? It's running in a venv after all.

@benjyw
Copy link
Collaborator Author

benjyw commented May 3, 2021

Good point from an implementation perspective.

But from the user perspective: I've been handed a .pex file (I neither know nor care that it was created with --venv). I see in the documentation that PEX_INHERIT_PATH should do a thing, and I see that in practice it not only does not do the thing, but it is ignored - I can give it a bad value without getting an error. Then I nuke the venv cache and suddenly do get that error.

I think that user would expect the PEX to inherit from the venv they think they're in (that is, the venv active in their current shell), and/or from their PYTHONPATH.

But if we can't make the feature work sensibly, and you make a good argument for that, then we should probably error out on any attempt to use it?

@jsirois
Copy link
Member

jsirois commented May 4, 2021

Yeah, it's a tough feature generally. Venv aside it almost makes no sense since Pex will pick a compatible interpreter at runtime and maybe that one was not the one you were expecting / doesn't have the extra distributions you wanted. Afaict the feature is only for experimenting unless you either:

  1. Have tightly controlled target hosts with just one compatible interpreter.
  2. Like 1, except you use pexrc files to do the tightening.
  3. You run PEX files via a script or other command line that is of the form /this/compatible/interpreter my.pex.

I'd prefer to fail fast for unsupported Pex env vars in venv mode until someone can come up with an easy to understand algorithm for picking which env to inherit the path from for a venv pex. I'd like even more to drop the feature!

@benjyw
Copy link
Collaborator Author

benjyw commented May 4, 2021

Remind me why we have the feature? AFAICT we don't use it in Pants.

@jsirois
Copy link
Member

jsirois commented May 4, 2021

Pretty sure Twitter. You can imagine having a blessed interpreter on a host with puppet installed numerical computing distributions in its site-packages and avoiding shipping those dists over the network in N PEXes. I need to do some research though to confirm this.

@benjyw
Copy link
Collaborator Author

benjyw commented May 4, 2021

Oh right, that makes sense. Well we should probably keep the feature, I can see how it might be handy.

@jsirois jsirois added the bug label May 7, 2021
jsirois added a commit to jsirois/pex that referenced this issue Jun 2, 2021
Previously you could not ask a `--venv` PEX to run in unzip mode. This
regularizes all PEX files so that they can be asked to operate in unzip
mode or venv mode whenever possible (venv mode requires the PEX was
built with `--include-tools` or `--venv`).

Work towards pex-tool#1343.
jsirois added a commit that referenced this issue Jun 2, 2021
Previously you could not ask a `--venv` PEX to run in unzip mode. This
regularizes all PEX files so that they can be asked to operate in unzip
mode or venv mode whenever possible (venv mode requires the PEX was
built with `--include-tools` or `--venv`).

Work towards #1343.
jsirois added a commit to jsirois/pex that referenced this issue Jun 2, 2021
Previously these were silently ignored which was confusing at best.

Fixes pex-tool#1343
jsirois added a commit that referenced this issue Jun 3, 2021
Previously these were silently ignored which was confusing at best.

Fixes #1343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants