diff options
| -rw-r--r-- | doc/release/upcoming_changes/21187.new_feature.rst | 15 | ||||
| -rw-r--r-- | doc/source/f2py/buildtools/index.rst | 6 | ||||
| -rw-r--r-- | doc/source/f2py/buildtools/meson.rst | 6 | ||||
| -rw-r--r-- | doc/source/f2py/code/meson.build | 2 | ||||
| -rw-r--r-- | doc/source/f2py/code/meson_upd.build | 2 | ||||
| -rw-r--r-- | doc/source/f2py/usage.rst | 5 | ||||
| -rwxr-xr-x | numpy/f2py/f2py2e.py | 21 |
7 files changed, 26 insertions, 31 deletions
diff --git a/doc/release/upcoming_changes/21187.new_feature.rst b/doc/release/upcoming_changes/21187.new_feature.rst index 52d798636..904dce25b 100644 --- a/doc/release/upcoming_changes/21187.new_feature.rst +++ b/doc/release/upcoming_changes/21187.new_feature.rst @@ -1,7 +1,8 @@ -optionally deterministic output files for F2PY ----------------------------------------------- -``f2py`` now accepts the ``--empty-gen`` flag for producing all possible output -files, namely: ``modname-f2pywrappers.f``, ``modname-f2pywrappers2.f90`` for F90 -inputs and ``modname-f2pywrappers.f`` for F77 inputs. This allows writing -generic output rules in ``cmake`` or ``meson`` and other build systems. -:ref:`f2py-meson` details usage. +deterministic output files for F2PY +----------------------------------- +For F77 inputs, ``f2py`` will generate ``modname-f2pywrappers.f`` +unconditionally, though these may be empty. For free-form inputs, +``modname-f2pywrappers.f``, ``modname-f2pywrappers2.f90`` will both be generated +unconditionally, and may be empty. This allows writing generic output rules in +``cmake`` or ``meson`` and other build systems. Older behavior can be restored +by passing ``--no-empty-gen`` to ``f2py``. :ref:`f2py-meson` details usage. diff --git a/doc/source/f2py/buildtools/index.rst b/doc/source/f2py/buildtools/index.rst index 5121c3775..08e0763fe 100644 --- a/doc/source/f2py/buildtools/index.rst +++ b/doc/source/f2py/buildtools/index.rst @@ -80,8 +80,10 @@ Signature files .. note:: - To generate every possible input for a given standard (F77 or F90) - ``--empty-gen`` can be passed to ``f2py`` from NumPy version ``1.22.4``. + From NumPy ``1.22.4`` onwards, ``f2py`` will deterministically generate + wrapper files based on the input file Fortran standard (F77 or greater). + ``--no-empty-gen`` can be passed to ``f2py`` to restore the previous + behaviour of only generating wrappers when needed by the input . In theory keeping the above requirements in hand, any build system can be diff --git a/doc/source/f2py/buildtools/meson.rst b/doc/source/f2py/buildtools/meson.rst index 2c5a2395c..59a96ab45 100644 --- a/doc/source/f2py/buildtools/meson.rst +++ b/doc/source/f2py/buildtools/meson.rst @@ -85,8 +85,10 @@ for reasons discussed in :ref:`f2py-bldsys`. .. note:: - To generate every possible input for a given standard (F77 or F90) - ``--empty-gen`` can be passed to ``f2py`` from NumPy version ``1.22.4``. + From NumPy ``1.22.4`` onwards, ``f2py`` will deterministically generate + wrapper files based on the input file Fortran standard (F77 or greater). + ``--no-empty-gen`` can be passed to ``f2py`` to restore the previous + behaviour of only generating wrappers when needed by the input . However, we can augment our workflow in a straightforward to take into account files for which the outputs are known when the build system is set up. diff --git a/doc/source/f2py/code/meson.build b/doc/source/f2py/code/meson.build index 36c841fd3..b84bf52a9 100644 --- a/doc/source/f2py/code/meson.build +++ b/doc/source/f2py/code/meson.build @@ -24,7 +24,7 @@ fibby_source = custom_target('fibbymodule.c', input : ['fib1.f'], # .f so no F90 wrappers output : ['fibbymodule.c', 'fibby-f2pywrappers.f'], command : [ py3, '-m', 'numpy.f2py', '@INPUT@', - '-m', 'fibby', '--lower', '--empty-gen' ] + '-m', 'fibby', '--lower'] ) inc_np = include_directories(incdir_numpy, incdir_f2py) diff --git a/doc/source/f2py/code/meson_upd.build b/doc/source/f2py/code/meson_upd.build index a2b2badea..44d69d182 100644 --- a/doc/source/f2py/code/meson_upd.build +++ b/doc/source/f2py/code/meson_upd.build @@ -24,7 +24,7 @@ fibby_source = custom_target('fibbymodule.c', input : ['fib1.f'], # .f so no F90 wrappers output : ['fibbymodule.c', 'fibby-f2pywrappers.f'], command : [ py3, '-m', 'numpy.f2py', '@INPUT@', - '-m', 'fibby', '--lower', '--empty-gen' ]) + '-m', 'fibby', '--lower']) inc_np = include_directories(incdir_numpy, incdir_f2py) diff --git a/doc/source/f2py/usage.rst b/doc/source/f2py/usage.rst index 7541be34b..d3e9db22a 100644 --- a/doc/source/f2py/usage.rst +++ b/doc/source/f2py/usage.rst @@ -224,8 +224,9 @@ Other options Run quietly. ``--verbose`` Run with extra verbosity. - ``--empty-gen`` - Generate all possible (empty) wrapper files. + ``--no-empty-gen`` + Do not generate wrapper files unless required by the inputs. + This is a backwards compatibility flag to restore pre 1.22.4 behavior. ``-v`` Print the F2PY version and exit. diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 90aea7705..20fdca2c7 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -122,8 +122,7 @@ Options: --quiet Run quietly. --verbose Run with extra verbosity. - --empty-gen Ensure all possible output files are created for a language - standard. + --no-empty-gen Only generate wrapper files when needed. -v Print f2py version ID and exit. @@ -181,7 +180,7 @@ def scaninputline(inputline): files, skipfuncs, onlyfuncs, debug = [], [], [], [] f, f2, f3, f5, f6, f7, f8, f9, f10 = 1, 0, 0, 0, 0, 0, 0, 0, 0 verbose = 1 - emptygen = 0 + emptygen = True dolc = -1 dolatexdoc = 0 dorestdoc = 0 @@ -253,8 +252,8 @@ def scaninputline(inputline): f7 = 1 elif l[:15] in '--include-paths': f7 = 1 - elif l == '--empty-gen': - emptygen = 1 + elif l == '--no-empty-gen': + emptygen = False elif l[0] == '-': errmess('Unknown option %s\n' % repr(l)) sys.exit() @@ -304,9 +303,9 @@ def scaninputline(inputline): 'Signature file "%s" exists!!! Use --overwrite-signature to overwrite.\n' % (signsfile)) sys.exit() + options['emptygen'] = emptygen options['debug'] = debug options['verbose'] = verbose - options['emptygen'] = emptygen if dolc == -1 and not signsfile: options['do-lower'] = 0 else: @@ -325,16 +324,6 @@ def scaninputline(inputline): options['buildpath'] = buildpath options['include_paths'] = include_paths options.setdefault('f2cmap_file', None) - if not emptygen: - import warnings - warnings.warn("\n --empty-gen is false" - " this will default to true" - " in subsequent releases" - " for build uniformity\n" - " see: " - "https://numpy.org/devdocs/f2py/buildtools/index.html" - "\n Pass --empty-gen to silence this warning\n", - FutureWarning, stacklevel=2) return files, options |
