From 073c5a23eb8505f68c5d70b92e8a0098d03158d8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 30 Jun 2020 10:51:34 -0700 Subject: Add logic to pull version string from SCons/__init__.py to single source that --- setup.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d6b7783..8ea0246 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,26 @@ +#!python3 + import fnmatch from setuptools import setup from setuptools.command.build_py import build_py as build_py_orig +import codecs +import os.path + +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, rel_path), 'r') as fp: + return fp.read() + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + else: + raise RuntimeError("Unable to find version string.") + + exclude = ['*Tests'] @@ -21,5 +40,6 @@ class build_py(build_py_orig): setup( cmdclass={ 'build_py': build_py, - } + }, + version=get_version('SCons/__init__.py'), ) \ No newline at end of file -- cgit v0.12