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

deps: support numpy 2.0 #2391

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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, 9):
georgebisbas marked this conversation as resolved.
Show resolved Hide resolved
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enforce"

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
Loading