Where does the version come from?¶
A version number is essentially what zest.releaser cannot do without. A version number can come from four different locations:
setup.pyfile. Two styles are supported:
version = '1.0' def setup( version=version, name='...
def setup( version='1.0', name='...
setup.cfgfile. zest.releaser will look for something like:
[metadata] name = ... version = 1.0
setup.pyis found, zest.releaser looks for a
version.txtfile. It should contain just a version number (a newline at the end is OK).
version.txtwas only meant to support really old and ancient Plone packages, but it turned out to be quite useful for non-Python packages, too. A completely static website, for instance, that you do want to release and that you do want a changelog for.
__version__attribute in a Python file. You need to tell zest.releaser which Python file by adding (or updating) the
setup.cfgfile next to the
setup.py. You need a
[zest.releaser]header and a
[zest.releaser] python-file-with-version = mypackage/__init__.py
Because you need to configure this explicitly, this option takes precedence over any
Where is the version number being set?¶
Of those four locations where the version can come from, only the first one found is also set to the new value again. Zest.releaser assumes that there’s only one location.
According to PEP 396, the version should have one source and all the others should be derived from it.
Using the version number in
Here are opinionated suggestions from the zest.releaser main authors about how to use the version information. For some other ideas, see the zest.releaser issue 37 discussion.
The version in the
setup.pyis the real version.
__version__attribute in your main module. Often this will be an
__init__.py. Set this version attribute with
pkg_resources, which is automatically installed as part of setuptools/distribute. Here’s the code from
import pkg_resources __version__ = pkg_resources.get_distribution("zest.releaser").version
This way you can do:
>>> import zest.releaser >>> zest.releaser.__version__ '3.44'