[SciPy-dev] Automated get_version

Pearu Peterson pearu at cens.ioc.ee
Sat Jan 5 06:30:32 CST 2002


I have commited a new function get_version to scipy_distutils that
provides automatic versioning of packages developed within CVS
repositories. Here is the signature of get_version:

def get_version(release_level='alpha', path='.', major=None):
    Return version string calculated from CVS tree or found in
    <path>/__version__.py. Automatically update <path>/__version__.py
    if the version is changed.
    An attempt is made to guarantee that version is increasing in
    time. This function always succeeds. None is returned if no
    version information is available.

    Version string is in the form


    and its items have the following meanings:
      serial - shows cumulative changes in all files in the CVS
      micro  - a number that is equivalent to the number of files
      minor  - indicates the changes in micro value (files are added
               or removed)
      release_level - is alpha, beta, canditate, or final
      major  - indicates changes in release_level.

Here is an example of the process of automatic versioning that is
executed inside scipy_distutils directory:

>>> from misc_util import get_version
>>> get_version ('alpha')
No module named __version__
updating version: None -> 0.1.19-alpha-45
>>> get_version ('alpha')
>>> get_version ('beta')
updating version: 0.1.19-alpha-45 -> 0.1.19-beta-45
>>> get_version ('final')
updating version: 0.1.19-beta-45 -> 0.1.19-final-45
>>> get_version ('final')
>>> get_version ('alpha')
updating version: 0.1.19-final-45 -> 1.1.19-alpha-45
>>> get_version ('alpha')

The function get_version should be used only in setup.py files.
See scipy_distutils/setup.py for example.

Comments are most welcome. 
In particular, opinions about the major=None argument are appreciated. 
It is there for the case if packagers wish to have a manual control over
the major number (then changes in release_level are just ignored), but is
this actually desired? Should I remove major=None argument or leave it


More information about the Scipy-dev mailing list