I'm trying to build a few packages with an automatic versioning set by setuptools-git-versioning. Unfortunately, even following the documentation and the very few resources online, I can't manage to make this versioning work.
pyproject.toml:
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools-git-versioning"]
build-backend = "setuptools.build_meta"
[tool.setuptools-git-versioning]
enabled = true
...
[project]
version = "1.0"
...
According to documentation, the enabled flag should suffice for setuptools to get the tag-based version and set it as the version of the package, yet when building the package, the version prompted when running python3 -m pip list or conda list corresponds to the hard-coded value of version in the project section of pyproject.toml.
What am I missing/doing wrong?
According to the PyPa documentation when version is defined statically it can't be changed by a tool (i.e. setuptools-git-versioning in this case). The other option is to use dynamic which...
Dynamic metadata is listed via the
dynamicfield (defined later in this specification) and represents metadata that a tool will later provide.
So removing the static version = "1.0" and adding dynamic = ["version"] to the [project] should work.
From the docs of setuptools-scm.
Add the following to your pyproject.toml to infer the version from git (or hg):
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
[project]
name = "example"
# Important: Remove any existing version declaration
# version = "0.0.1"
dynamic = ["version"]
# more missing
[tool.setuptools_scm]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With