Numpy2 support fails when running with 32-bit windows
maffoo opened this issue · 5 comments
In #442 we identified a few issues when running against 32-bit windows. With numpy2 some tests fail because the dtype ELSIZE is incorrectly returning 0, while with numpy1 some examples were segfaulting. @adamreichold suggested that we disable using the library for 32-bit windows to unblock progress. This issue will track either fixing these issues or dropping support for 32-bit windows builds entirely.
I think you meant so say @itamarst made the suggestion, but yes 👍
In our package, we're trying to eke out 32-bit Windows and Linux support in new releases until about February 2025, so I spent a bit of work time trying to help out here.
I tracked the failures down to some issues with the npyffi::types::npy_* type aliases for the static-sized types - things like npy_uint64 were defined in terms of c_ulong and friends, which aren't the same size on Windows 32-bit. Seems like those types just never appeared in FFI wrappers that were needed before now, so the problem didn't appear.
The ELSIZE returning zero was a symptom of the _PyArray_LegacyDescr::flags being defined as npy_uint64, which was typedef'd to c_ulong and so only actually using 32 bits on Windows x86. The extra zeros that were really the high bytes of flags then got interpreted as elsize. Everything else got all shifted too, so a bunch of zeros ended up being interpreted as pointers that needed to be dereferenced.
With #463 in place, I was able to run the full test suite on both archs of Windows locally without further issue.
@davidhewitt: Sorry to be nudging. This merge fix the issue that actually blocks the installation of rust-numpy on Windows 32bit platform, which is needed for the Python 3.13 upgrade (see, for example, this CI workflow for this PR to fix this issue). It would be hugely helpful if you can make a patch release (e.g 0.22.1) with this merge.
P.S. Sorry, just discover you're on the same issue thread. You must have been working on this also 🤦🏻♂️. Thanks for your work.
Agreed; I hope to prep the patch release tonight, will probably then put it live tomorrow.
Release is now live