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

Allow constraining the interpreter search path directly. #1012

Closed
jsirois opened this issue Jul 24, 2020 · 3 comments · Fixed by #1077
Closed

Allow constraining the interpreter search path directly. #1012

jsirois opened this issue Jul 24, 2020 · 3 comments · Fixed by #1077

Comments

@jsirois
Copy link
Member

jsirois commented Jul 24, 2020

Right now the Pex API allows this:
https://github.com/pantsbuild/pex/blob/b51b340bea8a585a246997071a815d008986d6e3/pex/interpreter.py#L278-L288

Neither the CLI (buildtime) nor runtime via PEX-INFO / ENV vars does however forcing manipulation of the PATH to acheive the desired effect. This is problematic at buildtime since during wheel building tools may need to be invoked by subprocesses (think gcc). This could also be problematic at runtime for any PEX housing user code that needs to shell out to tools expected to be on the PATH.

See pantsbuild/pants#9760 for the motivating issue.

@jsirois
Copy link
Member Author

jsirois commented Jul 28, 2020

OK - Lies above. Both buildtime and runtime support PEX_PYTHON_PATH which is a path-like env var that accepts both directory entries and paths to interpreter binaries:

  1. Build time:
    https://github.com/pantsbuild/pex/blob/5fd9b1527691f3efb42a469a563a7653a3a1594d/pex/bin/pex.py#L722-L725
  2. Run time:
    https://github.com/pantsbuild/pex/blob/b51b340bea8a585a246997071a815d008986d6e3/pex/pex_bootstrapper.py#L203-L215

This fully suffices for the Pants motivating use case. It still may make sense to add a CLI flag / PexInfo metadata slot for this to bake in a "corporate" interpreter path without resorting to ~/.pexrc or /etc/pexrc, but that resort has been working? for Twitter at least as an example of corporate.

@jsirois jsirois mentioned this issue Aug 29, 2020
4 tasks
This was referenced Oct 2, 2020
Eric-Arellano added a commit that referenced this issue Oct 15, 2020
…a PEX (#1077)

Closes #1012.

Currently, PEX defaults to searching the $PATH when `--interpreter-constraint` and/or `--resolve-local-platforms` are used. (Otherwise, it uses the current interpreter or `--python`).

You can specify `PEX_PYTHON_PATH`, but this has several issues:

* Env vars should only be used for runtime, not build time. We break that separation here.
* This only works if `PEX_IGNORE_RCFILES` is not set to true. Pants must set this option, meaning Pants cannot leverage this mechanism.
* The behavior doesn't work as expected if running Pex as a Pex: #1075

Instead of further using `PEX_PYTHON_PATH`, we add a proper `--python-path` flag. In a followup, we can remove the `PEX_PYTHON_PATH` mechanism.
@Eric-Arellano Eric-Arellano mentioned this issue Oct 15, 2020
7 tasks
@Eric-Arellano
Copy link
Contributor

Closed by #1077. #1075 tracks removing PEX_PYTHON_PATH from build time.

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

Successfully merging a pull request may close this issue.

3 participants