Closed ocehugo closed 6 years ago
FYI, we were discussing this for Python projects in general yesterday and since the Jenkins server is responsible for setting versions, we have adopted the following simple method of determining the version when packaging:
https://github.com/aodn/python-aodncore/blob/master/setup.py#L41 https://github.com/aodn/python-aodncore/blob/master/aodncore/version.py#L5
This pattern was suggested on the official packaging guide (option 3), and suits our use case quite well without an additional dependency:
https://packaging.python.org/guides/single-sourcing-package-version/
I just found versionner worth the mention and also the dependency: It can pick up git information (like tags/etc) and leave a trail behind when you are doing work (say installing code not committed or not tagged).
It's a set and forget solution...
I haven't looked into it much, and it may well be worth investigating as a general solution, but it does need to a) fit in with our build processes (i.e. the way Jenkins builds and versions our packages) and b) ideally be consistent among all of our packaged Python projects.
They use jenkins and versioneer: https://github.com/graphistry/pygraphistry
I've had a look and it should integrate quite nicely with Jenkins.
Current Jenkins has to do crap like this when setting the version in addition to pushing a tag. Versioneer would let us remove this script and just push the tag:
#!/bin/bash
set -ex
sed -i "s/__version__\ = '.*'/__version__ \= '${VERSION}'/g" aodncore/version.py
git commit -m "Jenkins version bump (${VERSION})" aodncore/version.py
Maybe we could trial it here and if it works well, look at making it standard for other packages if it works well.
I took the liberty of creating this example PR of versioneer enabled package for discussion ;)
merged
I used, and I liked it.