From dcb35293cb12d0fbcae5fd3f95026b3dc7713ab0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Javier=20B=C3=A9rtoli?= Date: Fri, 23 Mar 2018 17:02:57 -0300 Subject: [PATCH] Add functions to return the python version for packaging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit refs #13200 Arvados-DCO-1.1-Signed-off-by: Javier Bértoli --- build/run-library.sh | 2 +- sdk/python/arvados_version.py | 20 ++++++++++++++++++++ sdk/python/setup.py | 6 +++--- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 sdk/python/arvados_version.py diff --git a/build/run-library.sh b/build/run-library.sh index 238d6d62cc..77ea465f90 100755 --- a/build/run-library.sh +++ b/build/run-library.sh @@ -277,7 +277,7 @@ test_package_presence() { fi repo_pkg_list=$(curl -o - http://apt.arvados.org/pool/${D}/main/${repo_subdir}/) - echo ${repo_pkg_list} |grep -q ${pkgname} + echo ${repo_pkg_list} |grep -q ${complete_pkgname} if [ $? -eq 0 ]; then echo "Package $complete_pkgname exists, not rebuilding!" curl -o ./${complete_pkgname} http://apt.arvados.org/pool/${D}/main/${repo_subdir}/${complete_pkgname} diff --git a/sdk/python/arvados_version.py b/sdk/python/arvados_version.py new file mode 100644 index 0000000000..bc8ce7347b --- /dev/null +++ b/sdk/python/arvados_version.py @@ -0,0 +1,20 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +import subprocess +import time + +class VersionInfoFromGit(): + """Return arvados version from git + """ + def git_latest_tag(self): + gitinfo = subprocess.check_output( + ['git', 'describe', '--abbrev=0']).strip() + return str(gitinfo) + + def git_timestamp_tag(self): + gitinfo = subprocess.check_output( + ['git', 'log', '--first-parent', '--max-count=1', + '--format=format:%ct', '.']).strip() + return time.strftime('.%Y%m%d%H%M%S', time.gmtime(int(gitinfo))) diff --git a/sdk/python/setup.py b/sdk/python/setup.py index 88bf51e8a8..1adc19f997 100644 --- a/sdk/python/setup.py +++ b/sdk/python/setup.py @@ -15,10 +15,10 @@ README = os.path.join(SETUP_DIR, 'README.rst') tagger = egg_info_cmd.egg_info version = os.environ.get("ARVADOS_BUILDING_VERSION") if not version: - version = "0.1" try: - import gittaggers - tagger = gittaggers.EggInfoFromGit + import arvados_version + vtag = arvados_version.VersionInfoFromGit() + version = vtag.git_latest_tag() + vtag.git_timestamp_tag() except ImportError: pass -- 2.30.2