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

Support injecting args and env vars in a PEX. #1948

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Oct 13, 2022

Pex now supports setting defaults for environment variables and
injecting default arguments for the entry point chosen at PEX build
time. This eliminates the need for projects like
https://github.com/kwlzn/pyuwsgi_pex and makes it easy to package a
PEXed framework app where the main entry point is fixed in the framework
and the hooks are configured to point to user supplied entry points.

The __pex__ import hook introduced in #1845 removed the need for
projects like https://github.com/pantsbuild/lambdex. This change removes
the last known legitimate API use of Pex and paves the way for Pex 3 to
be cut in good conscience with a CLI-only API that does not hinder any
known use cases.

Fixes #987

Pex now supports setting defaults for environment variables and
injecting default arguments for the entry point chosen at PEX build
time. This eliminates the need for projects like
https://github.com/kwlzn/pyuwsgi_pex and makes it easy to package a
PEXed framework app where the main entry point is fixed in the
framework and the hooks are configured to point to user supplied entry
points.

This removes the last known legitimate API use of Pex and paves the way
for Pex 3 to be cut in good conscience with a CLI-only API that does not
hinder any known use cases.

Fixes pex-tool#987
@jsirois jsirois mentioned this pull request Oct 13, 2022
2 tasks
Copy link
Contributor

@hrfuller hrfuller left a comment

Choose a reason for hiding this comment

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

Should there be support for this in sh-booted venvs?

With respect to blocker for a 3.0 pex release being unblocked I think #1907 is related to what you are saying. I still owe you a reproducible issue with the current CLI.

pex/pex.py Show resolved Hide resolved
@jsirois
Copy link
Member Author

jsirois commented Oct 13, 2022

Should there be support for this in sh-booted venvs?

There is. There are only 2 Pex runtime entry points, pex.pex.Pex and the venv pex script and these are both tested. The --sh-boot is just a replacement shebang that still delegates to those 2 entry points, it just speeds things up by pre-selecting the correct interpreter to use in sh code instead of having to have the PEX re-exec itself.

@jsirois
Copy link
Member Author

jsirois commented Oct 13, 2022

Re #1907, great. Get me info and it gets fixed.

Copy link
Contributor

@hrfuller hrfuller left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying!

Copy link
Collaborator

@benjyw benjyw left a comment

Choose a reason for hiding this comment

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

Excellent!

@jsirois jsirois merged commit 72913e3 into pex-tool:main Oct 18, 2022
@jsirois jsirois deleted the issues/987 branch October 18, 2022 22:10
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.

Add support for closing over a fixed environment in PEX files.
3 participants