gorgeous-winter-99296
03/19/2023, 1:56 PMdef pants_at_least(version: str) -> bool:
pants = __import__("pants")
return pants.version.PANTS_SEMVER >= pants.version.Version(version)
But it's clearly wrong since I have to "force" the import to avoid the guard rails. My end-goal is to enable early adoption/testing of future pants versions in CI. Below is an instance from my open OCI backend where this would be useful in my examples directory:
empty_base = "//:empty" # see [oci].empty_image_target
# using pants 2.15+ there's an built-in for empty bases, but before that we need to declare an empty image to use:
if not pants_at_least("2.15.0.dev0"):
oci_image_empty(
name="empty",
)
empty_base = ":empty"
oci_image_build(
name="with_empty_base",
base=[empty_base],
packages=[":example"],
tag="latest",
)
bitter-ability-32190
03/19/2023, 3:05 PM__import__
existed.
Honestly it kinda works to think about BUILD files as Python the language, but not the runtime or ecosystem, or library IMO.
To your question though, that looks eyebrow raising, can you share the use-case a bit better? A custom plugin that needs to support multiple pants versions I assume?gorgeous-winter-99296
03/19/2023, 3:10 PMexperimental_shell_command
won't have a deprecation period (at least it's not mentioned in 2.16.0 changelog right now afaict). I'm going to guess especially our internal plugins might be a bit fragile and require some finagling... and I'd rather catch/handle/triage early than deal with it when we bump Pants.
This isn't something I plan to expose via my plugin, just a utility. I'm really hoping for a better way - I'd just copy this between all the repos if there's no sanctioned way.PANTS_VERSION=2.16.0dev0
if something is broken/needs upgrading/...)enough-analyst-54434
03/19/2023, 3:17 PMgorgeous-winter-99296
03/19/2023, 3:27 PMenough-analyst-54434
03/19/2023, 3:32 PMfast-nail-55400
03/19/2023, 3:46 PMBut I imagine things likewon't have a deprecation period (at least it's not mentioned in 2.16.0 changelog right now afaict).experimental_shell_command
experimental_shell_command
is still valid in 2.16.x. It is just a deprecated name for shell_command
.gorgeous-winter-99296
03/19/2023, 4:02 PMIn recognition of these improvements, theBut in the details it does clarify that they are being deprecated:andexperimental_shell_command
target types have graduated to no longer have theexperimental_run_shell_command
prefix; useexperimental_
andshell_command
respectively instead.run_shell_command
User API Changes
• Deprecatesin favour ofexperimental_run_shell_command
(#18266)run_shell_command
• Deprecates, replacing withexperimental_shell_command
(#18255)shell_command
bitter-ability-32190
03/19/2023, 7:19 PMfast-nail-55400
03/19/2023, 7:46 PMshell_command
and run_shell_command
respectively before then.gorgeous-winter-99296
03/19/2023, 8:55 PM%(env.FOOBAR)s
are expanded.bitter-ability-32190
03/19/2023, 9:09 PM