From ba2d28329f7fd05b1b40b794d6b4160ba5afb85d Mon Sep 17 00:00:00 2001 From: Vinay Hegde Date: Tue, 17 Sep 2019 12:18:43 -0700 Subject: [PATCH] Single-source the package version - II - The previous `from qmpy import __version__` does not work as the `qmpy/__init__.py` file imports several packages that will not be available to `setup.py` (which is not really a good practice, but it is what we have) --- qmpy/VERSION.txt | 1 + qmpy/__init__.py | 6 +++++- setup.py | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 qmpy/VERSION.txt diff --git a/qmpy/VERSION.txt b/qmpy/VERSION.txt new file mode 100644 index 00000000..26aaba0e --- /dev/null +++ b/qmpy/VERSION.txt @@ -0,0 +1 @@ +1.2.0 diff --git a/qmpy/__init__.py b/qmpy/__init__.py index 115bd5a1..f272a984 100644 --- a/qmpy/__init__.py +++ b/qmpy/__init__.py @@ -18,8 +18,12 @@ import django.core.exceptions as de -__version__ = '1.2.0' + +with open(os.path.join(os.path.dirname(__file__), 'VERSION.txt')) as fr: + __version__ = fr.read().strip() VERSION = __version__ +__short_version__ = __version__.rpartition('.')[0] + INSTALL_PATH = os.path.abspath(os.path.dirname(__file__)) sys.path = [os.path.join(INSTALL_PATH, 'qmpy', 'db')] + sys.path diff --git a/setup.py b/setup.py index 6caee604..072dc1c2 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,12 @@ +import os from setuptools import setup, find_packages -from qmpy import __version__ - +with open(os.path.join(os.path.dirname(__file__), 'qmpy', 'VERSION.txt')) as fr: + version = fr.read().strip() setup( name='qmpy', - version=__version__, + version=version, author='S. Kirklin', author_email='scott.kirklin@gmail.com', license='LICENSE.txt',