0

I have managed to wrap a set of Fortran 90 sources manually using f2py. To do so, I generated the signature file as explained in: http://docs.scipy.org/doc/numpy/user/c-info.python-as-glue.html and I can obtain a .so which I can call from some Python interface files.

Now I want to create a package from it which would automatically build the Fortran extension. The only addition in the folder containing the Fortran sources and signature file is now a setup.py file with the following content:

from numpy.distutils.core import setup, Extension
from numpy.distutils.misc_util import Configuration

DISTNAME = 'greengard'

def configuration(parent_package='',top_path=None):
    config = Configuration(DISTNAME, parent_package, top_path)
    # the Fortran sources
    f90_sources = ['_greengard.pyf'
                   'nufft1df90.f',
                   'nufft2df90.f',
                   'nufft3df90.f',
                   'next235.f',
                   'dfftpack.f',
                   ]
    config.add_extension('_greengard', f90_sources)
return config

if __name__ == "__main__":
    setup(configuration=configuration) 

Then activated a virtualenv and tried to install the package

python setup.py install 

But get the following error in the end:

creating build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/greengard
compile options: '-Ibuild/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
gcc: build/src.linux-x86_64-2.7/greengard/_greengardmodule.c
gcc: build/src.linux-x86_64-2.7/fortranobject.c
compiling Fortran sources
Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-Ibuild/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
error: _greengard.pyfnufft1df90.f: No such file or directory

First line after launching setup.py gave:

non-existing path in '': '_greengard.pyfnufft1df90.f'

But the setup process keeps going and the Fortran extension seem to be compiled (the displayed lines look like what I get by manually running f2py).

I tried to find a solution from the examples available online but most of them were a bit too simple to be helpful. Can someone with experience in Python packaging help me on this one please ?

ghisvail
  • 33
  • 5

1 Answers1

0

After trying a bit more, I realized I was not correctly cleaning the intermediate "Build" directory created when calling the setup script. The latter must have retained one of my previous unsuccessful attempt where the path to the shared extension was set wrong.

I retried with a blank example and the installation into the site-packages of my virtualenv has been successful.

ghisvail
  • 33
  • 5