Skip to content

Commit e0fee5c

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

4 files changed

Lines changed: 24 additions & 43 deletions

File tree

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
os: ubuntu-22.04
4848
arch: "gcc-11"
4949
language: "CXX"
50-
sympy: "1.11"
50+
sympy: "1.12"
5151

5252
- name: pytest-ubuntu-py312-gcc12-cxxomp
5353
python-version: '3.12'
@@ -61,7 +61,7 @@ jobs:
6161
os: ubuntu-24.04
6262
arch: "gcc-14"
6363
language: "openmp"
64-
sympy: "1.9"
64+
sympy: "1.14"
6565

6666
- name: pytest-ubuntu-py310-gcc10-noomp
6767
python-version: '3.10'
@@ -82,28 +82,28 @@ jobs:
8282
os: ubuntu-22.04
8383
arch: "custom"
8484
language: "openmp"
85-
sympy: "1.10"
85+
sympy: "1.14"
8686

8787
- name: pytest-osx-py312-clang-omp
8888
python-version: '3.12'
8989
os: macos-latest
9090
arch: "clang"
9191
language: "openmp"
92-
sympy: "1.13"
92+
sympy: "1.12"
9393

9494
- name: pytest-docker-py39-gcc-omp
9595
python-version: '3.9'
9696
os: ubuntu-latest
9797
arch: "gcc"
9898
language: "openmp"
99-
sympy: "1.12"
99+
sympy: "1.13"
100100

101101
- name: pytest-docker-py39-icx-omp
102102
python-version: '3.9'
103103
os: ubuntu-latest
104104
arch: "icx"
105105
language: "openmp"
106-
sympy: "1.12"
106+
sympy: "1.14"
107107

108108
- set: base
109109
test-set: 'not adjoint'
@@ -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()]))"

devito/types/caching.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ def clear(cls, force=True):
168168

169169
# Wipe out the hidden module-private SymPy caches
170170
sympy.polys.rootoftools.ComplexRootOf.clear_cache()
171-
sympy.polys.rings._ring_cache.clear()
171+
try:
172+
sympy.polys.rings._ring_cache.clear()
173+
except AttributeError:
174+
# SymPy 1.14 and later
175+
pass
172176
sympy.polys.fields._field_cache.clear()
173177
sympy.polys.domains.modularinteger._modular_integer_cache.clear()
174178

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pip>=9.0.1
2-
numpy>1.16,<2.3
3-
sympy>=1.9,<1.14
2+
numpy>=2,<2.3
3+
sympy>=1.12.1,<1.15
44
psutil>=5.1.0,<8.0
55
py-cpuinfo<10
66
cgen>=2020.1,<2021

setup.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
import versioneer
2-
from packaging.version import Version
31
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-
142
from setuptools import setup, find_packages
3+
import versioneer
154

165

176
def min_max(pkgs, pkg_name):
@@ -23,30 +12,8 @@ def min_max(pkgs, pkg_name):
2312
return vmin, vmax
2413

2514

26-
def numpy_compat(required):
27-
new_reqs = [r for r in required if "numpy" not in r and "sympy" not in r]
28-
sympy_lb, sympy_ub = min_max(required, "sympy")
29-
numpy_lb, numpy_ub = min_max(required, "numpy")
30-
31-
# Due to api changes in numpy 2.0, it requires sympy 1.12.1 at the minimum
32-
# Check if sympy is installed and enforce numpy version accordingly.
33-
# 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}"])
43-
44-
return new_reqs
45-
46-
4715
with open('requirements.txt') as f:
4816
required = f.read().splitlines()
49-
required = numpy_compat(required)
5017

5118
with open('requirements-optional.txt') as f:
5219
optionals = f.read().splitlines()

0 commit comments

Comments
 (0)