From 6e7e94dd8e79203729f8fd74fa5a1406264fcdeb Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 27 Nov 2016 09:22:31 -0800 Subject: [PATCH 1/2] Tweak __version__ handling in setup.py --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a64cb7b..d3113d2 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,9 @@ import os import re import sys +import runpy import subprocess +from distutils.spawn import find_executable from setuptools import find_packages, setup @@ -30,14 +32,16 @@ os.chdir(os.path.split(os.path.abspath(__file__))[0]) PKG = "hy" VERSIONFILE = os.path.join(PKG, "version.py") -try: +if os.path.exists('.git') and find_executable('git'): __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: +elif os.path.exists(VERSIONFILE): + __version__ = runpy.run_path(VERSIONFILE)['__version__'] +else: __version__ = "unknown" long_description = """Hy is a Python <--> Lisp layer. It helps From fe0fb6fba1af6b4660ec31d1f92086c8411036a3 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 24 Jan 2017 08:31:38 -0800 Subject: [PATCH 2/2] Use `try` instead of `if` in setup.py --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index d3113d2..75a61c3 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,6 @@ import re import sys import runpy import subprocess -from distutils.spawn import find_executable from setuptools import find_packages, setup @@ -32,17 +31,18 @@ os.chdir(os.path.split(os.path.abspath(__file__))[0]) PKG = "hy" VERSIONFILE = os.path.join(PKG, "version.py") -if os.path.exists('.git') and find_executable('git'): +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__)) -elif 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" long_description = """Hy is a Python <--> Lisp layer. It helps make things work nicer, and lets Python and the Hy lisp variant play