Dynamic versioning at build time

So I’m looking at this page: Single-sourcing the package version - Python Packaging User Guide

Down in the Note, there’s a description of how to make this work with a pyproject.toml. I tried, and it didn’t.

ValueError: invalid pyproject.toml config: `project.version`.
configuration error: `project.version` must be string

Only when scrolling up to get a link to post here do I spot this little goody at the top (I followed a link from elsewhere to get here, so I didn’t end up at the very top originally):

Todo
Update this page for build backends other than setuptools.

Yeah, I’m using build, so not setuptools. Any idea where I find the relevant info (or whether, in fact, this backend supports this at all)? If so, I could maybe offer some updates for the page. But at the moment a bit stumped… will stay with the rather more manual approach we’ve been using to fetch the version, which is code in a (now tiny) setup.py.

The answer depends on the build backend you are using - I don’t think build is itself such a backend, it is just a frontend that calls into a backend.

The build backend is whatever you have in the key build-system -> build-backend.

Sigh. Turns out there was something else conflicting in the pyproject.toml, so put this one down to operator error. I’ll still think about whether there’s a page update to suggest, but it looks like this was just baloney (sorry).

1 Like
Todo
Update this page for build backends other than setuptools.

Yeah, I’m using build, so not setuptools.

Minor point on terminology, because I know this can be super
confusing… build is a pyproject (a.k.a. PEP 517) build
frontend while setuptools is a pyproject build backend.
Usually there will be one of each in the picture, though sometimes
the frontend and backend might be combined.