-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Fix Numpy 2.0 compatibility issues #1706
Conversation
Is this backwards compatible? In other words, will Cantera 3.1 require NumPy >=2.0, or can we support 1.x and 2.x simultaneously? |
This is meant to be backwards compatible, at least in terms of the source -- all the changes for us are pretty minor. I think the conda and PyPI packages will have to be specific to one version or another. I was hoping for your help in figuring some of that out. 😁 |
Yeah, the NumPy headers are different, right? I haven't looked into how that's meant to be handled. I'll see if there's anything out there, I assume NumPy have gotten out ahead of this. |
This may be easier than I thought. According to the NumPy Docs:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1706 +/- ##
=======================================
Coverage 72.82% 72.83%
=======================================
Files 379 379
Lines 53593 53593
Branches 9123 9123
=======================================
+ Hits 39031 39032 +1
+ Misses 11610 11609 -1
Partials 2952 2952 ☔ View full report in Codecov by Sentry. |
146f238
to
0cf35ea
Compare
interfaces/cython/pyproject.toml
Outdated
dependencies = [ | ||
"numpy>=1.19.3", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be coming from setup.cfg
, is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just trying things. I'm not finding the supposed ABI compatibility of the compiled module with older NumPy versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll experiment with this tomorrow too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, from the latest runs, it seems like backwards compatibility is working as expected when building with NumPy 2.0.0. The problem is with the builds for Python 3.8 using NumPy 1.24 and then running with NumPy 1.19. And now I've finally read this page enough times to understand that this is expected not to work and we have to go the other way around in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it. The dependency, at least in the sdist at wheel build time, is that "oldest-supported-numpy" option they mention. But good to know that it needs to depend on the Python versions that NumPy supports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. It sounds like this should be a lot easier going forward -- a build-time dependency on NumPy 2.x will provide backwards compatibility with NumPy 1.x and also forward compatibility with future 2.x releases. If we want to get ahead of things, I suppose we could set the version requirement to numpy<3
.
0a94036
to
df8336e
Compare
One tricky thing I found here is that Pint 0.24 supports Python 3.10 and up, and only Pint >=0.24 supports NumPy 2.0. hgrecco/pint@749d77c for the Python 3.10 stuff and I'm having test failures on Python 3.9 with cibuildwheel because it's installing 0.23.2 of Pint and 2.0 of NumPy. I think the solution is to edit the |
Changes proposed in this pull request
Fix usage of functions that were removed or deprecated in NumPy 2.0.
We can make sure that at least some of the CI tests are using NumPy 2.0 once the official release is made on June 16 (numpy/numpy#24300), and then merge this PR.
If applicable, fill in the issue number this pull request is fixing
Partially resolves #1675. I think the issues with matching versions of NumPy for packaged versions of Cantera will need to be resolved in the various packaging scripts, but we can leave the issue open until those changes are made.
If applicable, provide an example illustrating new features this pull request is introducing
Checklist
scons build
&scons test
) and unit tests address code coverage