Skip to content
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

MAINT: fix up use of NPY_NO_DEPRECATED_API usage in f2py #21786

Merged
merged 1 commit into from Jun 17, 2022

Conversation

rgommers
Copy link
Member

This was giving a lot of warnings like:

numpy/f2py/src/fortranobject.h:9: warning: "NPY_NO_DEPRECATED_API" redefined

when building SciPy. In general, this is generated code which is included in the build of other projects which may have already set this macro - so only set it if it is not yet set.

The other change is to set it to the current numpy version, like is done everywhere else in numpy, rather than to a fixed 1.7 version. This will ensure that if new deprecations happen, f2py gets updated for them.

This came in with gh-19388 recently (not present in the 1.23.x branch).

This was giving a lot of warnings like:

    numpy/f2py/src/fortranobject.h:9: warning: "NPY_NO_DEPRECATED_API" redefined

when building SciPy. In general, this is generated code which is
included in the build of other projects which may have already set this
macro - so only set it if it is not yet set.

The other change is to set it to the current numpy version, like is done
everywhere else in numpy, rather than to a fixed 1.7 version.
This will ensure that if new deprecations happen, f2py gets updated for
them.
Copy link
Member

@mattip mattip left a comment

Choose a reason for hiding this comment

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

Makes sense. Would an f2py maintainer take a look?

@charris
Copy link
Member

charris commented Jun 17, 2022

I did something like this years ago, but there was a problem where, IIRC, f2py was switching data pointers in an array and that wasn't possible with the new interface functions. Maybe that has been fixed?

@rgommers
Copy link
Member Author

f2py was switching data pointers in an array and that wasn't possible with the new interface functions. Maybe that has been fixed?

That must have been fixed, because things work in main without the deprecated (pre 1.7) APIs.

@charris
Copy link
Member

charris commented Jun 17, 2022

That must have been fixed

Or maybe it this change doesn't affect all the generated C code? In any case, this seems to work.

@rgommers
Copy link
Member Author

@charris the description of gh-19388 says that all deprecated API usage has been removed, so it does work and affect the generated C code. It was fixed properly; this PR is just a minor tweak to avoid build warnings.

@charris
Copy link
Member

charris commented Jun 17, 2022

the description of gh-19388 says that all deprecated API usage has been removed

Ah, thanks for the link. I hadn't noticed that the API usage was fixed. That removes a small task that has been in the back of my mind for many years. Good riddance :)

@charris charris merged commit 1a424bc into numpy:main Jun 17, 2022
@charris
Copy link
Member

charris commented Jun 17, 2022

Thanks Ralf.

@rgommers rgommers deleted the fix-f2py-deprecation-macro branch June 17, 2022 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants