Skip to content

Instantly share code, notes, and snippets.

@mchwalisz
Forked from nloadholtes/setup.py
Created August 1, 2017 13:05
Show Gist options
  • Save mchwalisz/0595efa194ee312364fdd967dbdeb4ae to your computer and use it in GitHub Desktop.
Save mchwalisz/0595efa194ee312364fdd967dbdeb4ae to your computer and use it in GitHub Desktop.
An example of using the git hash/tag as a version number
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