-
-
Notifications
You must be signed in to change notification settings - Fork 7
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 conditionally setting arguments to a command #130
Comments
Currently, the `scie-pants` launcher sometimes needs to pass an additional argument to the underlying pants invocation, to be able to support `PANTS_SHA` and its custom wheel location. Effectively turning an invocation like `pants goal --arg` into `pants --pants-repos-find-links=+["..."] goal --arg` when appropriate: https://github.com/pantsbuild/scie-pants/blob/0a204c5ac816ad24d74b55ecf7424397a07b3c2a/package/scie-pants.toml#L57-L60 However, when not using `PANTS_SHA`, the pants command becomes `pants "" goal --arg`, and the spurious empty string results in some commands failing, e.g. `pants "" tailor --check` thinks `--check` is a global argument, and this is ambiguous. To fix this issue, this PR does two things: 1. avoid passing an empty string, via a no-op workaround: always set the `PANTS_SHA_FIND_LINKS` variable (to a no-op like `--python-repos-find-links=-[]`), so that scie-pants never passes an empty variable to the pants command, since that makes commands like `pants tailor --check ::` explode: 2. deprecates `PANTS_SHA`, so that the hack above doesn't feel so bad: we're on the way to removing the need for `PANTS_SHA_FIND_LINKS` entirely, thus sidestepping the limitation and the need for the workaround (2) This could also be fixed via a-scie/jump#130. Fixes #249
@huonw as I noted here: pantsbuild/scie-pants#249 (comment), scie-jump doesn't support dynamic commands, the lift manifest is static save for interpolation. None the less, commands can be selected dynamically by using recursive dispatch. This is what scie-pants already does to handle the debug case. I'd really like to keep scie-jump simple as per the general thrust outlined here: https://github.com/a-scie/jump/blob/main/CONTRIBUTING.md#guiding-principles Does the recursive dynamic dispatch of commands that scie-pants already does suffice for you @huonw? |
Yep, happy to call that sufficient for this. I assume you aware of the combinatorial explosion (if one has 2 args that might need to disappear independently, I think one will need 4 |
Yeah, I'm aware Pants would need to go from 2 to 4 commands the way it's currently doing things. My initial thought was to not do things this way (not have the existing configuration / install handle PEX installs), but to have Pants release an unpacked scie (PEX + manifest) where each release of Pants could have arbitrarily complex bespoke to the version complexity (see: #10). All that said, isn't scie-pants / Pants engaged in hoisting and petards here? IIUC one can say |
I noted what seems to me to be the root bug here: pantsbuild/scie-pants#226 (comment) |
Yeah, in this case, there's an "obvious" no-op value, so that's the fix we went for in pantsbuild/scie-pants#250 |
In pantsbuild/scie-pants#249, we encounter a circumstance where a
command
has anarg
that needs to be conditionally set: a binding computes an env var that is sometimes set to--python-repos-find-links=...
and sometime empty. If the env var is empty, it'd be better for the command to not receive an argument: invokingpants "" ...
causes issues with pants specifically, and in general passing a spurious empty string is likely to cause problems for any program.It'd be handy to be able to (optionally) make an argument conditional, so that these sort of "maybe set an argument" uses cases are easier to handle.
AFAICT, this isn't currently possible with scie-jump: there's a reified argument for every argument in the manifest, and string like
"{scie.bindings.configure:PANTS_SHA_FIND_LINKS}"
just becomes an empty string.jump/jump/src/context.rs
Lines 270 to 274 in 1403e1f
jump/jump/src/context.rs
Lines 576 to 581 in 1403e1f
Suppose there's a manifest like the following, we'd like to be able to annotate the
ARGUMENT
arg to disappear completely in some cases (particularly whenARGUMENT
is empty, but a more general mechanism would be okay too):In shell terms:
Workaround that we'll likely use in pantsbuild/scie-pants#250: instead of setting the env var to nothing, set it to a "no-op" argument, so that we're never passing an empty arg to the executable.
(This may apply to arguments in bindings in addition to commands?)
The text was updated successfully, but these errors were encountered: