versionbump (GitHub) is a Python library and utility for bumping version number of semantic versioning (SemVer).

You tells it what the current version is, then it will search for that in a list of files to bump the number:

$ versionbump -c 1.0.0 minor setup.py
1.1.0

You could bump major, minor, and patch. If you don’t give at least one file, it simply echoes out the bumped version, for example:

$ versionbump -c 1.1.0 major
2.0.0

If it can’t find the current version number in files to bump, then it will raise an error, so the user can investigate:

$ versionbump -c 3.4.5 patch setup.py
[snip]
ValueError: Version not in file.

You can also use it as library for programmatic interface via versionbump.VersionBump and versionbump.FileBump.

For examples, from its README:

from versionbump import VersionBump
vb = VersionBump('2.0.1')
vb.bump()              ## default value: 'patch'
print vb.get()         ## 2.0.2
print vb.get('patch')  ## 2

from versionbump import FileBump
fo = open('version.txt', 'r+')
fb = FileBump(fo, '2.0.1')
vb.bump()              ## default value: 'patch', writes to file
print vb.get()         ## 2.0.2
print vb.get('patch')  ## 2

versionbump is written by Fabian Kochem under the MIT License, currently version 1.0.0 (2014-04-05). There is also an alternative bumpversion by Filip Noetzel, which is more configurable and can work with VCS, doing tasks like committing and creating tag for you.