I would like to define a __version__ variable in my module which should be automatically updated on git commit similarly to what SVN keywords do. Is there a way
Another possibility other than Versioneer is setuptools_scm.
I have successfully implemented something very similar to the OP by adding the following to setup.py (or by modifying it accordingly):
from setuptools import setup
setup(
...,
use_scm_version=True,
setup_requires=['setuptools_scm'],
...,
)
and, in order to have __version__ updated automatically, added this to __init__.py of my package:
from pkg_resources import get_distribution, DistributionNotFound
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass