[f2py] Help with using f2py under WinXP

Mauro Cavalcanti <[email protected]> Thu, 9 Sep 2010 23:43:22 -0300
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Dear ALL,

Greetings. I am new to py2f (and although not new to Python, I am not
used to writing extension modules). I have a very simple FORTRAN
module, consisting of two small subroutines, with which I want to
create a Python extension module under WindowsXP.

I have compiled and created the extension module with these
subroutines without any hassles under Ubuntu Linux (Jaunty), using g95
(v4.3.3-5), and they work as expected when called from a Python
program. However, when attempting to compile the extension under
WindowsXP (with Python 2.5 and Numpy 1.3, gfortran and gcc 4.6.0
(20100620) [trunk revision 161045] from MinGW), I have struck to a
number of errors.

To compile the extension module, I issued the command:

C:\Projetos\Croizat\source>python c:\Python25\scripts\f2py.py
--build-dir \tmp --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -c
Calc.f -m Calc

I then get the following output:

running build

running config_cc

unifing config_cc, config, build_clib, build_ext, build commands
--compiler options

running config_fc

unifing config_fc, config, build_clib, build_ext, build commands
--fcompiler options

running build_src

building extension "Calc" sources

f2py options: []

  adding '\tmp\src.win32-2.5\fortranobject.c' to sources.

  adding '\tmp\src.win32-2.5' to include_dirs.

running build_ext

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

customize Gnu95FCompiler

Found executable c:\gfortran\bin\gfortran.exe

Found executable c:\gfortran\bin\gfortran.exe

customize Gnu95FCompiler using build_ext

building 'Calc' extension

compiling C sources

C compiler: gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes



compile options: '-I\tmp\src.win32-2.5
-IC:\Python25\lib\site-packages\numpy\core\include
-IC:\Python25\include -IC:\Python25\PC -c' gcc -mno-cygwin -O2 -Wall
-Wstrict-prototypes -I\tmp\src.win32-2.5
-IC:\Python25\lib\site-packages\numpy\core\include
-IC:\Python25\include -IC:\Python25\PC
-c\tmp\src.win32-2.5\fortranobject.c -o
\tmp\src.win32-2.5\fortranobject.o

Found executable c:\gfortran\bin\gcc.exe

In file included from C:\Python25\include/Python.h:8:0,
  <---------------------
                 from \tmp\src.win32-2.5\/fortranobject.h:7,
    <---------------------
                 from \tmp\src.win32-2.5\fortranobject.c:2:

C:\Python25\include/pyconfig.h:61:16: fatal error: io.h: No such file
or directory compilation terminated.

error: Command "gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes
-I\tmp\src.win32-2.5
-IC:\Python25\lib\site-packages\numpy\core\include
-IC:\Python25\include -IC:\Python25\PC -c
\tmp\src.win32-2.5\fortranobject.c -o
\tmp\src.win32-2.5\fortranobject.o" failed with exit status 1


As it can be seen from the two lines indicated by arrows, it seems
that the compiler is confused by the different styles of backlashes
("/" and "\"), but I have no idea of where to look for this!

I presume the subsequent errors are caused by this problem, however I
also could not locate the pyconfig.h under C:\Python25\include. The
output files "fortranobject.c", "fortranobject.h" and "Calcmodule.c"
are correctly created in the \tmp\scr.win32-2.5 directory, but it
seems that because it gets confused with the backlashes, the compiler
is not able to find them in order to complete the process of creating
the extension module.

Any hints?

Thanks in advance for any assistance you can provide.

With warmest regards,

-- 
Dr. Mauro J. Cavalcanti
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: [email protected]
Web: http://sites.google.com/site/maurobio
Linux Registered User #473524 * Ubuntu User #22717