From 31041f1713f9a22176b3610a9b619db52004ddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 23 Sep 2019 20:35:48 +0200 Subject: [PATCH 1/2] get_version.py: allow specifying version in environment variable While packaging hy for Alpine Linux I noticed that the VERSIONFILE is ignored if hy is build in a git repository. On Alpine the packages are build in the package repository resulting in a wrong hy version. This change allows specifying the version in an environment variable which is preferred over git-describe(1) and the VERSIONFILE. --- get_version.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/get_version.py b/get_version.py index 759336d..9224f59 100644 --- a/get_version.py +++ b/get_version.py @@ -5,16 +5,19 @@ import os, subprocess, runpy os.chdir(os.path.split(os.path.abspath(__file__))[0]) VERSIONFILE = os.path.join("hy", "version.py") -try: - __version__ = (subprocess.check_output - (["git", "describe", "--tags", "--dirty"]) - .decode('ASCII').strip() - .replace('-', '+', 1).replace('-', '.')) - with open(VERSIONFILE, "wt") as o: - o.write("__version__ = {!r}\n".format(__version__)) +if "HY_VERSION" in os.environ: + __version__ = os.environ["HY_VERSION"] +else: + try: + __version__ = (subprocess.check_output + (["git", "describe", "--tags", "--dirty"]) + .decode('ASCII').strip() + .replace('-', '+', 1).replace('-', '.')) + with open(VERSIONFILE, "wt") as o: + o.write("__version__ = {!r}\n".format(__version__)) -except (subprocess.CalledProcessError, OSError): - if os.path.exists(VERSIONFILE): - __version__ = runpy.run_path(VERSIONFILE)['__version__'] - else: - __version__ = "unknown" + except (subprocess.CalledProcessError, OSError): + if os.path.exists(VERSIONFILE): + __version__ = runpy.run_path(VERSIONFILE)['__version__'] + else: + __version__ = "unknown" From f5977555f4db68bf20182156e78cf60a213698ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 23 Sep 2019 21:54:46 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Add=20S=C3=B6ren=20Tempel=20to=20AUTHORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 7e744e0..b987a9b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -92,3 +92,4 @@ * Brandon T. Willard * Andrew R. M. * Tristan de Cacqueray +* Sören Tempel