1 from setuptools.command.egg_info import egg_info
6 SETUP_DIR = os.path.dirname(__file__) or '.'
8 def choose_version_from():
9 sdk_ts = subprocess.check_output(
10 ['git', 'log', '--first-parent', '--max-count=1',
11 '--format=format:%ct', os.path.join(SETUP_DIR, "../python")]).strip()
12 cwl_ts = subprocess.check_output(
13 ['git', 'log', '--first-parent', '--max-count=1',
14 '--format=format:%ct', SETUP_DIR]).strip()
15 if int(sdk_ts) > int(cwl_ts):
16 getver = os.path.join(SETUP_DIR, "../python")
21 class EggInfoFromGit(egg_info):
22 """Tag the build with git commit timestamp.
24 If a build tag has already been set (e.g., "egg_info -b", building
25 from source package), leave it alone.
28 def git_timestamp_tag(self):
29 gitinfo = subprocess.check_output(
30 ['git', 'log', '--first-parent', '--max-count=1',
31 '--format=format:%ct', choose_version_from()]).strip()
32 return time.strftime('.%Y%m%d%H%M%S', time.gmtime(int(gitinfo)))
35 if self.tag_build is None:
36 self.tag_build = self.git_timestamp_tag()
37 return egg_info.tags(self)