Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions source/single_source_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Single-sourcing the Project Version
===================================

:Page Status: Complete
:Last Reviewed: 2015-09-08
:Last Reviewed: 2015-12-03


There are a few techniques to store the version in your project code without duplicating the value stored in
``setup.py``:
There are many techniques to maintain a single source of truth for the version
number of your project:

#. Read the file in ``setup.py`` and parse the version with a regex. Example (
from `pip setup.py <https://github.com/pypa/pip/blob/1.5.6/setup.py#L33>`_)::
Expand Down Expand Up @@ -115,3 +115,8 @@ There are a few techniques to store the version in your project code without dup
``sample/__init__.py`` imports packages from ``install_requires``
dependencies, which will very likely not be installed yet when ``setup.py``
is run.


#. Keep the version number in the tags of a version control system (Git, Mercurial, etc)
instead of in the code, and automatically extract it from there using
`setuptools_scm <https://pypi.python.org/pypi/setuptools_scm>`_.