From dd9774fb6d55f62ef830c098bb28c725bcc58cb2 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 23 May 2017 11:28:28 -0700 Subject: [PATCH] Remove the documentation's dependency on Hy itself --- docs/conf.py | 13 +++++++------ get_version.py | 20 ++++++++++++++++++++ setup.py | 21 +++------------------ 3 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 get_version.py diff --git a/docs/conf.py b/docs/conf.py index 8b8d339..bf120a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,12 +11,13 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os -import sys -import time +import os, sys, time sys.path.append(os.path.abspath("..")) -import hy +from get_version import __version__ as hy_version +if hy_version.endswith(".dirty"): + # Read the Docs might dirty its checkout, so ignore this. + hy_version = hy_version[:-len(".dirty")] # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -53,9 +54,9 @@ copyright = u'%s the authors' % time.strftime('%Y') # built documents. # # The short X.Y version. -version = ".".join(hy.__version__.split(".")[:-1]) +version = ".".join(hy_version.split(".")[:-1]) # The full version, including alpha/beta/rc tags. -release = hy.__version__ +release = hy_version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/get_version.py b/get_version.py new file mode 100644 index 0000000..759336d --- /dev/null +++ b/get_version.py @@ -0,0 +1,20 @@ +import os, subprocess, runpy + +# Try to get and update the version. + +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__)) + +except (subprocess.CalledProcessError, OSError): + if os.path.exists(VERSIONFILE): + __version__ = runpy.run_path(VERSIONFILE)['__version__'] + else: + __version__ = "unknown" diff --git a/setup.py b/setup.py index a7d551b..a5d64a9 100755 --- a/setup.py +++ b/setup.py @@ -3,31 +3,16 @@ # This file is part of Hy, which is free software licensed under the Expat # license. See the LICENSE. -import os -import re -import sys -import runpy -import subprocess +import sys, os from setuptools import find_packages, setup from setuptools.command.install import install +from get_version import __version__ + os.chdir(os.path.split(os.path.abspath(__file__))[0]) PKG = "hy" -VERSIONFILE = os.path.join(PKG, "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__)) -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