Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Created August 4, 2015 06:38
Show Gist options
  • Save ecarreras/9f44fedd277bc7d26877 to your computer and use it in GitHub Desktop.
Save ecarreras/9f44fedd277bc7d26877 to your computer and use it in GitHub Desktop.
def get_version():
import os
import subprocess
try:
try:
version = subprocess.check_output([
'git', 'describe', '--tags'
]).strip()
except subprocess.CalledProcessError:
version = __import__('pkg_resources') \
.get_distribution(__name__).version
except Exception, e:
version = 'unknown'
return version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment