This is a tool for managing a recorded version number in setuptools-based python projects. The goal is to remove the tedious and error-prone "update the embedded version string" step from your release process. Making a new release should be as easy as recording a new tag in your version-control system, and maybe making new tarballs.
Quick Install
Versioneer provides two installation modes. The "classic" vendored mode installs a copy of versioneer into your repository. The experimental build-time dependency mode is intended to allow you to skip this step and simplify the process of upgrading.
Vendored mode
pip install versioneerto somewhere in your $PATH- A conda-forge recipe is
available, so you can also use
conda install -c conda-forge versioneer
- A conda-forge recipe is
available, so you can also use
- add a
[tool.versioneer]section to yourpyproject.tomlor a[versioneer]section to yoursetup.cfg(see Install)- Note that you will need to add
tomli; python_version < "3.11"to your build-time dependencies if you usepyproject.toml
- Note that you will need to add
- run
versioneer install --vendorin your source tree, commit the results - verify version information with
python setup.py version
Build-time dependency mode
pip install versioneerto somewhere in your $PATH- A conda-forge recipe is
available, so you can also use
conda install -c conda-forge versioneer
- A conda-forge recipe is
available, so you can also use
- add a
[tool.versioneer]section to yourpyproject.tomlor a[versioneer]section to yoursetup.cfg(see Install) - add
versioneer(with[toml]extra, if configuring inpyproject.toml) to therequireskey of thebuild-systemtable inpyproject.toml:[build-system] requires = ["setuptools", "versioneer[toml]"] build-backend = "setuptools.build_meta"
- run
versioneer install --no-vendorin your source tree, commit the results - verify version information with
python setup.py version
Version Identifiers
Source trees come from a variety of places:
- a version-control system checkout (mostly used by developers)
- a nightly tarball, produced by build automation
- a snapshot tarball, produced by a web-based VCS browser, like github's "tarball from tag" feature
- a release tarball, produced by "setup.py sdist", distributed through PyPI
Within each source tree, the version identifier (either a string or a number, this tool is format-agnostic) can come from a variety of places:
- ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows about recent "tags" and an absolute revision-id
- the name of the directory into which the tarball was unpacked
- an expanded VCS keyword (