Skip to content

Commit cb76c3d

Browse files
committed
Extract exact version from a tagged git archive.
Produce exact version with GitHub zip archives from the releases/tags page. No need to upload sdist archives anymore.
1 parent 7ffdaba commit cb76c3d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pyobjcryst/gitarchive.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
commit = $Format:%H$
33
date = $Format:%ai$
44
timestamp = $Format:%at$
5+
refnames = $Format:%D$

setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def gitinfo():
9191

9292

9393
def getversioncfg():
94+
import re
9495
from ConfigParser import RawConfigParser
9596
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
9697
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
@@ -99,6 +100,9 @@ def getversioncfg():
99100
cp0.read(gitarchivecfgfile)
100101
if '$Format:' not in cp0.get('DEFAULT', 'commit'):
101102
g = cp0.defaults()
103+
mx = re.search(r'\btag: v(\d[^,]*)', g.pop('refnames'))
104+
if mx:
105+
g['version'] = mx.group(1)
102106
# then try to obtain version data from git.
103107
gitdir = os.path.join(MYDIR, '.git')
104108
if os.path.exists(gitdir) or 'GIT_DIR' in os.environ:

0 commit comments

Comments
 (0)