12

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?

2 Answers 2

14

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I just incorporated this into my own project. Thanks for your answer
2

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]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.