Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Automatic version numbers for git-based python projects

Subscribe to updates I use version.py

Statistics on version.py

Number of watchers on Github 96
Number of open issues 1
Main language Python
Open pull requests 0+
Closed pull requests 1+
Last commit over 3 years ago
Repo Created almost 5 years ago
Repo Last Updated 5 months ago
Size 8 KB
Organization / Authorchangaco
Page Updated
Do you use version.py? Leave a review!
View version.py activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating version.py for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

version.py saves you from having to hard-code the version number of your project by getting it from git tags (directly or indirectly).

To use the script, simply copy it into your project and call get_version() in your setup.py file:

from version import get_version


By default the tags that are considered to be version numbers are those that start with a digit. If you use a prefix, for example a v, modify the PREFIX constant in version.py accordingly.

You need to distribute the version.py file in your sdist packages by adding the following line in the MANIFEST.in file:

include version.py

For the script to work within git archives (for example those automatically generated by GitHub for each tag) you need to add the following line to the .gitattributes file:

version.py  export-subst

Note: if you don't care about git archives, or you're looking for a solution that works with Mercurial, then you can use setuptools_scm instead.

Compatibility: python 3.x and 2.7

Licence: CC0 Public Domain Dedication

version.py open issues Ask a question     (View All Issues)
  • almost 5 years Add support for Mercurial
version.py list of languages used
Other projects in Python
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark