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

Support NumPy 2 #977

Merged
merged 12 commits into from
Apr 5, 2024
Merged

Support NumPy 2 #977

merged 12 commits into from
Apr 5, 2024

Conversation

henryiii
Copy link
Member

A new release of iMinuit needs to be made with pybind11 2.12 in order to support numpy 2. All binaries must be rebuilt with pybind11 2.12+ in order to support NumPy 2.

That should happen automatically, but I took the opportunity to update a few things while I was adding a NumPy 2 test. (which I actually forgot to do, will make draft until I add that!)

@henryiii
Copy link
Member Author

henryiii commented Mar 31, 2024

VisibleDeprecationWarning has been removed in NumPy 2. Actually, I think it was always supposed to be numpy.exceptions.VisibleDeprecationWarning, it just used to be leaked into the main namespace in NumPy 1.

Edit: Ahh, no, it's moved now, but it wasn't always there. I'll work on this in a couple of days. I think we have about at least a week before release.

FYI, Python has a visible Deprecation warning. It's called FutureWarning: Base class for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python. (Wording was updated in a PEP a few years ago to clarify it is intended to be a deprecation warning)

Signed-off-by: Henry Schreiner <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
@@ -37,20 +37,14 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [auto, aarch64, universal2]
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
Copy link
Member Author

Choose a reason for hiding this comment

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

MacOS 14 is the new ARM runner. So this builds native wheels on both (the ARM part can now be tested! Except for CPython 3.8, which is wonky)

pyproject.toml Outdated Show resolved Hide resolved
@henryiii henryiii changed the title ci: update wheel build Support NumPy 2 Mar 31, 2024
Signed-off-by: Henry Schreiner <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
@henryiii
Copy link
Member Author

henryiii commented Apr 2, 2024

@henryiii henryiii marked this pull request as ready for review April 2, 2024 10:34
@henryiii henryiii requested a review from HDembinski April 2, 2024 15:15
.github/workflows/test.yml Outdated Show resolved Hide resolved
@henryiii
Copy link
Member Author

henryiii commented Apr 3, 2024

SciPy 1.13 has shipped! One step closer to NumPy 2.0 releasing. pip install iminuit will start breaking in Python 3.9+ once NumPy 2 ships if we don’t make a new release. Boost-histogram and awkward have released new compatible versions.

@HDembinski
Copy link
Member

FYI, Python has a visible Deprecation warning. It's called FutureWarning: Base class for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python. (Wording was updated in a PEP a few years ago to clarify it is intended to be a deprecation warning)

Ok, I shall use that in the future.

@HDembinski
Copy link
Member

Thank you for the extensive patch and the pointers. If feasible, I would prefer to install the right versions of dependencies via environment markers declared in pyproject.toml. This should be possible for the numpy version at least. scipy is an optional dependency, I don't know whether these can be declared with environment markers as well. If it is cannot be done easily, then installing the right scipy version in the CI workflow is ok.

.github/workflows/test.yml Outdated Show resolved Hide resolved
@HDembinski HDembinski merged commit cffa8ff into scikit-hep:develop Apr 5, 2024
9 checks passed
@HDembinski
Copy link
Member

Thank you for the nice patch.

@henryiii henryiii deleted the henryiii/ci/up branch April 5, 2024 15:47
@matthewfeickert
Copy link
Member

matthewfeickert commented May 29, 2024

👋 @HDembinski would it be possible to get a release of some sort (I'm not sure given the development that has happened since release v2.25.2 what SemVer type it should be, that's up to you, but looks like a patch release(?)) to support NumPy 2?

$ docker run --rm -ti python:3.12 /bin/bash
root@f790da29487c:/# python -m venv venv && . venv/bin/activate
(venv) root@f790da29487c:/# python -m venv venv && . venv/bin/activate
(venv) root@f790da29487c:/# python -m pip --quiet install --upgrade pip wheel
(venv) root@f790da29487c:/# python -m pip install --upgrade iminuit
Collecting iminuit
  Downloading iminuit-2.25.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
Collecting numpy>=1.21 (from iminuit)
  Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 926.1 kB/s eta 0:00:00
Downloading iminuit-2.25.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (423 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 423.9/423.9 kB 6.2 MB/s eta 0:00:00
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.0/18.0 MB 42.7 MB/s eta 0:00:00
Installing collected packages: numpy, iminuit
Successfully installed iminuit-2.25.2 numpy-1.26.4
(venv) root@f790da29487c:/# python -m pip install --upgrade --pre numpy
Requirement already satisfied: numpy in /venv/lib/python3.12/site-packages (1.26.4)
Collecting numpy
  Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 937.6 kB/s eta 0:00:00
Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.0/19.0 MB 52.2 MB/s eta 0:00:00
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.26.4
    Uninstalling numpy-1.26.4:
      Successfully uninstalled numpy-1.26.4
Successfully installed numpy-2.0.0rc2
(venv) root@f790da29487c:/# python
Python 3.12.3 (main, Apr 24 2024, 11:17:35) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iminuit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.12/site-packages/iminuit/__init__.py", line 24, in <module>
    from iminuit.minuit import Minuit
  File "/venv/lib/python3.12/site-packages/iminuit/minuit.py", line 6, in <module>
    from iminuit import util as mutil
  File "/venv/lib/python3.12/site-packages/iminuit/util.py", line 11, in <module>
    from iminuit import _repr_html, _repr_text, _deprecated
  File "/venv/lib/python3.12/site-packages/iminuit/_deprecated.py", line 2, in <module>
    from numpy import VisibleDeprecationWarning
ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/venv/lib/python3.12/site-packages/numpy/__init__.py)

I've started to see this in some environments where other dependencies are testing against the release candidates of NumPy, and it would be great if iminuit could have a release that supports them, as these changes are already in the repository.

@henryiii
Copy link
Member Author

NumPy 2 will be released mid June. June 16 IIRC. I would highly recommend releasing an iminuit release supporting it before then!

@HDembinski
Copy link
Member

@henryiii @matthewfeickert Release is in progress.

@henryiii
Copy link
Member Author

henryiii commented Jun 3, 2024

Fantastic, thanks! I think this means all our key libraries are now ready for NumPy 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants