Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requirement of min xprec version #6

Merged
merged 1 commit into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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