[Numpy-discussion] Help using numpy.distutils.fcompiler for my GSoC project

Lisandro Dalcin dalcinl@gmail....
Tue Jun 23 13:41:00 CDT 2009


On Mon, Jun 22, 2009 at 11:53 PM, Kurt Smith<kwmsmith@gmail.com> wrote:
> Hello,
>
> Is there a way for numpy.distutils to compile a fortran source file
> into an executable?

If the whole point of building the executable is to run it in order to
parse the output, then you can start with this:

$ cat setup.py
from numpy.distutils.core import setup
from numpy.distutils.command.config import config as config_orig

helloworld = """
program hello
    write(*,*) "Hello, World!"
end program hello
"""

class config(config_orig):
    def run(self):
        self.try_run(helloworld, lang='f90')

setup(name="ConfigF90",
      cmdclass={'config' : config})


$ python setup.py config
<... lots of ouput ...>
gfortran:f90: _configtest.f90
/usr/bin/gfortran -Wall -Wall _configtest.o -lgfortran -o _configtest
_configtest
 Hello, World!
success!
removing: _configtest.f90 _configtest.o _configtest


In order to actually capture the ouput, you will have to implement
method spawn() in class config(), likely using subprocess module (or
older os.* APIS's for max backward compatibility)

Hope this helps,


> I'm not well-versed in the black arts of
> distutils or numpy.distutils.  I know the basics and am quickly
> reading up on it -- any pointers would be very appreciated.
>
> Thanks,
>
> Kurt Smith
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594


More information about the Numpy-discussion mailing list