Does stripy support numpy 2.x on PyPI (pip) ?
I can see that stripy 2.3.3 on conda supports numpy 2.x (conda-forge/stripy-feedstock#21).
Do you know if stripy 2.3.3 on PyPI was also compiled with numpy 2.x ?
Because in GPlates/gplately#305 we're getting a numpy import error that appears to come from stripy. But if we downgrade numpy from 2.x to 1.x it's fine.
Building against numpy 2.x supports both numpy 1.x and 2.x at runtime. So you could force compilation against numpy 2.x with something like the following in your "pyproject.toml":
[build-system]
...
requires = [
# Building against numpy 2.x supports both numpy 1.x and 2.x at *runtime*.
'numpy>=2.0; python_version>="3.9"',
# Python 3.8 is not supported by NumPy 2.x.
# And *building* against NumPy 1.x does NOT support earlier (<1.x) versions at runtime.
# So using the oldest supported NumPy for the Python version and platform.
'oldest-supported-numpy; python_version<"3.9"',
...
]
...this is what I do in pygplates.
Hi @jcannon-gplates, I'm not sure about the build on Pypi - I'm guessing it's compiled with numpy 1.x @brmather & @lmoresi any comment?
I'm happy to kick off a numpy>=2 build via feedstock if you like.
No reason I can see to stay at 1.X, this is for @brmather to give final approval, though.
L
Prof Louis Moresi.
+61 2 6125 5590 or +61 4 0333 1413
@.@.>
@.?anonymous&ep=bwmEmailSignature> Book time to meet with @.?anonymous&ep=bwmEmailSignature>
From: Julian Giordani @.> Sent: Monday, 3 February 2025 4:22 PM To: underworldcode/stripy @.> Cc: Louis Moresi @.>; Mention @.> Subject: Re: [underworldcode/stripy] Does stripy support numpy 2.x on PyPI (pip) ? (Issue #114)
Hi @jcannon-gplateshttps://github.com/jcannon-gplates, I'm not sure about the build on Pypi - I'm guessing it's compiled with numpy 1.x @brmatherhttps://github.com/brmather & @lmoresihttps://github.com/lmoresi any comment?
I'm happy to kick off a numpy>2 build via feedstock if you like.
— Reply to this email directly, view it on GitHubhttps://github.com/underworldcode/stripy/issues/114#issuecomment-2629992407, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADABPI5HYAB33DFZ6WME5OD2N34JPAVCNFSM6AAAAABWJC4YEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMRZHE4TENBQG4. You are receiving this because you were mentioned.Message ID: @.***>
I'm happy to kick off a numpy>2 build via feedstock if you like.
Thanks, but conda is all good - it looks like @brmather has numpy 2 working there. The code snippet above is really just for PyPI.
oh i see. Unfortunately I don't have access to the stripy PyPI. @brmather or @lmoresi please grant.
@julesghub what is your PyPI username?
Just found it. jgiordani Has been added
Thanks - I'll update it later today.
Thanks - I'll update it later today.
Great, thanks!!
I see that "test_linear_interpolation" is failing. Gosh I hope that's not a NumPy 2 issue. No hurry for us, we can always set dependencies=["numpy<2"] in gplately, for our upcoming release (which is still a few weeks away) and revisit it in the future.
By the way, regarding 7cfce70, it's fine to leave dependencies = ["numpy>=1.16.0"] (rather than "numpy>=2.0.0"). That allows user's environment to work with numpy 1.x (or 2.x) at runtime.
Hello all,
Thank you for making progress towards a fix on PyPI. I am curious to know if there is a particular reason why a newer version is not available on PyPI yet. For instance, is the "test_linear_interpolation" unit test failure one of the issues?
Cheers, Matt
Hi,
I'm using stripy for a brain imaging software pipeline (https://www.biorxiv.org/content/10.1101/2022.11.18.517039v1). Stripy was working using numpy<2 but not with recent versions. I'd like to keep using stripy but it would be great if it were compatible with current numpy releases.
It's probably redundant but here's the error I'm getting:
Traceback (most recent call last):
File "
Cheers!
Thomas
I had a look at this and I'm not sure what you are running to get this error. If I make a clean install of stripy with condo / mamba then I can import stripy correctly with numpy at 2.2.x. The pip installation is harder to reproduce because it requires a Fortran compiler, I think, and I usually install this with mamba.
@tfunck, can you elaborate a little here on how to reproduce this error ?
I think conda is fine (due to conda-forge/stripy-feedstock@c5dba63).
However PyPI isn't. At least in my case, and I assume @tfunck's case too.
But yeah, @tfunck can you confirm this ?
The pip installation is harder to reproduce because it requires a Fortran compiler
I'm relying on the pre-compiled wheels. Which I believe were compiled against NumPy 1.x (which is why they don't work with NumPy 2.x).
@julesghub made the necessary changes to support NumPy 2.x for PyPI (in 7cfce70). But unfortunately "test_linear_interpolation" is failing. So once that error is sorted out then new 2.3.4 wheels for PyPI will get uploaded (that support both NumPy 1.x and 2.x).
@jcannon-gplates That's exactly right.
I have a docker image that produces this error which was created using (among a couple other instructions): RUN python3 -m venv bbenv && /opt/bbenv/bin/pip3 install stripy numpy
If if use the following line instead, then there's no error: RUN python3 -m venv bbenv && /opt/bbenv/bin/pip3 install stripy numpy<2
It's not a huge deal to use a slightly older version of numpy at the moment, but it might cause problems down the line.
The full error is the following an confirms the numpy version problem.
Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripy
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "<stdin>", line 1, in <module>
File "/opt/bbenv/lib/python3.11/site-packages/stripy/__init__.py", line 38, in <module>
from .spherical import sTriangulation
File "/opt/bbenv/lib/python3.11/site-packages/stripy/spherical.py", line 23, in <module>
from . import _stripack
Traceback (most recent call last):
File "/opt/bbenv/lib/python3.11/site-packages/numpy/core/_multiarray_umath.py", line 44, in __getattr__
raise ImportError(msg)
ImportError:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/bbenv/lib/python3.11/site-packages/stripy/__init__.py", line 38, in <module>
from .spherical import sTriangulation
File "/opt/bbenv/lib/python3.11/site-packages/stripy/spherical.py", line 23, in <module>
from . import _stripack
I see - no wheels for me on the mac / arm64, hence the gfortran comments.
Can we split off the interpolation bug as a new issue, @jcannon-gplates ? I had missed that in the earlier discussion.