diff --git a/LoopStructural/__init__.py b/LoopStructural/__init__.py index 5ef8264b6..9d464108f 100644 --- a/LoopStructural/__init__.py +++ b/LoopStructural/__init__.py @@ -10,12 +10,12 @@ from logging.config import dictConfig import tempfile from pathlib import Path +from .version import __version__ ch = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s ~ %(name)-12s ~ %(levelname)-10s ~ %(message)s') ch.setFormatter(formatter) ch.setLevel(logging.WARNING) loggers = {} -__version__ = '1.2.2' from .modelling.core.geological_model import GeologicalModel from .utils import log_to_console, log_to_file, getLogger logger = getLogger(__name__) diff --git a/LoopStructural/version.py b/LoopStructural/version.py new file mode 100644 index 000000000..079d34f09 --- /dev/null +++ b/LoopStructural/version.py @@ -0,0 +1 @@ +__version__ = '1.2.2' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..33482f439 --- /dev/null +++ b/setup.cfg @@ -0,0 +1 @@ +[metadata] \ No newline at end of file diff --git a/setup.py b/setup.py index 178f53b6b..d8a8ed399 100644 --- a/setup.py +++ b/setup.py @@ -22,19 +22,13 @@ import numpy import os -import codecs -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.") +package_root = os.path.abspath(os.path.dirname(__file__)) + +version = {} +with open(os.path.join(package_root, "LoopStructural/version.py")) as fp: + exec(fp.read(), version) +version = version["__version__"] setup( name="LoopStructural", @@ -47,7 +41,7 @@ def get_version(rel_path): 'tqdm', # 'pyamg' ], - version=get_version("LoopStructural/__init__.py"), + version=version, packages=find_packages(), ext_modules=cythonize("LoopStructural/interpolators/cython/*.pyx",compiler_directives={"language_level": "3"}), include_dirs=[numpy.get_include()],