We routinely use poetry-dynamic-versioning
to establish the version of our packages from git. Thanks to modern packaging standards and tooling, I only need to declaratively include
[build-system]
build-backend = "poetry_dynamic_versioning.backend"
requires = ["poetry-core>=1.6.0", "poetry-dynamic-versioning"]
in my pyproject.toml and then any PEP 518-compliant build tool will handle the package versioning correctly, at least at build time.
However, we also don’t want to build a package we already have, so it’s useful to know what the dynamic version is going to be before we do the build. So far as I can tell, that requires essentially installing poetry
, then running poetry self add poetry-dynamic-versioning
, then poetry version --short
. In other words, I’m manually and imperatively adding a bunch of the build tooling myself. I’d rather use what I’ve already declared.
Is there some way I can get any PEP 518-compliant build tool to tell me the version without building the package? Barring that, can I get it to just build the build-time virtualenv and let me execute a command inside it?
(Ideally, this isn’t just about poetry-dynamic-versioning, but would work for any dynamic value generated by something in the build-system
of a PEP 518 build.)