8000 API: Default to hidden visibility for API tables by seberg · Pull Request #26103 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: Default to hidden visibility for API tables #26103

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

Merged
merged 7 commits into from
Apr 30, 2024

Conversation

seberg
Copy link
Member
@seberg seberg commented Mar 21, 2024

This adds a new NPY_API_SYMBOL_ATTRIBUTE but defaults to using hidden visibility (always the case on windows!).

That actually makes the situation "worse" for eigenpy in some degree, since it forces them to adapt, but it also allows them to decide to just roll with it (by actually also exporting it on windows which).

Since it aligns windows and linux it seems like a good idea? OTOH, who knows how many projects get away with just not caring about windows...

I tried to reorganize the docs a bit on how to import the array API...


Should be ready, but for discussion: we have to make a decision that this is better and ideally improves the eigenpy situation (if just be clarifying it). EDIT: See gh-26098 and gh-26091.

This adds a new ``NPY_API_SYMBOL_ATTRIBUTE`` but defaults to using
hidden visibility (always the case on windows!).

That actually makes the situation "worse" for ``eigenpy`` in some degree,
since it forces them to adapt, but it also allows them to decide to just
roll with it (by actually also exporting it on windows which).

Since it aligns windows and linux it seems like a good idea?  OTOH,
who knows how many projects get away with just not caring about windows...

I tried to reorganize the docs a bit on how to import the array API...
@charris
Copy link
Member
charris commented Mar 22, 2024

This should be backported?

@seberg
Copy link
Member Author
seberg commented Mar 22, 2024

Maybe? It only really matters if we think it helps clarify the situation for 2.0 and I am not certain.
I.e. it forces/nudges users to not share the API table between shared libraries. Something that is shaky on windows and could be an anti-pattern if the shared libraries are not all part of one project.

Maybe @mattip has an opinion on this?

Otherwise, I think this may be nice but if it causes breakage it is probably niche enough that we can get away with it in a 2.1 release.

@charris
Copy link
Member
charris commented Mar 22, 2024

Sounds like it needs more experimentation, so 2.1 is probably the better option.

@rgommers
Copy link
Member

This seems like a good idea to me. It prevents potential problems I think, and having Windows and other OSes behave consistently here has to be better.

Regarding symbol visibility, I'll note that:

@seberg
Copy link
Member Author
seberg commented Mar 23, 2024

Ah nice point, maybe another reason that adding it explicitly may be good to make downstream setups not accidentally rely on somtehing that is brittle (by build setup/system rules).
(I.e. if we create pain now, at least we are likely to safe pain elsewhere because eventually someone will run into it.)

Meson turns on -fvisibility=hidden (inlineshidden for C++)

I guess we don't actually use it? Would be a nice cleanup (not now!) to remove all the NPY_NO_EXPORT and only mark the functions that we do want to export.

@mattip mattip added 54 - Needs decision triage review Issue/PR to be discussed at the next triage meeting labels Apr 3, 2024
@seberg
Copy link
Member Author
seberg commented Apr 3, 2024

We discussed it and landed on trying this for 2.1 (which means that this should be fine but the release notes/migration changes need to be moved around a bit).

@rgommers
Copy link
Member
rgommers commented Apr 3, 2024

I guess we don't actually use it? Would be a nice cleanup (not now!) to remove all the NPY_NO_EXPORT and only mark the functions that we do want to export.

Cleanup would be nice indeed. We do use it, it's automatic. Try this (after you've built with spin):

$ meson introspect build --targets -i > targets.json
# now open targets.json and search for `hidden`

@seberg
Copy link
Member Author
seberg commented Apr 9, 2024

OK, finally moved the notes in the last commit. This should be squash merged to avoid editing the release notes back and forth.

@seberg seberg added triaged Issue/PR that was discussed in a triage meeting and removed triage review Issue/PR to be discussed at the next triage meeting labels Apr 9, 2024
@seberg
Copy link
Member Author
seberg commented Apr 17, 2024

Rebased (hopefully correctly), it would be good to check the docs reorg (the technical change is pretty small).



.. versionchanged::
NumPy 2.0 exports the headers to avoid sharing the table outside of a
Copy link
Member

Choose a reason for hiding this comment

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

Now that this PR is targeting numpy 2.1 it's a bit of a shame that these docs won't be available for the 2.0 release. Maybe consider splitting off into a separate PR if that's not obnoxious or manually backporting after this is merged?

Also now that this is targeting 2.1, I think the versionchanged here is 2.1. The other versionadded above is 2.0.


.. c:macro:: PY_ARRAY_UNIQUE_SYMBOL

.. c:macro:: NPY_API_SYMBOL_ATTRIBUTE

.. versionadded:: 2.0
Copy link
Member

Choose a reason for hiding this comment

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

2.1 here as well

Copy link
Member
@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

The new docs look good! I wish this was available when I was figuring out how the import_array() mechanism is supposed to work in late 2022.

@seberg
Copy link
Member Author
seberg commented Apr 18, 2024

In principle we could backport just the docs or even more (even if it says 2.1, I guess). I guess we could even backport the whole thing, so long we change the default to do nothing.

Or just backport and delete all the new things, shouldn't be hard after all.

@seberg seberg requested a review from ngoldbaum April 30, 2024 06:37
@ngoldbaum
Copy link
Member

Sorry for letting this one drop, let's bring this in.

@ngoldbaum ngoldbaum merged commit 2234793 into numpy:main Apr 30, 2024
@seberg seberg deleted the visibility-hidden-table branch April 30, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
30 - API 54 - Needs decision triaged Issue/PR that was discussed in a triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0