Skip to content

Commit cd2bea9

Browse files
committed
Added version management a la PyHEADTAIL
1 parent 9f5f7d7 commit cd2bea9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from _version import __version__

_version.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os, subprocess
2+
worktree = os.path.dirname(os.path.abspath(__file__))
3+
gitdir = worktree + '/.git/'
4+
try:
5+
__version__ = subprocess.check_output(
6+
'git --git-dir=' + gitdir + ' --work-tree=' +
7+
worktree + ' describe --long --dirty --abbrev=10 --tags', shell=True)
8+
__version__ = __version__.rstrip() # remove trailing \n
9+
__version__ = __version__[1:] # remove leading v
10+
# remove commit hash to conform to PEP440:
11+
split_ = __version__.split('-')
12+
__version__ = split_[0]
13+
if split_[1] != '0':
14+
__version__ += '.' + split_[1]
15+
except:
16+
__version__ = '(no git available to determine version)'

0 commit comments

Comments
 (0)