Skip to content

Commit

Permalink
DOC: Cleanup F2Py doc with reduced distutils info
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Nov 22, 2023
1 parent eed77e2 commit ac26bef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
21 changes: 13 additions & 8 deletions doc/source/f2py/f2py.getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@ following steps:
* F2PY compiles all sources and builds an extension module containing
the wrappers.

* In building the extension modules, F2PY uses ``numpy_distutils`` which
supports a number of Fortran 77/90/95 compilers, including Gnu, Intel, Sun
Fortran, SGI MIPSpro, Absoft, NAG, Compaq etc. For different build systems,
see :ref:`f2py-bldsys`.
* In building the extension modules, F2PY uses ``meson`` and used to use
``numpy.distutils`` For different build systems, see :ref:`f2py-bldsys`.

* Depending on your operating system, you may need to install the Python
development headers (which provide the file ``Python.h``) separately. In
Linux Debian-based distributions this package should be called ``python3-dev``,
in Fedora-based distributions it is ``python3-devel``. For macOS, depending
how Python was installed, your mileage may vary. In Windows, the headers are
typically installed already.
typically installed already, see :ref:`f2py-windows`.

.. note::

F2PY supports all the operating systems SciPy is tested on so their
`system dependencies panel`_ is a good reference.

Depending on the situation, these steps can be carried out in a single composite
command or step-by-step; in which case some steps can be omitted or combined
with others.

Below, we describe three typical approaches of using F2PY. These can be read in
order of increasing effort, but also cater to different access levels depending
on whether the Fortran code can be freely modified.
Below, we describe three typical approaches of using F2PY with Fortran 77. These
can be read in order of increasing effort, but also cater to different access
levels depending on whether the Fortran code can be freely modified.

The following example Fortran 77 code will be used for
illustration, save it as ``fib1.f``:
Expand Down Expand Up @@ -298,3 +301,5 @@ the previous case::

>>> print(fib3.fib(8))
[ 0. 1. 1. 2. 3. 5. 8. 13.]

.. _`system dependencies panel`: http://scipy.github.io/devdocs/building/index.html#system-level-dependencies
21 changes: 15 additions & 6 deletions doc/source/f2py/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ F2PY user guide and reference manual
=====================================

The purpose of the ``F2PY`` --*Fortran to Python interface generator*-- utility
is to provide a connection between Python and Fortran. F2PY is a part of NumPy_
(``numpy.f2py``) and also available as a standalone command line tool.
Originally created by Pearu Peterson, and older changelogs are in the
`historical reference`_.
is to provide a connection between Python and Fortran. F2PY distributed as part
of NumPy_ (``numpy.f2py``) and once installed is also available as a standalone
command line tool. Originally created by Pearu Peterson, and older changelogs
are in the `historical reference`_.

F2PY facilitates creating/building Python C/API extension modules that make it
possible
F2PY facilitates creating/building native `Python C/API extension modules`_ that
make it possible

* to call Fortran 77/90/95 external subroutines and Fortran 90/95
module subroutines as well as C functions;
Expand All @@ -20,6 +20,14 @@ possible

from Python.


.. note::

Fortran 77 is essentially feature complete, and an increasing amount of
Modern Fortran is supported within F2PY. Most ``iso_c_binding`` interfaces
can be compiled to native extension modules automatically with ``f2py``.
Bug reports welcome!

F2PY can be used either as a command line tool ``f2py`` or as a Python
module ``numpy.f2py``. While we try to provide the command line tool as part
of the numpy setup, some platforms like Windows make it difficult to
Expand Down Expand Up @@ -47,3 +55,4 @@ replace all calls to ``f2py`` mentioned in this guide with the longer version.
.. _Python: https://www.python.org/
.. _NumPy: https://www.numpy.org/
.. _`historical reference`: https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
.. _Python C/API extension modules: https://docs.python.org/3/extending/extending.html#extending-python-with-c-or-c

0 comments on commit ac26bef

Please sign in to comment.