-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Adding support to have all command line flags respected via environment variables #2475
Comments
Hi @AlexTereshenkov , doesn't Pants's |
Hey Benjy! It would, but only for that particular target. I want the PEX args to be passed on any Pants goal invocation, not just when dealing with that particular target type.https://www.pantsbuild.org/2.22/reference/targets/python_aws_lambda_function I hope this makes sense? |
This seems easy to add, at least globally, in the |
Thankfully @benjyw stepped in here but @AlexTereshenkov this clearly is a problem for Pants to be handling in its own shed. I happen to know both the Python rule side Process dataclass and the rust side struct have slots for both args and env vars. How is it easier to fill one and not the other? Sounds like a Pants problem to me. I'll just point out all the things off-putting in this issue filing:
|
I suspect it won't shed favorable light on the OP, but I will note https://pantsbuild.slack.com/archives/C046T6T9U/p1695281564840179 is not accessible to me. I am no longer a member of either the Pantsbuild GitHub org or the Slack. @AlexTereshenkov if you can provide a linen link or copy paste the whole thread you point to, that would be great. |
@AlexTereshenkov I'm going to close this in favor of #2242 since it adds nothing over that issue. I filed that quite a while ago and still haven't gotten to it; so thast should make it clear I'm unlikely to be getting to it any time soon. If you want to pitch in and do the work in Pex to make it so, great. If you'd rather put the work into Pants to make it handle controlling the tools it launches more flexibly and more generally, probably better - more bang for your buck. |
I'd love to see PEX supporting receiving any command line argument by reading a corresponding environment variable. This means that all (or most) command line options listed under
pex --help
would be having a matching env var. E.g. runningwould be equivalent to running
PEX does have PEX runtime environment variables, but it only covers some of the flags.
The motivation for this is two fold:
It's quite common from what I've seen for cli tools to make it possible to declare environment variables instead of passing the flags, e.g. https://github.com/buchgr/bazel-remote?tab=readme-ov-file#command-line-flags. This can be done for various purposes such as convenience or security (not exposing the values in the terminal). The
pex
invocation can become quite lean with most of the complicated logic stored in Shell scripts or elsewhere.Clients who make calls to Pex do not need to be modified for every new flag that
pex
expose. Pants is of primary concern.As an example, in a recent PR, a user added
pex_build_extra_args
flag option to be able to propagate a PEX command line flag from Pants invocation down the line topex
itself:There was at least one question about this on Pantsbuild Slack.
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 ofpex
. This is because thepex
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).To avoid going the route of raising individual PRs in Pants trying to add support for random PEX flags user may want to have, it would be so much easier to be able to set the environment variables.
I appreciate
pex
isn't part of Pants so its development might not be driven by Pants users needs, but I hope that use case (1) is strong enough for this enhancement to be considered.The text was updated successfully, but these errors were encountered: