Skip to content

Commit

Permalink
Merge pull request #6 from SpM-lab/xprec_version_check
Browse files Browse the repository at this point in the history
Add requirement of min xprec version
  • Loading branch information
mwallerb authored Jan 8, 2022
2 parents 9a026ac + d64d778 commit 75c407e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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'},
Expand Down
10 changes: 10 additions & 0 deletions src/irbasis3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75c407e

Please sign in to comment.