My goal:
I want to keep coherent versions in my GIT repository, my distribution on pypi repository, and in my source using the __version__
variable.
Details:
I tried to use pbr, which generates the distro version from git tags, so these two versions will be coherent. However, I cannot find out how to keep the __version__
variable coherent with them in my source. (There are several ways to fetch the version from source, but how will it be connected to git/distro?)
Is it possible to generate a version file (to parse form source) or directly modify the __version__
variable?
Finally, I have found the solution in this post.
import pkg_resources # part of setuptools
version = pkg_resources.require("MyProject")[0].version
UPDATE
This post shows another, more robust solution:
from pbr.version import VersionInfo
package_name='MyProject'
info = VersionInfo(package_name)
version = info.version_string()