8000 Merge pull request #25124 from HaoZeke/f2pyCLIcruft · numpy/numpy@5b1317c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b1317c

Browse files
authored
Merge pull request #25124 from HaoZeke/f2pyCLIcruft
DOC: `f2py` CLI documentation enhancements
2 parents 676534c + d36e8a7 commit 5b1317c

File tree

3 files changed

+70
-71
lines changed

3 files changed

+70
-71
lines changed

doc/source/f2py/usage.rst

Lines changed: 57 additions & 28 8000 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ To scan Fortran sources and generate a signature file, use
3131
either specify which routines should be wrapped (in the ``only: .. :`` part)
3232
or which routines F2PY should ignore (in the ``skip: .. :`` part).
3333

34+
F2PY has no concept of a "per-file" ``skip`` or ``only`` list, so if functions
35+
are listed in ``only``, no other functions will be taken from any other files.
36+
3437
If ``<filename.pyf>`` is specified as ``stdout``, then signatures are written to
3538
standard output instead of a file.
3639

@@ -115,36 +118,31 @@ finally all object and library files are linked to the extension module
115118
If ``<fortran files>`` does not contain a signature file, then an extension
116119
module is constructed by scanning all Fortran source codes for routine
117120
signatures, before proceeding to build the extension module.
118-
119-
Among other options (see below) and options described for previous modes, the
120-
following options can be used in this mode:
121-
122-
``--help-fcompiler``
123-
8000 List the available Fortran compilers.
124-
``--help-compiler`` **[depreciated]**
125-
List the available Fortran compilers.
126-
``--fcompiler=<Vendor>``
127-
Specify a Fortran compiler type by vendor.
128-
``--f77exec=<path>``
129-
Specify the path to a F77 compiler
130-
``--fcompiler-exec=<path>`` **[depreciated]**
131-
Specify the path to a F77 compiler
132-
``--f90exec=<path>``
133-
Specify the path to a F90 compiler
134-
``--f90compiler-exec=<path>`` **[depreciated]**
135-
Specify the path to a F90 compiler
121+
122+
.. warning::
123+
From Python 3.12 onwards, ``distutils`` has been removed. Use
124+
environment variables to interact with ``meson`` instead. See its
125+
`FAQ <https://mesonbuild.com/howtox.html>`__ for more information.
126+
127+
Among other options (see below) and options described for previous modes, the following can be used.
128+
129+
.. note::
130+
131+
.. versionchanged:: 1.26.0
132+
There are now two separate build backends which can be used, ``distutils``
133+
and ``meson``. Users are **strongly** recommended to switch to ``meson``
134+
since it is the default above Python ``3.12``.
135+
136+
Common build flags:
137+
138+
``--backend <backend_type>``
139+
Specify the build backend for the compilation process. The supported backends
140+
are ``meson`` and ``distutils``. If not specified, defaults to ``distutils``.
141+
On Python 3.12 or higher, the default is ``meson``.
136142
``--f77flags=<string>``
137143
Specify F77 compiler flags
138144
``--f90flags=<string>``
139145
Specify F90 compiler flags
140-
``--opt=<string>``
141-
Specify optimization flags
142-
``--arch=<string>``
143-
Specify architecture specific optimization flags
144-
``--noopt``
145-
Compile without optimization flags
146-
``--noarch``
147-
Compile without arch-dependent optimization flags
148146
``--debug``
149147
Compile with debugging information
150148
``-l<libname>``
@@ -159,13 +157,41 @@ following options can be used in this mode:
159157
``-L<dir>``
160158
Add directory ``<dir>`` to the list of directories to be searched for
161159
``-l``.
162-
``link-<resource>``
160+
161+
The ``meson`` specific flags are:
162+
163+
``--dep <dependency>`` **meson only**
164+
Specify a meson dependency for the module. This may be passed multiple times
165+
for multiple dependencies. Dependencies are stored in a list for further
166+
processing. Example: ``--dep lapack --dep scalapack`` This will identify
167+
"lapack" and "scalapack" as dependencies and remove them from argv, leaving a
168+
dependencies list containing ["lapack", "scalapack"].
169+
170+
The older ``distutils`` flags are:
171+
172+
``--help-fcompiler`` **no meson**
173+
List the available Fortran compilers.
174+
``--fcompiler=<Vendor>`` **no meson**
175+
Specify a Fortran compiler type by vendor.
176+
``--f77exec=<path>`` **no meson**
177+
Specify the path to a F77 compiler
178+
``--f90exec=<path>`` **no meson**
179+
Specify the path to a F90 compiler
180+
``--opt=<string>`` **no meson**
181+
Specify optimization flags
182+
``--arch=<string>`` **no meson**
183+
Specify architecture specific optimization flags
184+
``--noopt`` **no meson**
185+
Compile without optimization flags
186+
``--noarch`` **no meson**
187+
Compile without arch-dependent optimization flags
188+
``link-<resource>`` **no meson**
163189
Link the extension module with <resource> as defined by
164190
``numpy_distutils/system_info.py``. E.g. to link with optimized LAPACK
165191
libraries (vecLib on MacOSX, ATLAS elsewhere), use ``--link-lapack_opt``.
166192
See also ``--help-link`` switch.
167193

168-
.. note::
194+
.. note::
169195

170196
The ``f2py -c`` option must be applied either to an existing ``.pyf`` file
171197
(plus the source/object/library files) or one must specify the
@@ -215,6 +241,9 @@ Other options
215241

