Merge branch '8650-container-work-unit' into 9318-dashboard-uses-work-units
[arvados.git] / sdk / python / gittaggers.py
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             self.tag_build = self.git_timestamp_tag()
20         return egg_info.tags(self)