Skip to content

Commit aeda57e

Browse files
author
Peter Amstutz
committed
Add missing gittaggers.py to produce timestamped version numbers.
1 parent 5ac4858 commit aeda57e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

gittaggers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from setuptools.command.egg_info import egg_info
2+
import subprocess
3+
import time
4+
5+
class EggInfoFromGit(egg_info):
6+
"""Tag the build with git commit timestamp.
7+
8+
If a build tag has already been set (e.g., "egg_info -b", building
9+
from source package), leave it alone.
10+
"""
11+
def git_timestamp_tag(self):
12+
gitinfo = subprocess.check_output(
13+
['git', 'log', '--first-parent', '--max-count=1',
14+
'--format=format:%ct', '.']).strip()
15+
return time.strftime('.%Y%m%d%H%M%S', time.gmtime(int(gitinfo)))
16+
17+
def tags(self):
18+
if self.tag_build is None:
19+
try:
20+
self.tag_build = self.git_timestamp_tag()
21+
except subprocess.CalledProcessError:
22+
pass
23+
return egg_info.tags(self)

0 commit comments

Comments
 (0)