-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
NumPy 2.0 support #9751
Comments
I gave a try a few weeks ago locally, and everything went fine without requiring any change (GDAL usage of NumPy is rather primitive). We have some CI targets targetting rolling distributons (Alpine Linux, CondaForge), so at some point NumPy 2 will come into CI by default. That said, we might try to hack an existing CI configuration to test against numpy 2.
The GDAL project itself doesn't deliver binary wheels on pypi. GDAL and its complex set of dependencies are not appropriate for pip (cf #4352, #3060), due to potential clashes with other packages that might use the same native dependencies of GDAL. conda-forge builds are our current answer to that need.
we'll do that |
Actually I should have written any change in the library itself. A few adjustments were made in the test suite per #9044 |
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Any Python packaging champion here (perhaps @pl-kevinwurster @rcoup) ? |
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Hopefully this context is helpful If GDAL builds against a Python version and NumPy 2.0 (using the RC1 would suffice), then the packages built would support the oldest NumPy 1.x released for that Python version and NumPy 2.x Ralf shared an example in this comment: conda-forge/conda-forge.github.io#1997 (comment) IOW building against NumPy 2 in all builds would make |
how is that possible? Doesn't numpy 2 changes the Numpy C ABI ? I don't think we can require numpy 2 because current Linux distributions don't ship it yet, and they wouldn't want to depend on a pip package not present on their system. |
Yes this is covered in the "NumPy 2.0-specific advice" section of "For downstream packages authors" doc:
Here are more details on specific NumPy C API changes |
hum according to https://numpy.org/devdocs/dev/depending_on_numpy.html#numpy-2-abi-handling, "When you build wheels for your package using a NumPy 2.x version at build time, those will work with NumPy 1.xx" ... Looks like magic to me, but if they say so... @sebastic I'd be interested by your insights regarding Linux packaging. Have you seen packages that start requiring numpy 2 and how that has been handled ? That said if we bump the build requirement only in pyproject.toml to be numpy>=2.0.0rc1, I don't think that would affect the Debian build as it probably doesn't use that file if using just a make && make install process to build the Python bindings. |
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2
Refs OSGeo#9751 This commit should be reverted once alpine:edge switches to numpy 2 as it disables pyarrow related tests (however the alpine 32 bit config still has it)
Some of the PyTroll related projects started requiring NumPy 2: pykdtree, pyresample, geotiepoints, and trollimage for example. Their Debian packages were patched to drop the version requirement as the numpy package in Debian unstable is still at 1.26.4. The pyproject plugin for the pybuild buildsystem is used to build Python packages using the build module instead of running The gdal Debian package lets CMake build the Python modules, but would use pybuild-plugin-pyproject when the Python module is split out of the GDAL source tree like we already do for fiona and rasterio. |
This is correct, and applies to all distros. Even if they use |
One issue I'm thinking about is that for GDAL 3.9 we still support Python 3.8, but numpy 2.0 only supports >= 3.9. |
You can use Python version specific metadata like this:
That is reliable, and for example |
ok, I've queued in #9761 a PR updating pyproject.toml along the lines of #9751 (comment) . This should hopefully be safe for backport to the 3.9 branch. We'll probably discuss that during the tomorrow GDAL maintainer monthly meeting |
@rouault I'm a bit swamped and can't fully dig into this at the moment, but it seems like your plan is sound. |
Thanks all! 🙏 Am very appreciative of all the engagement around this issue 😊 Wonder if there is a low stakes way of getting Even's work out there for testing. Is there an RC/dev or nightly release process for GDAL? Maybe this would provide a way to test out the changes a bit more and build confidence around them? |
The PR passing shows that at least "distribution-like" building workflows this doesn't seem to break things. For "pip install" workflows, we'll mostly know after the release where it will land. If that goes into the 3.9 branch, we have at least a 3.9.0rc1, and possibly a 3.9.0beta2, but we traditionally don't issue pip packages for the non-final versions (partly because our rcs are really candidate final versions, and so the pip package version has no rc in it, and we can't upload twice a package with the same version) |
Ofc that makes sense. Thanks for the insight into the release process! 🙏 |
Decision from today's GDAL maintainer meetings. We'll include the change in pyproject.toml in the 3.9.0beta2 release to give it a bit more chance to be tested before 3.9.0RC1. |
Feature description
NumPy 2.0 is coming out soon ( numpy/numpy#24300 ). NumPy 2.0.0rc1 packages for conda & wheels came out 3 weeks back ( numpy/numpy#24300 (comment) )
To prepare for NumPy 2.0, it might be worthwhile to start testing against NumPy 2 in CI
NumPy has put out a migration guide. More details are in the release notes
If GDAL make use of NumPy's C API (and produces wheels that use it), having a release of GDAL with wheels built against NumPy 2.0.0rc1 would be helpful to ensure NumPy 1 & 2 compatible wheels (as wheels built against NumPy 1 won't be compatible with NumPy 2). More details in this NumPy 2 ABI doc
Also as NumPy is tracking ecosystem support for NumPy 2.0, it would be helpful to share GDAL current support status in issue (with any plans): numpy/numpy#26191
Additional context
No response
The text was updated successfully, but these errors were encountered: