Python 2.3 distutils with Mingw C++

A

Andrew Gregory

In Python 2.2, I compiled some C++ code on Windows (MinGW compiler) to
create an extension using distutils and the following setup.py file:

from distutils.core import setup, Extension
setup (name = "_pysimple",
version = "1.0",
maintainer = "AG",
maintainer_email = "(e-mail address removed)",
description = "Sample Python C++ DLL",
ext_modules = [Extension('_pysimple',

extra_compile_args=['-O2','-march=i586','-malign-double'],
extra_link_args=['-mthread'],
library_dirs=['C:\\mingw\\lib'],
libraries=['supc++'], # if using iostreams etc.
use stdc++
sources=['pysimple_wrap.cxx'])])

Provided that certain C++ features such as templates were not used,
this would build ok using the gcc compiler (not g++), as supc++ is
linked to.
Command used is: python setup.py build --compiler=mingw32

In Python 2.3, distutils recognises the .cxx extension as C++ and
tries to compile with
cc -mno-cygwin -shared etc.
resulting in "cc not found" error message. It should compile with
c:\mingw\bin\gcc -mno-cygwin -shared etc.
or *much* better
c:\mingw\bin\g++ -mno-cygwin -shared etc.

The quick fix is to copy the old distutils subdirectory from Python22
into Python23.

Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top