Skip to content

Commit 2041a38

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

4 files changed

Lines changed: 30 additions & 93 deletions

File tree

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

Lines changed: 8 additions & 8 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.14"
5151

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

6666
- name: pytest-ubuntu-py310-gcc10-noomp
6767
python-version: '3.10'
6868
os: ubuntu-22.04
6969
arch: "gcc-10"
7070
language: "C"
71-
sympy: "1.12"
71+
sympy: "1.14"
7272

7373
- name: pytest-ubuntu-py312-gcc13-omp
7474
python-version: '3.12'
@@ -82,28 +82,28 @@ jobs:
8282
os: ubuntu-22.04
8383
arch: "custom"
8484
language: "openmp"
85-
sympy: "1.10"
85+
sympy: "1.12"
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.13"
107107

108108
- set: base
109109
test-set: 'not adjoint'
@@ -163,8 +163,8 @@ jobs:
163163
if: "!contains(matrix.name, 'docker')"
164164
run: |
165165
python3 -m pip install ${{ env.PIPFLAGS }} --upgrade pip
166-
python3 -m pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}}
167166
python3 -m pip install ${{ env.PIPFLAGS }} -e .[tests,extras]
167+
python3 -m pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}}
168168
169169
- name: Check configuration
170170
run: |

devito/types/caching.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,13 @@ 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()
172-
sympy.polys.fields._field_cache.clear()
173171
sympy.polys.domains.modularinteger._modular_integer_cache.clear()
172+
try:
173+
sympy.polys.rings._ring_cache.clear()
174+
sympy.polys.fields._field_cache.clear()
175+
except AttributeError:
176+
# SymPy 1.14 and later
177+
pass
174178

175179
# Take a copy of the dictionary so we can safely iterate over it
176180
# even if another thread is making changes

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pip>=9.0.1
2-
numpy>1.16,<2.3
3-
sympy>=1.9,<1.14
2+
numpy>=2,<2.2.6
3+
sympy>=1.12.1,<1.14; python_version < '3.10'
4+
sympy>=1.12.1,<1.15; python_version >= '3.10'
45
psutil>=5.1.0,<8.0
56
py-cpuinfo<10
67
cgen>=2020.1,<2021

setup.py

Lines changed: 13 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,29 @@
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

17-
def min_max(pkgs, pkg_name):
18-
pkg = [p for p in pkgs if pkg_name in p][0]
19-
minsign = '>=' if '>=' in pkg else '>'
20-
maxsign = '<=' if '<=' in pkg else '<'
21-
vmin = pkg.split(minsign)[1].split(',')[0]
22-
vmax = pkg.split(maxsign)[-1]
23-
return vmin, vmax
24-
25-
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-
47-
with open('requirements.txt') as f:
48-
required = f.read().splitlines()
49-
required = numpy_compat(required)
50-
51-
with open('requirements-optional.txt') as f:
52-
optionals = f.read().splitlines()
53-
54-
with open('requirements-testing.txt') as f:
55-
testing = f.read().splitlines()
56-
57-
with open('requirements-mpi.txt') as f:
58-
mpis = f.read().splitlines()
59-
60-
with open('requirements-nvidia.txt') as f:
61-
nvidias = f.read().splitlines()
6+
def load_requirements(filename):
7+
with open(filename) as f:
8+
lines = f.read().splitlines()
9+
return lines
6210

63-
reqs = []
64-
for ir in required:
65-
if ir[0:3] == 'git':
66-
name = ir.split('/')[-1]
67-
reqs += ['%s @ %s@main' % (name, ir)]
68-
else:
69-
reqs += [ir]
7011

71-
extras_require = {}
72-
for mreqs, mode in (zip([optionals, mpis, nvidias, testing],
73-
['extras', 'mpi', 'nvidia', 'tests'])):
74-
opt_reqs = []
75-
for ir in mreqs:
76-
# For conditionals like pytest=2.1; python == 3.6
77-
if ';' in ir:
78-
entries = ir.split(';')
79-
extras_require[entries[1]] = entries[0]
80-
# Git repos, install main
81-
if ir[0:3] == 'git':
82-
name = ir.split('/')[-1]
83-
opt_reqs += ['%s @ %s@main' % (name, ir)]
84-
else:
85-
opt_reqs += [ir]
86-
extras_require[mode] = opt_reqs
12+
reqs = load_requirements('requirements.txt')
13+
extras_require = {
14+
'mpi': load_requirements('requirements-mpi.txt'),
15+
'nvidia': load_requirements('requirements-nvidia.txt'),
16+
'tests': load_requirements('requirements-testing.txt'),
17+
'extras': load_requirements('requirements-optional.txt'),
18+
}
8719

8820
# If interested in benchmarking devito, we need the `examples` too
8921
exclude = ['docs', 'tests']
9022
try:
9123
if not bool(int(os.environ.get('DEVITO_BENCHMARKS', 0))):
9224
exclude += ['examples']
9325
else:
94-
required += testing
26+
reqs += extras_require['tests']
9527
except (TypeError, ValueError):
9628
exclude += ['examples']
9729

0 commit comments

Comments
 (0)