From e514ade2b1917dcbce9c11f094cfd3c97681c293 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 28 Sep 2019 11:22:27 -0700 Subject: [PATCH] Use fatamorgana/VERSION file to single-source version number `import fatamorgana` inside setup.py could break if dependencies weren't satisfied --- MANIFEST.in | 1 + fatamorgana/VERSION | 1 + fatamorgana/__init__.py | 7 ++++++- setup.py | 9 +++++++-- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 fatamorgana/VERSION diff --git a/MANIFEST.in b/MANIFEST.in index c28ab72..3d18ec7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include README.md include LICENSE.md +include fatamorgana/VERSION diff --git a/fatamorgana/VERSION b/fatamorgana/VERSION new file mode 100644 index 0000000..bd73f47 --- /dev/null +++ b/fatamorgana/VERSION @@ -0,0 +1 @@ +0.4 diff --git a/fatamorgana/__init__.py b/fatamorgana/__init__.py index 0e8485b..9079367 100644 --- a/fatamorgana/__init__.py +++ b/fatamorgana/__init__.py @@ -18,6 +18,8 @@ - Python 3.5 or later - numpy (optional, no additional functionality) """ +import pathlib + from .main import OasisLayout, Cell, XName from .basic import NString, AString, Validation, OffsetTable, OffsetEntry, \ EOFError, SignedError, InvalidDataError, InvalidRecordError @@ -25,4 +27,7 @@ from .basic import NString, AString, Validation, OffsetTable, OffsetEntry, \ __author__ = 'Jan Petykiewicz' -version = '0.4' +with open(pathlib.Path(__file__).parent / 'VERSION', 'r') as f: + __version__ = f.read().strip() +version = __version__ + diff --git a/setup.py b/setup.py index a8ee066..9efc3c1 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,15 @@ #!/usr/bin/env python3 from setuptools import setup, find_packages -import fatamorgana with open('README.md', 'r') as f: long_description = f.read() +with open('fatamorgana/VERSION', 'r') as f: + version = f.read().strip() + setup(name='fatamorgana', - version=fatamorgana.version, + version=version, description='OASIS layout format parser and writer', long_description=long_description, long_description_content_type='text/markdown', @@ -51,6 +53,9 @@ setup(name='fatamorgana', 'Topic :: Software Development :: Libraries :: Python Modules', ], packages=find_packages(), + package_data={ + 'fatamorgana': ['VERSION'] + }, install_requires=[ 'typing', ],