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

Path filter for PythonInterpreter.iter_candidates. #1046

Merged
merged 3 commits into from
Sep 27, 2020

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Sep 27, 2020

This adds support for a path filter to allow unification of Pex
buildtime and runtime interpreter discovery. The PythonInterpreter
public API family of iter, iter_candidates and all is
type-annotated and tests are added for iter_candidates. To support
proper annotation of iter_candidates helpers, @overload support is
added for Python 2.7.

Work towards #1043

with temporary_dir() as bin_dir:
os.symlink(test_interpreter2, os.path.join(bin_dir, "jake"))

# Verify path filtering happens before interpreter resolution, which os.path.realpaths
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the use-case coming in a follow-up PR to close #1043. The PEX runtime needs to be able to filter by basename when PEX_PYTHON=python2 (for example) is in the environment. Today this is handled with dedicated code in pex_bootstrapper.py that is a near duplicate of the relevant code in PythonInterpreter.iter_candidates.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, John!

Comment on lines +36 to +37
InterpreterIdentificationJobError = Tuple[str, Union[Job.Error, Exception]]
InterpreterOrJobError = Union["PythonInterpreter", InterpreterIdentificationJobError]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thank you.

This adds support for a path filter to allow unification of Pex
buildtime and runtime interpreter discovery. The PythonInterpreter
public API family of `iter`, `iter_candidates` and `all` is
type-annotated and tests are added for `iter_candidates`. To support
proper annotation of iter_candidates helpers, `@overload` support is
added for Python 2.7.

Work towards pex-tool#1043
@jsirois jsirois force-pushed the issues/1043/path_filter_prework branch from 5e50741 to 5ad317e Compare September 27, 2020 22:30
@jsirois jsirois merged commit cff4089 into pex-tool:master Sep 27, 2020
@jsirois jsirois deleted the issues/1043/path_filter_prework branch September 27, 2020 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants