1 from setuptools.command.egg_info import egg_info
5 class EggInfoFromGit(egg_info):
6 """Tag the build with git commit timestamp.
8 If a build tag has already been set (e.g., "egg_info -b", building
9 from source package), leave it alone.
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)))
18 if self.tag_build is None:
19 self.tag_build = self.git_timestamp_tag()
20 return egg_info.tags(self)