-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Upcoming breaking changes in Numpy 2.0 #1675
Comments
We would need to rebuild the PyPI packages to add that version restriction. How many things are broken in that workflow is an interesting question.
Those errors are coming from Cython-generated code, so I think we just need to wait for Cython to be updated on this one. What version of Cython are you using? |
Sorry, I'm still getting used to Cython, so I did not realize that the error was coming from that instead of the onedim Cantera file, which explains why I couldn't find it.
Perhaps I should open an issue on Cython instead? |
To add my 2 cents, I don't think that we need to jump on implementing changes based on a beta release yet. At the same time, we have an established workflow for prerelease dependencies in our I would suggest to simply modify the (now no longer needed) CI runner for pre-release Cython to test for NumPy 2.x instead, so we can monitor whether things clear up (breaking NumPy API changes may or may not be breaking for Cantera due to the Cython layer, which at this point should default to 3.0.x). This modification is presumably quite simple - a PR is welcome and a good intro to learn about our GH actions tests. Beyond, NumPy v2.0.0b1 was just released 2 days ago. While I found this statement "The tentative release date for the first release candidate of NumPy 2.0 is around 1 Mar 2024, and the final release 6-8 weeks later," it is not necessarily easy to predict how fast downstream packages are expected/able to move. I consider Cantera as downstream relative to Cython and other packages that themselves depend on NumPy, so we may have to pin to |
My 2 cents as well... 😄 If this dependency cap is added to 3.0 (by creating |
Great to hear that you're volunteering for Jests aside the fact that we pretty much decided to remove the legacy MATLAB interface (#1670) may mean that 3.0 may be around for a while for some users. At the same time I am very hesitant to spend time on back ports. |
Happy to help as much as I can with this. I know the packaging stuff is still pretty arcane. ❤️ |
As a point of reference, conda-forge attempted an automatic upgrade to NumPy 2.0 and as expected it failed. conda-forge/cantera-feedstock#38 |
With conda-forge/cantera-feedstock#38 and #1719 merged, there should be packages published for 3.0.1 on PyPI that back port changes to support NumPy 2.0 and Python 3.12 and 3.13. The last step is to update the Cantera channel conda recipes to build 3.0.1 and pin NumPy. |
Alright, Cantera/conda-recipes#50 is merged which pins NumPy < 2.0 for our conda packages. Since the This work is done, thanks for raising it! |
NumPy 2.0 hasn't been released yet, but the initial release notes from the pre-release mentions some breaking changes that they address in their migration guide. I don't know how the Cantera team wants to handle compatibility going forward, but I thought I would go ahead and make a thread in case it's helpful.
Previous Cantera builds
I installed NumPy 2.0.0b1 and attempted to import Cantera 3.0.0 which yields the following error:
Clearly previous builds of Cantera can only be used with NumPy 1.x and will not work with 2.x releases. I don't know if there is a way to enforce
numpy<2.0.0
as a package requirement on PyPI, or if that can't be done retroactively, but it might need to be added to some documentation somewhere.Future Cantera builds
I attempted to build Cantera from source from the latest commit using NumPy 2.0.0b1 to see what changes would need to be made. The first build error that I get from the breaking changes is below:
The changes to the
PyArray_Descr
struct are covered in this section of the migration guide. It seems thePyDataType_SUBARRAY
accessor function needs to be used. They also provide anpy2_compat.h
file that can be included in the code base that will allow compilation on NumPy 1.x and not affect 2.x builds.I haven't gotten any further yet, but I will edit this if I do.
The text was updated successfully, but these errors were encountered: