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

David Cournapeau cournape@gmail....
Tue Jun 23 22:17:36 CDT 2009


On Wed, Jun 24, 2009 at 3:41 AM, Lisandro Dalcin<dalcinl@gmail.com> wrote:
> 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)

If possible, you should not build executables, it is not portable.
Compiling and linking is Ok, running is not. For a tool which is aimed
a general use, I think this is important. Knowing the exact tests
needed by the OP would help me to give more detailed advices.

cheers,

David


More information about the Numpy-discussion mailing list