Question

I am trying to create a Python module from Fortran code using f2py. I have set up a Makefile for my project. I am using MinGW and Python 3.2.2 on Windows 7. When I run

f2py.py -c --compiler=mingw32 -m itf itimes-f.f

everything compiles and runs fine. However, when I create a target in my Makefile and run it, it does this:

> make compilef
f2py.py -c --compiler=mingw32 -m itf itimes-f.f
process_begin: CreateProcess(NULL, env python.exe C:\Python32\Scripts\f2py.py -c
 --compiler=mingw32 -m itf itimes-f.f, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [compilef] Error 2

Why won't make run the command, and how can I fix it?

EDIT: Running the command shown in the output doesn't work:

> env python.exe C:\Python32\Scripts\f2py.py -c --compiler=mingw32 -m itf itimes-f.f
'env' is not recognized as an internal or external command,
operable program or batch file.

However, the following does work:

> python.exe C:\Python32\Scripts\f2py.py -c --compiler=mingw32 -m itf itimes-f.f

EDIT 2: This raises another question - What is env and why does make add it?

EDIT 3: Based on Florian's comment, it seems that the env was added by make due to the presence of the shebang line in f2py.py. I edited f2py.py, adding an additional # in front of the shebang. I now have the following problem:

>make compilef
f2py.py -c --compiler=mingw32 -m itf itimes-f.f
process_begin: CreateProcess(C:\Python32\Scripts\f2py.py, f2py.py -c --compiler=
mingw32 -m itf itimes-f.f, ...) failed.
make (e=193): Error 193
make: *** [compilef] Error 193
Was it helpful?

Solution

Ok, it's just a convention to write makefiles so they run in a standard unix environment. Nevertheless, make comes from *nix and if you have make installed then you probably have msys which provides the basic tools, and scripts are executed in a unix-way, not like windows would do it...

An example makefile that works for me using mingw-make on windows:

all:
    ./test.py

With test.py having a shebang of #!C:\\Python27\\python.exe

or if python is in the PATH #!python is enough, as is:

all:
    python test.py
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top