I would like to use use a Version Identification compliant with PEP440 but with a way to include the git information:
$ git describe --long
4.1-202-gab0f789
In PEP 440 there is a chapter about dvcs but this is not clear to me how the .devN suffix can hold a non numeric hash like the above: ab0f789
. I need a way to request from one of my scripts on production the 4.1-202-gab0f789
info, so where in setup.py
can I put the project metadata?
That section tells you not to use the hash:
As hashes cannot be ordered reliably such versions are not permitted in the public version field.
Emphasis mine.
They offer .devN
as an alternative. If you are going to release developer versions from a git repository, number them, so .dev0
, .dev1
, etc. You could use tags to track these releases and track them back to specific revisions.
But if you read on, there is a way to tack on the hash as a local version number:
Identifying hash information may also be included in local version labels.
Add a +
, then your hash (prefixed with g
to ensure that an all-digit hash isn't compared as a number):
4.1.dev0+gab0f789
Local version numbers should only be used when creating a local non-indexed packaging or installation of your project however. Don't put a version with +<hash>
on PyPI for example. But if you are producing packages from a continuous-integration server for developers to test, local version numbers are fine.
The setuptools-scm
project uses that exact scheme to include the git hash in versions based on non-tag git commits.
The problem with using the dev
appendix for this is that for instance 4.1dev0+gab0f789
is semantically before the 4.1
release, while 4.1-202-gab0f789
from git describe
actually mean that it is 202 commits behind 4.1
.
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