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

Add support for controlling Pex CLI via env var or arg. #2242

Open
jsirois opened this issue Sep 17, 2023 · 0 comments
Open

Add support for controlling Pex CLI via env var or arg. #2242

jsirois opened this issue Sep 17, 2023 · 0 comments

Comments

@jsirois
Copy link
Member

jsirois commented Sep 17, 2023

Currently the Pex CLI(s) only support command line arg control. The env var control is only formally supported and documented via --help-variables for runtime control over PEX files. Like many options systems, it would be good if the Pex CLIs could be controlled by either env var or command line arg for every command line arg they currently accept. It probably also makes sense to support toml config since toml is now vendored to support PEP-517 / PEP-518. The latter would provide, amongst other things, a nice way to seal in modern defaults for Pex CLI options like --resolver-version pip-2020-resolver and --pip-version ....

AlexTereshenkov added a commit to pantsbuild/pants that referenced this issue Aug 13, 2024
…ss globally (#21202)

A new option `[pex-cli].global_args` has been added to be able to pass
arbitrary arguments to the `pex` tool as part of any Pants goal
invocation. This should make it a lot easier to modify behavior of `pex`
tool without needing to make changes in the Pants codebase.

Not having this ability to pass arbitrary arguments to pex makes it
really hard to start taking advantage of new features that come with
newer versions of pex. For instance, the new `--exclude` flag added
recently would require making lots of changes in the codebase to be able
to pass those extra arguments. This is because the pex invocations in
the Pants codebase are numerous and it's really hard to make sure a
particular argument is respected (by keeping the chain of calls correct
making sure it does reach the final subprocess spawn). And if it's
relevant for multiple goals, this becomes even harder.

We would still need to make changes to pass arguments to individual
targets, see #20737 or
#20939 - this makes sense as
those arguments apply only to those targets. However, some options would
need to apply for any `pex` invocation (e.g. ignoring all 3rd party
dependencies).

I've looked into having environment variables support for all flags that
PEX has (pex-tool/pex#2242) first (so that no
changes are needed in Pants, one would just export a bunch of env vars
as needed), but this is not going to happen any time soon, so doing it
in the Pants codebase instead is the only path forward, I reckon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant