cool-easter-32542
03/19/2023, 4:49 PMempty_base = "//:empty" # see [oci].empty_image_target
# using pants 2.15+ there's a 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",
)
Doing this right now requires some hacking to read and compare the version, since imports are forbidden:
def pants_at_least(version: str) -> bool:
pants = __import__("pants")
return pants.version.PANTS_SEMVER >= pants.version.Version(version)
Describe the solution you'd like
If the (stringified?) value of PANTS_SEMVER
was exposed to the BUILD files, the first kind of use-cases would be possible - and the second would be possible for someone who cares enough to do it. I don't think this necessarily should be encouraged and thus there's no "easy" comparison, but it's a nice escape hatch for those who find the need or run matrix testing over pants itself and want to early adopt coming features.
Additional context
https://pantsbuild.slack.com/archives/C046T6T9U/p1679234208316439
I'm willing to also do the work required here if we can agree that it should be done (and how ;-))
pantsbuild/pantscool-easter-32542
04/05/2023, 3:28 PM