Skip to content

Commit 46325db

Browse files
committed
tests: test installed sympy version
1 parent 3c0887d commit 46325db

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

.github/workflows/pytest-core-nompi.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ jobs:
166166
python3 -m pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}}
167167
python3 -m pip install ${{ env.PIPFLAGS }} -e .[tests,extras]
168168
169+
- name: Check sympy version
170+
if: "!contains(matrix.name, 'docker')"
171+
run: |
172+
full=$(pip show sympy | awk '/^Version:/ {print $2}')
173+
majmin=${full%.*}
174+
if [[ $majmin != ${{ matrix.sympy }} ]]; then
175+
echo "::error::Sympy version mismatch: expected" ${{ matrix.sympy }} " got " $full
176+
exit 1
177+
fi
178+
169179
- name: Check configuration
170180
run: |
171181
${{ env.RUN_CMD }} python3 -c "from devito import configuration; print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"

setup.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import versioneer
22
from packaging.version import Version
33
import os
4-
5-
try:
6-
import importlib.metadata as metadata
7-
get_version = lambda x: metadata.version(x)
8-
PkgNotFound = metadata.PackageNotFoundError
9-
except ImportError:
10-
import pkg_resources
11-
get_version = lambda x: pkg_resources.get_distribution(x).version
12-
PkgNotFound = pkg_resources.DistributionNotFound
13-
144
from setuptools import setup, find_packages
155

166

@@ -31,15 +21,16 @@ def numpy_compat(required):
3121
# Due to api changes in numpy 2.0, it requires sympy 1.12.1 at the minimum
3222
# Check if sympy is installed and enforce numpy version accordingly.
3323
# If sympy isn't installed, enforce sympy>=1.12.1 and numpy>=2.0
34-
try:
35-
sympy_version = Version(get_version("sympy"))
36-
min_ver2 = Version("1.12.1")
37-
if sympy_version < min_ver2:
38-
new_reqs.extend([f"numpy>{numpy_lb},<2.0", f"sympy=={sympy_version}"])
39-
else:
40-
new_reqs.extend([f"numpy>=2.0,<{numpy_ub}", f"sympy=={sympy_version}"])
41-
except PkgNotFound:
42-
new_reqs.extend([f"sympy>=1.12.1,<{sympy_ub}", f"numpy>=2.0,<{numpy_ub}"])
24+
# try:
25+
import sympy
26+
sympy_version = Version(sympy.__version__)
27+
min_ver2 = Version("1.12.1")
28+
if sympy_version < min_ver2:
29+
new_reqs.extend([f"numpy>{numpy_lb},<2.0", f"sympy=={sympy_version}"])
30+
else:
31+
new_reqs.extend([f"numpy>=2.0,<{numpy_ub}", f"sympy=={sympy_version}"])
32+
# except ImportError:
33+
# new_reqs.extend([f"sympy>=1.12.1,<{sympy_ub}", f"numpy>=2.0,<{numpy_ub}"])
4334

4435
return new_reqs
4536

@@ -143,4 +134,5 @@ def numpy_compat(required):
143134
license='MIT',
144135
packages=find_packages(exclude=exclude),
145136
install_requires=reqs,
137+
setup_requires=["sympy"],
146138
extras_require=extras_require)

0 commit comments

Comments
 (0)