-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: F2PY build output determinism #21187
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
Conversation
625e313
to
be70a24
Compare
Needs a release note. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to generate both -f2pywrappers.f
and -f2pywrappers.f90
? An alternative seems to be to let users specify whether the code is F77 or F90; either way one needs a single flag when invoking f2py
at the moment. I think that's still fine for determinism - the problem that was causing trouble was more "output file generated depends on details of the code". Or are there cases where f2py
switches modes between F77 and F90 based on contents of a file, rather than file extension?
Other comment: why not make this the default straight away? It's fully backwards-compatible.
The While it isn't a good idea to mix modules and common blocks, since it is allowed by the Fortran standard (but not recommended) we can't really disallow it. TL:DR; For F77 code the
It is backwards-compatible, but might be confusing/annoying for downstream projects if updating causes the sudden generation of empty files. I would like it to be the default eventually though. |
Thanks for the explanation. That's too bad for F90 code. It seems like for F77 though, the
Whenever it does switch the effect is the same. I suggest deciding on the final config, and either switching it now, or never. If it's now, you then don't need the command-line flag. |
Thinking about this a little bit more then I think I'll rework this to just generate That would probably solve this better than having a flag.
The only reason to have a flag is to have the option to revert to older behavior (irrespective of the default we decide on). |
Discussed briefly at an F2PY meeting. The cleanest fix here is to only generate only one EDIT: This is a larger refactor, and so has been moved to an issue (#21224) |
The current behaviour is to generate both wrapper files for F90 sources, and only an F77 wrapper for F77 inputs with
|
It's not clear from the issue why this is a larger refactor, maybe expand the description a bit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, thanks @HaoZeke
Whenever it does switch the effect is the same. I suggest deciding on the final config, and either switching it now, or never. If it's now, you then don't need the command-line flag.
The only reason to have a flag is to have the option to revert to older behavior (irrespective of the default we decide on).
My comment still applies though. I'm not sure the flag is needed at all, but if you (and @pearu, @melissawm) want to have it, then I suggest to just pick a default and stick with it. There's no point switching the default later.
Mostly because of implementation details:
Also, it isn't actually clear this needs to be done in the first place, given that mixing F77 formatted code (which is what COMMON blocks generate) and F90 formatted code (generated by To work around this F2PY could generate free-form wrappers to COMMON blocks when the inputs are F90 but IMO the current wrappers are more readable ( |
Also remove FutureWarning and update documentation Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now, thanks @HaoZeke.
I'll leave this open for @pearu or @melissawm to have a look at as well.
@pearu or @melissawm does this look OK? |
Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com> Co-authored-by: Pearu Peterson <pearu.peterson@gmail.com> Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
Closes #20385 and adds documentation for usage to fix rgommers/scipy#22 (comment).
Essentially:
--no-empty-gen
flag to restore earlier behaviorA few things which are out of scope for this PR:
Might need a release note? (as a new CLI arugment) done
See also #21187 (comment)