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

Complete support for PEX Python interpreter mode. #1748

Merged
merged 2 commits into from
May 4, 2022

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented May 4, 2022

Apply @BrandonTheBuilder's work in #1746 to the --venv case and flesh
out complete support for Python interpreter emulation by adding . to
the sys.path when running as an interpreter and handling interpreter
execution of directories.

Fixes #1745

Apply @BrandonTheBuilder's work in pex-tool#1746 to the `--venv` case and flesh
out complete support for Python interpreter emulation by adding `.` to
the `sys.path` when running as an interpreter and handling interpreter
execution of directories.

Fixes pex-tool#1745
@jsirois jsirois requested review from benjyw and Eric-Arellano May 4, 2022 21:05
Comment on lines +672 to +673
# N.B.: This should never happen.
return "Unable to resolve PEX __main__ module file: {}".format(main)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about raising AssertionError?

Copy link
Member Author

Choose a reason for hiding this comment

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

As the tests show, those can be turned off. This gives a clean non-zero exit with a non-backtrace mess message and is in line with all other exits here. What are you seeing as the advantage of an assertion over this? Collapsing a comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

That usually when you say "this shouldn't happen", using an assert is the way to ensure that doesn't happen. Sg though

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, an assert doesn't "ensure it doesn't happen" as the -O tests show, I think you must mean it expresses intent better, or at least more concisely. That I don't disagree with, but will leave as Loren established it.

@jsirois jsirois merged commit ce7f8d8 into pex-tool:main May 4, 2022
@jsirois jsirois deleted the issues/1745 branch May 4, 2022 23:57
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.

PEX interpreters should support all underlying Python interpreter options.
2 participants