8

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 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 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 an I missing/doing wrong ?

HCKRMVT
  • 355
  • 3
  • 10

1 Answers1

10

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 dynamic field (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.

Marmstrong
  • 1,686
  • 7
  • 30
  • 54