Skip to content

Commit

Permalink
deps: support numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jun 20, 2024
1 parent 16746b6 commit 6bf1a2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest-core-nompi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ jobs:
if: "!contains(matrix.name, 'docker')"
run: |
pip install ${{ env.PIPFLAGS }} --upgrade pip
pip install ${{ env.PIPFLAGS }} -e .[tests]
pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}}
pip install ${{ env.PIPFLAGS }} -e .[tests]
- name: Check configuration
run: |
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip>=9.0.1
numpy>1.16,<2.0
numpy>1.16,<2.1
sympy>=1.9,<1.13
psutil>=5.1.0,<7.0
py-cpuinfo<10
Expand Down
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
import versioneer

import os
import sys
import pkg_resources
from setuptools import setup, find_packages


def numpy_compat(required):
new_reqs = [r for r in required if "numpy" not in r and "sympy" not in r]
if sys.version_info <= (3, 8):
# Numpy 2.0 requires python > 3.8
new_reqs.extend(["sympy>=1.9,<1.13", "numpy>1.16,<2.0"])
return new_reqs

# Due to api changes in numpy 2.0, it requires sympy 1.12.1 at the minimum
# Check if sympy is installed and enforce numpy version accordingly.
# If sympy isn't installed, endforce sympy>=1.12.1 and numpy>=2.0
try:
sympy_version = pkg_resources.get_distribution("sympy").version
min_ver2 = pkg_resources.parse_version("1.12.1")
if pkg_resources.parse_version(sympy_version) < min_ver2:
new_reqs.append("numpy>1.16,<2.0")
else:
new_reqs.append("numpy>=2.0")
except pkg_resources.DistributionNotFound:
new_reqs.extend(["sympy>=1.12.1", "numpy>=2.0"])

return new_reqs


with open('requirements.txt') as f:
required = f.read().splitlines()
required = numpy_compat(required)

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

0 comments on commit 6bf1a2f

Please sign in to comment.