8000 BUG: f2py does not correctly report the f2py version in the docstrings of compiled extension modules · Issue #16525 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: f2py does not correctly report the f2py version in the docstrings of compiled extension modules #16525

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

Closed
sturlamolden opened this issue Jun 7, 2020 · 3 comments · Fixed by #16594

Comments

@sturlamolden
Copy link
Contributor
sturlamolden commented Jun 7, 2020

f2py tries to report the version of f2py in the docstring of the extension module. However, as the import of __svn_version__ in numpy/numpy/f2py/__version__.py always fails, the f2py version reported in the docstrings always has the value of '2'.

f2py should instead use a versioning mechanism that actually works, or at least include the NumPy version in the resported f2py version. This way it would be possible for projects like SciPy to query the version of f2py used for cmpilation (which might be different from the currently imported numpy) and correct for known bugs, such as the recently fixed issue with callbacks to Python not being threadsafe.

major = 2
try:
from __svn_version__ import version
version_info = (major, version)
version = '%s_%s' % version_info
except (ImportError, ValueError):
version = str(major)

Here is an example showing the problem:

>>> _cobyla.__doc__
"This module '_cobyla' is auto-generated with f2py (version:2).\nFunctions:\n  x,dinfo = minimize(calcfc,m,x,rhobeg,rhoend,dinfo,iprint=1,maxfun=100,calcfc_extra_args=())\n."
@sturlamolden sturlamolden changed the title BUG: f2py does not correctly resport the f2py version used for compilation BUG: f2py does not correctly report the f2py version used for compilation Jun 7, 2020
@sturlamolden sturlamolden changed the title BUG: f2py does not correctly report the f2py version used for compilation BUG: f2py does not correctly report the f2py version in the docstrings of compiled modules Jun 7, 2020
@sturlamolden sturlamolden changed the title BUG: f2py does not correctly report the f2py version in the docstrings of compiled modules BUG: f2py does not correctly report the f2py version in the docstrings of compiled extension modules Jun 7, 2020
@mattip
Copy link
Member
mattip commented Jun 10, 2020

This way it would be possible for projects like SciPy to query the version of f2py used for cmpilation (which might be different from the currently imported numpy) and correct for known bugs

I don't think a comment in a docstring is the proper interface for versioning extensions. We should remove this part of the docstring entirely. If we wish to version the extensions, we should do so in a way that provides a proper interface. For instance we could add a _f2py_version attribute to the extension.

@eric-wieser
Copy link
Member

__f2py_version__ might be a better name, but agreed that a module-level constant is the way to go.

I think putting the version in the module __doc__ would also be reasonable, just in case its useful in Sphinx docs generated from the module.

@sturlamolden
Copy link
Contributor Author

I suggest __f2py_numpy_version__ to avoid confusion as it is the version of NumPy with which f2py is associated. The version of f2py itself is probably unknown after it became a part of NumPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0