Pillow
Pillow copied to clipboard
Use setuptools_scm for dynamic versioning
Following on from https://github.com/python-pillow/Pillow/pull/7616.
I had a go setting it up on the weekend, I'm going to pause it for now, but opening a draft to show how it looks. We don't necessarily need to finish this off, and can do it another way instead, if at all.
For non-tagged builds, setuptools_scm would give us a different version, with a .devX number appended based on the number of commits from the last tag. This allows us to upload intra-tag builds to TestPyPI, as [Test]PyPI doesn't allow the same sdist/wheel filenames to be re-uploaded.
@hugovk how about enabling versioning of Git archives for arbitrary commits? This would require adding 2 small files: https://setuptools-scm.readthedocs.io/en/latest/usage/#git-archives.
What are Git archives, and what is their use case?
Does it help with publishing, or is it a nice-to-have extra when using setuptools_scm?
What are Git archives, and what is their use case?
It allows doing stuff like pip install https://github.com/python-pillow/Pillow/archive/refs/heads/main.tar.gz and getting the version generated correctly (instead of something like 0.0.1), when that commit is not tagged. Otherwise, setuptools-scm won't know where to get those tags from.
See also: https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives
Does it help with publishing, or is it a nice-to-have extra when using setuptools_scm?
It's a very nice to have, but is not required for publishing. FWIW it's like adding 5 lines of text to the Git repo — so it's a boilerplate I just have everywhere.
@hugovk so in the case of this PR, pip install https://github.com/hugovk/Pillow/archive/refs/heads/setuptools_scm.tar.gz doesn't work well, but with this, it would (provided that you also have the upstream tags in your fork, of course).
This PR was a demo, I'm not planning on continuing with it, so closing :)
FWIW I did this without setuptools_scm recently or so it appears from the syntax. I was hoping that adding dynamic = ["version"] to the [project] would be enough to enable the feature and that setuptools would default to the project package and search for a set of version files in that package, but no it does not, hence the 🤦 in the commit message.