Skip to content

ABI: Bump C-ABI to 2 but accept older NumPy if compiled against new one#23916

Merged
mattip merged 5 commits intonumpy:mainfrom
seberg:numpy2-abi
Jun 12, 2023
Merged

ABI: Bump C-ABI to 2 but accept older NumPy if compiled against new one#23916
mattip merged 5 commits intonumpy:mainfrom
seberg:numpy2-abi

Conversation

@seberg
Copy link
Member

@seberg seberg commented Jun 11, 2023

This commits bumps the C-ABI version but allows compiling against older NumPy versions (the previous bump was 13 years ago, I am ignoring it).

The second commit adds __unused_indices__ as a special entry in the API Table generation (I didn't have a better idea), and patches things up to allow holes in the API table.

The last commit adds a couple of those holes by removing functions that were long "disabled".


I was first thinking to remove PyArray_Dump(s), but then realized that should probably include arr.dump(s) and scalar.dump(s). So, lets start with some things that can clearly be empty simply deleted.


In NEP 53, I suggested creating numpy2_compat, that would allow a few additional things. I suspect we should go there, but this will carry us to some of the most important changes easily, so lets start with it.

seberg added 4 commits June 11, 2023 16:34
As of now we can do this, because only _removing_ features we will
remain truly ABI compatible.

NEP 53 outlines a plan to introduce `numpy2_compat` which would allow
more extensive changes, but lets start with this much simpler one.
Since we force users to compile against NumPy 2.0 (if they wish to
support NumPy 2.0+), it is OK to remove things from the API Table.

Allow doing so!

(note that NEP 53 suggests introducing `numpy2_compat`.  This would
allow fully replacing the table, for now, lets see how far we can
get without it though!
@seberg
Copy link
Member Author

seberg commented Jun 11, 2023

Hmmmmm, bumping the ABI version works. But the docs fail to import matplotlib... We could just not bump it for now?

Or even bump it, but let PyArray_GetNDArrayCFeatureVersion return the old one? That way you can compile for the NumPy 2.0, but before we break things badly (or the release comes along), you can run old wheels fine in practice.

This is a hack, but before the actual release process it allows us
to use downstream libs (so long there isn't an actual ABI problem,
but I don't expect one for a while).
* allows (for the moment) downstream modules to mix and match
* and us to import old matplotlib versions in our doc builds...
*/
return (unsigned int)0x01000009;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I put it at the wrong place first:

This is clearly an evil hack. I think I am leaning towards doing it though (with an issue opened of course!). It cannot be in a final release of course, and we could escalate to requiring an env variable soon.

Now, of course there is a good chance this will break down earlier anyway, because we will have enough reason to create that numpy2_compat package (meaning the de-facto ABI compatibility breaks down).

@mattip and @rgommers what do you think? Or is this too piece-meal for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am perfectly fine with such piecemeal tweaks to get to the desired end state. I think we can expect the C ABI to break multiple times during the 2.0 journey, and it's okay to lie a bit or do whatever is pragmatic to keep our CI or nightlies in a functional state during this period.

@mattip mattip merged commit 4af0bab into numpy:main Jun 12, 2023
@mattip
Copy link
Member

mattip commented Jun 12, 2023

Thanks @seberg

@mattip
Copy link
Member

mattip commented Jun 12, 2023

I guess we will find out soon enough if this breaks downstream, so let's do it.

@seberg seberg deleted the numpy2-abi branch June 12, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants