From a794b59fdb696144ac74d7973373f90de545f21b Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 05:07:24 +0000 Subject: [PATCH 1/6] MAINT: Kill 1.16 cliargs [f2py] [skip ci] --- numpy/f2py/f2py2e.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 1cfe8cddd68c..ae820e1a65c3 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -63,12 +63,6 @@ Options: - --2d-numpy Use numpy.f2py tool with NumPy support. [DEFAULT] - --2d-numeric Use f2py2e tool with Numeric support. - --2d-numarray Use f2py2e tool with Numarray support. - --g3-numpy Use 3rd generation f2py from the separate f2py package. - [NOT AVAILABLE YET] - -h Write signatures of the fortran routines to file and exit. You can then edit and use it instead of . If ==stdout then the @@ -711,23 +705,6 @@ def main(): show_all() return - # Probably outdated options that were not working before 1.16 - if '--g3-numpy' in sys.argv[1:]: - sys.stderr.write("G3 f2py support is not implemented, yet.\\n") - sys.exit(1) - elif '--2e-numeric' in sys.argv[1:]: - sys.argv.remove('--2e-numeric') - elif '--2e-numarray' in sys.argv[1:]: - # Note that this errors becaust the -DNUMARRAY argument is - # not recognized. Just here for back compatibility and the - # error message. - sys.argv.append("-DNUMARRAY") - sys.argv.remove('--2e-numarray') - elif '--2e-numpy' in sys.argv[1:]: - sys.argv.remove('--2e-numpy') - else: - pass - if '-c' in sys.argv[1:]: run_compile() else: From 5945fba12d802a57c2f980261f2ed7d307d6eccf Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 05:19:29 +0000 Subject: [PATCH 2/6] MAINT: [f2py] CLI signals meson flags [skip ci] --- numpy/f2py/f2py2e.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index ae820e1a65c3..747a1ea8ed00 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -123,20 +123,22 @@ -v Print f2py version ID and exit. -build backend options (only effective with -c): +build backend options (only effective with -c) +[NO_MESON] is used to indicate an option not meant to be used +with the meson backend or above Python 3.12: - --fcompiler= Specify Fortran compiler type by vendor - --compiler= Specify C compiler type (as defined by distutils) + --fcompiler= Specify Fortran compiler type by vendor [NO_MESON] + --compiler= Specify distutils C compiler type [NO_MESON] - --help-fcompiler List available Fortran compilers and exit - --f77exec= Specify the path to F77 compiler - --f90exec= Specify the path to F90 compiler + --help-fcompiler List available Fortran compilers and exit [NO_MESON] + --f77exec= Specify the path to F77 compiler [NO_MESON] + --f90exec= Specify the path to F90 compiler [NO_MESON] --f77flags= Specify F77 compiler flags --f90flags= Specify F90 compiler flags - --opt= Specify optimization flags - --arch= Specify architecture specific optimization flags - --noopt Compile without optimization - --noarch Compile without arch-dependent optimization + --opt= Specify optimization flags [NO_MESON] + --arch= Specify architecture specific optimization flags [NO_MESON] + --noopt Compile without optimization [NO_MESON] + --noarch Compile without arch-dependent optimization [NO_MESON] --debug Compile with debugging information --dep @@ -161,7 +163,7 @@ by numpy.distutils/system_info.py. E.g. to link with optimized LAPACK libraries (vecLib on MacOSX, ATLAS elsewhere), use --link-lapack_opt. - See also --help-link switch. + See also --help-link switch. [NO_MESON] -L/path/to/lib/ -l -D -U From 25527f9d51d86af736c98a1f231ae52284bd92a2 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 05:22:08 +0000 Subject: [PATCH 3/6] MAINT: Remove absoft flag [skip ci] Not handled outside distutils anyway --- numpy/f2py/f2py2e.py | 1 - 1 file changed, 1 deletion(-) diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 747a1ea8ed00..679733915231 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -173,7 +173,6 @@ Using the following macros may be required with non-gcc Fortran compilers: -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN - -DUNDERSCORE_G77 When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY interface is printed out at exit (platforms: Linux). From 9947aca0dff58713401376dc6eb9c6d390e2d996 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 06:03:58 +0000 Subject: [PATCH 4/6] DOC: Document the new CLI options [f2py] --- doc/source/f2py/usage.rst | 82 ++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/doc/source/f2py/usage.rst b/doc/source/f2py/usage.rst index a327b072de5a..cd7591c2cd01 100644 --- a/doc/source/f2py/usage.rst +++ b/doc/source/f2py/usage.rst @@ -115,36 +115,31 @@ finally all object and library files are linked to the extension module If ```` does not contain a signature file, then an extension module is constructed by scanning all Fortran source codes for routine signatures, before proceeding to build the extension module. - -Among other options (see below) and options described for previous modes, the -following options can be used in this mode: - -``--help-fcompiler`` - List the available Fortran compilers. -``--help-compiler`` **[depreciated]** - List the available Fortran compilers. -``--fcompiler=`` - Specify a Fortran compiler type by vendor. -``--f77exec=`` - Specify the path to a F77 compiler -``--fcompiler-exec=`` **[depreciated]** - Specify the path to a F77 compiler -``--f90exec=`` - Specify the path to a F90 compiler -``--f90compiler-exec=`` **[depreciated]** - Specify the path to a F90 compiler + +.. warning:: + From Python 3.12 onwards, ``distutils`` has been removed. Use + environment variables to interact with ``meson`` instead. See its + `FAQ `__ for more information. + +Among other options (see below) and options described for previous modes, the following can be used. + +.. note:: + + .. versionchanged:: 1.26.0 + There are now two separate build backends which can be used, ``distutils`` + and ``meson``. Users are **strongly** recommended to switch to ``meson`` + since it is the default above Python ``3.12``. + +Common build flags: + +``--backend `` + Specify the build backend for the compilation process. The supported backends + are ``meson`` and ``distutils``. If not specified, defaults to ``distutils``. + On Python 3.12 or higher, the default is ``meson``. ``--f77flags=`` Specify F77 compiler flags ``--f90flags=`` Specify F90 compiler flags -``--opt=`` - Specify optimization flags -``--arch=`` - Specify architecture specific optimization flags -``--noopt`` - Compile without optimization flags -``--noarch`` - Compile without arch-dependent optimization flags ``--debug`` Compile with debugging information ``-l`` @@ -159,13 +154,41 @@ following options can be used in this mode: ``-L`` Add directory ```` to the list of directories to be searched for ``-l``. -``link-`` + +The ``meson`` specific flags are: + +``--dep `` **meson only** + Specify a meson dependency for the module. This may be passed multiple times + for multiple dependencies. Dependencies are stored in a list for further + processing. Example: ``--dep lapack --dep scalapack`` This will identify + "lapack" and "scalapack" as dependencies and remove them from argv, leaving a + dependencies list containing ["lapack", "scalapack"]. + +The older ``distutils`` flags are: + +``--help-fcompiler`` **no meson** + List the available Fortran compilers. +``--fcompiler=`` **no meson** + Specify a Fortran compiler type by vendor. +``--f77exec=`` **no meson** + Specify the path to a F77 compiler +``--f90exec=`` **no meson** + Specify the path to a F90 compiler +``--opt=`` **no meson** + Specify optimization flags +``--arch=`` **no meson** + Specify architecture specific optimization flags +``--noopt`` **no meson** + Compile without optimization flags +``--noarch`` **no meson** + Compile without arch-dependent optimization flags +``link-`` **no meson** Link the extension module with as defined by ``numpy_distutils/system_info.py``. E.g. to link with optimized LAPACK libraries (vecLib on MacOSX, ATLAS elsewhere), use ``--link-lapack_opt``. See also ``--help-link`` switch. -.. note:: +.. note:: The ``f2py -c`` option must be applied either to an existing ``.pyf`` file (plus the source/object/library files) or one must specify the @@ -215,6 +238,9 @@ Other options .. warning:: Don't use this option if a signature file (``*.pyf``) is used. +.. versionchanged:: 2.0.0 + Will ignore ``-m`` if a ``pyf`` file is provided. + ``--[no-]lower`` Do [not] lower the cases in ````. By default, ``--lower`` is assumed with ``-h`` switch, and ``--no-lower`` without the ``-h`` switch. From 3fd12f3cd0e0de33d0211a7456b20092683cf3b7 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 06:54:22 +0000 Subject: [PATCH 5/6] DOC: Add a note about only: and skip: Close gh-20520 --- doc/source/f2py/usage.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/f2py/usage.rst b/doc/source/f2py/usage.rst index cd7591c2cd01..2bcfb3070bcd 100644 --- a/doc/source/f2py/usage.rst +++ b/doc/source/f2py/usage.rst @@ -31,6 +31,9 @@ To scan Fortran sources and generate a signature file, use either specify which routines should be wrapped (in the ``only: .. :`` part) or which routines F2PY should ignore (in the ``skip: .. :`` part). + F2PY has no concept of a "per-file" ``skip`` or ``only`` list, so if functions + are listed in ``only``, no other functions will be taken from any other files. + If ```` is specified as ``stdout``, then signatures are written to standard output instead of a file. From d36e8a7a77a05b4b6f33af90e7945a4c2bc43ba8 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 12 Nov 2023 16:59:04 +0000 Subject: [PATCH 6/6] DOC: Remove dead comments [f2py] --- numpy/f2py/crackfortran.py | 7 ------- numpy/f2py/f2py2e.py | 1 - 2 files changed, 8 deletions(-) diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index f352bbaa2720..bd28ee69513f 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -2398,8 +2398,6 @@ def _calc_depend_dict(vars): def get_sorted_names(vars): - """ - """ depend_dict = _calc_depend_dict(vars) names = [] for name in list(depend_dict.keys()): @@ -3218,11 +3216,6 @@ def true_intent_list(var): def vars2fortran(block, vars, args, tab='', as_interface=False): - """ - TODO: - public sub - ... - """ setmesstext(block) ret = '' nout = [] diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 679733915231..0b50b98575e3 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -184,7 +184,6 @@ Version: {f2py_version} numpy Version: {numpy_version} -Requires: Python 3.5 or higher. License: NumPy license (see LICENSE.txt in the NumPy source code) Copyright 1999 - 2011 Pearu Peterson all rights reserved. https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"""