brainy-fountain-94451
06/12/2024, 12:12 AM[cli.alias]
agnostic to their PWD?
For example, if my repo has a widgets/doodad
subdir, and in widgets/doodad/BUILD
I have run_shell_command(name="frizzle", command="./scripts/frizzle.sh")
,
and I want to alias this to doodad-frizzle = "run widgets/doodad:frizzle"
…
That works correctly from the repo root dir. But if I cd widgets/doodad; pants doodad-frizzle
it errors, directory widgets/doodad/widgets/doodad does not exist
, because the path is relative.
How can I define the alias so this works the same way no matter what directory I run the command from?
Thank you!brainy-fountain-94451
06/12/2024, 12:18 AM//
might work in some cases…
[cli.alias]
doodad-frizzle = "run //widgets/doodad:frizzle"
seems to be doing the right thing…brainy-fountain-94451
06/12/2024, 12:49 AMrun
alias. What about for a `check`… like
[python.resolves.add]
doodad = "widgets/doodad/pants-resolve.lock"
[cli.alias]
doodad-mypy = "check --mypy-install-from-resolve=doodad --mypy-config=widgets/doodad/mypy.ini widgets/doodad/::"
👀 …brainy-fountain-94451
06/12/2024, 12:53 AM//
syntax in python.resolves.add
seems to error,
native_engine.IntrinsicError: Absolute paths not supported: "//widgets/doodad/BUILD"
and it also doesn’t work for the flag value (--mypy-config
), perhaps reasonably.
Is there another way to make check
aliases PWD-agnostic?
Thanksbrainy-fountain-94451
06/12/2024, 12:55 AMdoodad-mypy = "check --mypy-install-from-resolve=doodad --mypy-config=widgets/doodadcli/mypy.ini //widgets/doodad/::"
Somehow the flag value seems to be resolved from the root, regardless of PWD. Mysterious!curved-television-6568
06/12/2024, 6:53 AMcareful-address-89803
06/15/2024, 4:55 AM[python.resolves]
uses the value as a hint for generating the (synthetic) lockfile targets. It uses it as a filepath, which is taken as from the root of the repo.
the //
is used for the root of the repo for _target_ addresses , which is why it works for the target of check
and run
but not outside of the context of a Pants target.
The reason the path from the repo root works for --mypy-config
is because Pants uses a filepath (similar to the resolves) to pull in the file. These filepaths are taken from the root of the repo.
I'm not sure that's helpful. The way I think about it is that Pants will try to reference filepaths in configs from the source roots, and targets can be either relative or absolute