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

Implement support for --exclude <req>. #2281

Merged
merged 4 commits into from
Nov 7, 2023
Merged

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Nov 6, 2023

When excluding a requirement from a PEX, any resolved distribution
matching that requirement, as well as any of its transitive dependencies
not also needed by non-excluded requirements, are elided from the PEX.

At runtime these missing dependencies will not trigger boot resolve
errors, but they will cause errors if the modules they would have
provided are attempted to be imported. If the intention is to load the
modules from the runtime environment, then --pex-inherit-path /
PEX_INHERIT_PATH or PEX_EXTRA_SYS_PATH knobs must be used to allow
the PEX to see distributions installed in the runtime environment.
Clearly, you must know what you're doing to use this option and not
encounter runtime errors due to import errors. Be ware!

A forthcoming --provided option, with similar effects on the PEX
contents, will both automatically inherit any needed missing
distributions from the runtime environment and require all missing
distributions are found; failing fast if they are not.

Work towards #2097.

When excluding a requirement from a PEX, any resolved distribution
matching that requirement, as well as any of its transitive dependencies
not also needed by non-excluded requirements, are elided from the PEX.

At runtime these missing dependencies will not trigger boot resolve
errors, but they will cause errors if the modules they would have
provided are attempted to be imported. If the intention is to load the
modules from the runtime environment, then `--pex-inherit-path` /
`PEX_INHERIT_PATH` or `PEX_EXTRA_SYS_PATH` knobs must be used to allow
the PEX to see distributions installed in the runtime environment.
Clearly, you must know what you're doing to use this option and not
encounter runtime errors due to import errors. Be ware!

A forthcoming `--provided` option, with similar effects on the PEX
contents, will both automatically inherit any needed missing
distributions from the runtime environment and require all missing
distributions are found; failing fast if they are not.

Work towards pex-tool#2097.
@jsirois jsirois requested review from kaos, benjyw and huonw November 6, 2023 22:13
@jsirois
Copy link
Member Author

jsirois commented Nov 6, 2023

N.B.: The diffstat is large, but a little more than half is a lock file I check in for an integration test; so this is just under 500 real delta lines.

Copy link
Collaborator

@kaos kaos left a comment

Choose a reason for hiding this comment

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

lgtm. I've only done a cursory pass.

pex/bin/pex.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@huonw huonw left a comment

Choose a reason for hiding this comment

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

Nice! I like it.

Lots of questions because, as usual, I'm not sure I fully understand all the moving parts (but I'm getting closer!).

pex/pex_info.py Show resolved Hide resolved
pex/environment.py Show resolved Hide resolved
pex/dependency_manager.py Outdated Show resolved Hide resolved
tests/test_dependency_manager.py Show resolved Hide resolved
tests/integration/test_excludes.py Show resolved Hide resolved
pex/environment.py Show resolved Hide resolved
pex/environment.py Outdated Show resolved Hide resolved
pex/dependency_manager.py Show resolved Hide resolved
pex/bin/pex.py Show resolved Hide resolved
@jsirois jsirois mentioned this pull request Nov 7, 2023
2 tasks
@jsirois
Copy link
Member Author

jsirois commented Nov 7, 2023

@huonw, thanks for a solid review.

@jsirois jsirois merged commit 32e9116 into pex-tool:main Nov 7, 2023
24 checks passed
@jsirois jsirois deleted the issues/2097 branch November 7, 2023 13:42
@jsirois jsirois mentioned this pull request Aug 9, 2024
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.

3 participants