1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 from setuptools.command.egg_info import egg_info
9 class EggInfoFromGit(egg_info):
10 """Tag the build with git commit timestamp.
12 If a build tag has already been set (e.g., "egg_info -b", building
13 from source package), leave it alone.
15 def git_timestamp_tag(self):
16 gitinfo = subprocess.check_output(
17 ['git', 'log', '--first-parent', '--max-count=1',
18 '--format=format:%ct', '.']).strip()
19 return time.strftime('.%Y%m%d%H%M%S', time.gmtime(int(gitinfo)))
22 if self.tag_build is None:
23 self.tag_build = self.git_timestamp_tag()
24 return egg_info.tags(self)