[Pyrex] Mingw usage so simple?

John J Smith johnjsmith at rediffmail.com
Wed Oct 6 21:29:33 CEST 2004


An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20041006/e05328cf/attachment.html
-------------- next part --------------
I'm new to using Pyrex.  I need to get a computationally
intensive function optimized.  The platform is Win98,
Python 2.3.4 (the installable executable as obtained from
www.python.org).

I'm using gcc 3.2 in -mno-cygwin (mingw) mode, though I
believe the python.org version is built with MSVC.

I have the following files:

  func.c (with a function f())
  pyfunc.pyx (with a function pf() that calls f())

Various web pages indicated that a long dance involving
dlltool and such utilities would be required.

However, this simple procedure seems to work for me:

  gcc -mno-cygwin -O3 -c func.c -o func.o

  pyrexc -o pyfunc.c pyfunc.pyx

  gcc -mno-cygwin -Ic:/python23/include -O3 -c \
      pyfunc.c -o pyfunc.o

  gcc -mno-cygwin -O3 -shared func.o pyfunc.o \
      c:/windows/system/python23.dll -o pyfunc.pyd

Importing pyfunc and calling pyfunc.pf() from Python
give the expected results.

Is it supposed to be so straightforward?  Is this
procedure reliable?  Will it work for more complex
functions?  Will the resulting .pyd file work on other
MS Windows versions?

Any input would be useful.

Thanks,

jjs


More information about the Pyrex mailing list