diff --git a/setup.py b/setup.py index 9090c98..3f24848 100644 --- a/setup.py +++ b/setup.py @@ -12,15 +12,16 @@ def readfile(*parts): return f.read() -def extract_version(*parts): +def extract_varval(*parts, varname): """Extract value of __version__ variable by parsing python script""" initfile = readfile(*parts) - version_re = re.compile(r"(?m)^__version__\s*=\s*['\"]([^'\"]*)['\"]") - match = version_re.search(initfile) + var_re = re.compile(r"(?m)^__" + varname + r"__\s*=\s*['\"]([^'\"]*)['\"]") + match = var_re.search(initfile) return match.group(1) -VERSION = extract_version('src', 'irbasis3', '__init__.py') +VERSION = extract_varval('src', 'irbasis3', '__init__.py', varname='version') +MIN_XPREC_VERSION = extract_varval('src', 'irbasis3', '__init__.py', varname='min_xprec_version') REPO_URL = "https://github.com/SpM-lab/irbasis3" LONG_DESCRIPTION = readfile('README.md') @@ -57,11 +58,13 @@ def extract_version(*parts): python_requires='>=3', install_requires=[ 'numpy', - 'scipy' + 'scipy', + 'setuptools' ], extras_require={ 'test': ['pytest', 'irbasis', 'xprec'], 'doc': ['sphinx>=2.1', 'myst-parser', 'sphinx_rtd_theme'], + 'xprec': [f'xprec>={MIN_XPREC_VERSION}'], }, package_dir={'': 'src'}, diff --git a/src/irbasis3/__init__.py b/src/irbasis3/__init__.py index 3f05f13..c5baa93 100644 --- a/src/irbasis3/__init__.py +++ b/src/irbasis3/__init__.py @@ -5,6 +5,16 @@ __copyright__ = "Copyright (C) 2020-2021 Markus Wallerberger and others" __license__ = "MIT" __version__ = "3.0-alpha6" +__min_xprec_version__ = "1.1.1" + +try: + import xprec as xprec + from pkg_resources import parse_version + from warnings import warn + if parse_version(xprec.__version__) < parse_version(__min_xprec_version__): + warn(f"xprec is too old! Please use xprec>={__min_xprec_version__}.") +except ImportError: + pass from .kernel import KernelFFlat, KernelBFlat from .sve import compute as compute_sve