216242
.. warning:: Don't use this option if a signature file (``*.pyf``) is used.
217243

244+
.. versionchanged:: 2.0.0
245+
Will ignore ``-m`` if a ``pyf`` file is provided.
246+
218247
``--[no-]lower``
219248
Do [not] lower the cases in ``<fortran files>``. By default, ``--lower`` is
220249
assumed with ``-h`` switch, and ``--no-lower`` without the ``-h`` switch.

numpy/f2py/crackfortran.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,8 +2398,6 @@ def _calc_depend_dict(vars):
23982398

23992399

24002400
def get_sorted_names(vars):
2401-
"""
2402-
"""
24032401
depend_dict = _calc_depend_dict(vars)
24042402
names = []
24052403
for name in list(depend_dict.keys()):
@@ -3218,11 +3216,6 @@ def true_intent_list(var):
32183216

32193217

32203218
def vars2fortran(block, vars, args, tab='', as_interface=False):
3221-
"""
3222-
TODO:
3223-
public sub
3224-
...
3225-
"""
32263219
setmesstext(block)
32273220
ret = ''
32283221
nout = []

numpy/f2py/f2py2e.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@
6363
6464
Options:
6565
66-
--2d-numpy Use numpy.f2py tool with NumPy support. [DEFAULT]
67-
--2d-numeric Use f2py2e tool with Numeric support.
68-
--2d-numarray Use f2py2e tool with Numarray support.
69-
--g3-numpy Use 3rd generation f2py from the separate f2py package.
70-
[NOT AVAILABLE YET]
71-
7266
-h <filename> Write signatures of the fortran routines to file <filename>
7367
and exit. You can then edit <filename> and use it instead
7468
of <fortran files>. If <filename>==stdout then the
@@ -129,20 +123,22 @@
129123
-v Print f2py version ID and exit.
130124
131125
132-
build backend options (only effective with -c):
126+
build backend options (only effective with -c)
127+
[NO_MESON] is used to indicate an option not meant to be used
128+
with the meson backend or above Python 3.12:
133129
134-
--fcompiler= Specify Fortran compiler type by vendor
135-
--compiler= Specify C compiler type (as defined by distutils)
130+
--fcompiler= Specify Fortran compiler type by vendor [NO_MESON]
131+
--compiler= Specify distutils C compiler type [NO_MESON]
136132
137-
--help-fcompiler List available Fortran compilers and exit
138-
--f77exec= Specify the path to F77 compiler
139-
--f90exec= Specify the path to F90 compiler
133+
--help-fcompiler List available Fortran compilers and exit [NO_MESON]
134+
--f77exec= Specify the path to F77 compiler [NO_MESON]
135+
--f90exec= Specify the path to F90 compiler [NO_MESON]
140136
--f77flags= Specify F77 compiler flags
141137
--f90flags= Specify F90 compiler flags
142-
--opt= Specify optimization flags
143-
--arch= Specify architecture specific optimization flags
144-
--noopt Compile without optimization
145-
--noarch Compile without arch-dependent optimization
138+
--opt= Specify optimization flags [NO_MESON]
139+
--arch= Specify architecture specific optimization flags [NO_MESON]
140+
--noopt Compile without optimization [NO_MESON]
141+
--noarch Compile without arch-dependent optimization [NO_MESON]
146142
--debug Compile with debugging information
147143
148144
--dep <dependency>
@@ -167,7 +163,7 @@
167163
by numpy.distutils/system_info.py. E.g. to link
168164
with optimized LAPACK libraries (vecLib on MacOSX,
169165
ATLAS elsewhere), use --link-lapack_opt.
170-
See also --help-link switch.
166+
See also --help-link switch. [NO_MESON]
171167
172168
-L/path/to/lib/ -l<libname>
173169
-D<define> -U<name>
@@ -177,7 +173,6 @@
177173
Using the following macros may be required with non-gcc Fortran
178174
compilers:
179175
-DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN
180-
-DUNDERSCORE_G77
181176
182177
When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY
183178
interface is printed out at exit (platforms: Linux).
@@ -189,7 +184,6 @@
189184
190185
Version: {f2py_version}
191186
numpy Version: {numpy_version}
192-
Requires: Python 3.5 or higher.
193187
License: NumPy license (see LICENSE.txt in the NumPy source code)
194188
Copyright 1999 - 2011 Pearu Peterson all rights reserved.
195189
https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"""
@@ -711,23 +705,6 @@ def main():
711705
show_all()
712706
return
713707

714-
# Probably outdated options that were not working before 1.16
715-
if '--g3-numpy' in sys.argv[1:]:
716-
sys.stderr.write("G3 f2py support is not implemented, yet.\\n")
717-
sys.exit(1)
718-
elif '--2e-numeric' in sys.argv[1:]:
719-
sys.argv.remove('--2e-numeric')
720-
elif '--2e-numarray' in sys.argv[1:]:
721-
# Note that this errors becaust the -DNUMARRAY argument is
722-
# not recognized. Just here for back compatibility and the
723-
# error message.
724-
sys.argv.append("-DNUMARRAY")
725-
sys.argv.remove('--2e-numarray')
726-
elif '--2e-numpy' in sys.argv[1:]:
727-
sys.argv.remove('--2e-numpy')
728-
else:
729-
pass
730-
731708
if '-c' in sys.argv[1:]:
732709
run_compile()
733710
else:

0 commit comments

Comments
 (0)
0