Discussion:
[Numpy-discussion] f2py, numpy.distutils and multiple Fortran source files
David Verelst
2015-12-03 21:07:32 UTC
Permalink
Hi,

For the wafo [1] package we are trying to include the extension compilation
process in setup.py [2] by using setuptools and numpy.distutils [3]. Some
of the extensions have one Fortran interface source file, but it depends on
several other Fortran sources (modules). The manual compilation process
would go as follows:

gfortran -fPIC -c source_01.f
gfortran -fPIC -c source_02.f
f2py -m module_name -c source_01.o source_02.o source_interface.f

Can this workflow be incorporated into setuptools/numpy.distutils?
Something along the lines as:

from numpy.distutils.core import setup, Extension
ext = Extension('module.name',
depends=['source_01.f', 'source_02.f'],
sources=['source_interface.f'])

(note that the above does not work)

[1] https://github.com/wafo-project/pywafo
[2] https://github.com/wafo-project/pywafo/blob/pipinstall/setup.py
[3] http://docs.scipy.org/doc/numpy/reference/distutils.html

Regards,
David
​
Tim Cera
2015-12-04 01:14:48 UTC
Permalink
Post by David Verelst
Hi,
For the wafo [1] package we are trying to include the extension
compilation process in setup.py [2] by using setuptools and
numpy.distutils [3]. Some of the extensions have one Fortran interface
source file, but it depends on several other Fortran sources (modules). The
gfortran -fPIC -c source_01.f
gfortran -fPIC -c source_02.f
f2py -m module_name -c source_01.o source_02.o source_interface.f
Can this workflow be incorporated into setuptools/numpy.distutils?
from numpy.distutils.core import setup, Extension
ext = Extension('module.name',
depends=['source_01.f', 'source_02.f'],
sources=['source_interface.f'])
(note that the above does not work)
[1] https://github.com/wafo-project/pywafo
[2] https://github.com/wafo-project/pywafo/blob/pipinstall/setup.py
[3] http://docs.scipy.org/doc/numpy/reference/distutils.html
Regards,
David
​
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
This might be helpful:
https://github.com/timcera/wdmtoolbox/blob/master/setup.py

Looks like I created the *.pyf file and include that in sources. I think I
only used f2py to create the pyf file and not directly part of the
compilation process. If memory serves the Extension function knows what to
do with the pyf file.

Kindest regards,
Tim
Sturla Molden
2015-12-04 10:34:07 UTC
Permalink
Can this workflow be incorporated into |setuptools|/|numpy.distutils|?
Take a look at what SciPy does.

https://github.com/scipy/scipy/blob/81c096001974f0b5efe29ec83b54f725cc681540/scipy/fftpack/setup.py

Multiple Fortran files are compiled into a static library using
"add_library", which is subsequently linked to the extension module.


Sturla
David Verelst
2015-12-05 15:01:02 UTC
Permalink
Thanks a lot for providing the example Sturla, that is exactly what we are
looking for!
Can this workflow be incorporated into |setuptools|/|numpy.distutils|?
Take a look at what SciPy does.
https://github.com/scipy/scipy/blob/81c096001974f0b5efe29ec83b54f725cc681540/scipy/fftpack/setup.py
Multiple Fortran files are compiled into a static library using
"add_library", which is subsequently linked to the extension module.
Sturla
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...