hundreds-carpet-28072
12/13/2024, 12:04 PMpex_binary
targets that own the same script but supply different BUILD properties similar to:
pex_binary(
name="do-the-thing",
entry_point="file.py:main",
)
pex_binary(
name="do-the-thing-arm64",
entry_point="file.py:main",
platforms=["linux_aarch64-cp-310-cp310"],
# BUILD props ...
)
When running the underlying script directly e.g. pants run file.py
is there a way I can detect the host platform and run the appropriate target? Bear in mind I’m on an older Pants version 2.17.0
so some of the new shiny environments features may not be available.gifted-lunch-20593
12/15/2024, 12:06 AMbroad-processor-92400
12/18/2024, 4:10 AMif ...:
or otherwise compute the `name`s differently
• read environment variables with env("NAME", optional_default_value)
(.pants.bootstrap
can be used to set env vars via a shell script: https://www.pantsbuild.org/prerelease/docs/using-pants/key-concepts/options#pantsbootstrap-file)
That said, the pex_binary
configuration doesn't influence(*) pants run file.py
, that always uses a "run on the current host" default configuration. pants run path/to:do-the-thing
is the only way in which a pex is invoked
(* this behaviour changed in Pants 2.x's lifetime... I'm pretty sure it was before 2.17, but potentially not, so I may be telling fibs)