Created
July 15, 2017 20:25
-
-
Save nloadholtes/07a1716a89b53119021592a1d2b56db8 to your computer and use it in GitHub Desktop.
An example of using the git hash/tag as a version number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup, find_packages | |
import subprocess | |
def _get_version_hash(): | |
"""Talk to git and find out the tag/hash of our latest commit""" | |
try: | |
p = subprocess.Popen(["git", "describe", | |
"--tags", "--dirty", "--always"], | |
stdout=subprocess.PIPE) | |
except EnvironmentError: | |
print("Couldn't run git to get a version number for setup.py") | |
return | |
ver = p.communicate()[0] | |
return ver.strip() | |
setup( | |
name='private-python-utils', | |
version=_get_version_hash(), | |
description='Our internal python utils library' | |
# And all of the other fields | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment