aodn / python-aodntools

Repository for templates and code relating to generating standard NetCDF files for the Australia Ocean Data Network
GNU Lesser General Public License v3.0
10 stars 3 forks source link

use versioneer to avoid version handling #22

Closed ocehugo closed 6 years ago

ocehugo commented 6 years ago

I used, and I liked it.

ghost commented 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/

ocehugo commented 6 years ago

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...

ghost commented 6 years ago

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.

ocehugo commented 6 years ago

They use jenkins and versioneer: https://github.com/graphistry/pygraphistry

ghost commented 6 years ago

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.

ghost commented 6 years ago

I took the liberty of creating this example PR of versioneer enabled package for discussion ;)

https://github.com/aodn/aodn-netcdf-tools/pull/23

ocehugo commented 6 years ago

merged