setup.py for c++

Rob McMonigal r at msolutionsinc.com
Tue Nov 4 19:24:08 EST 2003


python setup.py build --help-compilers

will give you a list of available compilers.  In your case it would probably
be

--compiler=unix

If you starting out, you may want to go through the options by starting at
python setup.py --help and explore from there.

HTH
Rob
"Zora Honey" <zhoney at wildmail.com> wrote in message
news:3FA6C613.5010302 at wildmail.com...
> I'm taking baby steps toward extending python with c++.  I got the demo
> from "Extending and Embedding the Python Interpreter" running.  My next
> step was to modify the demo to output stuff using <iostream>.  This
> fails, and this seems to be because my setup.py file is using a c
> compiler (gcc) instead of a c++ compiler.  I've searched the web and
> found several solutions, none of which I've been able to implement
> correctly.  I seem to be only inches away but always missing a critical
> piece of information, and I was wondering if the gurus here could help.
>     My attempts:
>
> 1.) From Pythonmac-SIG: "The problem is that the link step is done with
> "gcc", not "g++", so you have to add the C++ library by hand. The
> easiest is to add an extra_link_libraries (iirc) flag to the setup.py
> file." Where in the setup.py file? Is this simply a flag or does it need
> arguments?
>
> 2.) From "Extending and Embedding the Python Interpreter": "For example,
> if you need to link against libraries known to be in the standard
> library search path on target systems
>
> Extension(...,
>            libraries=["gdbm", "readline"])"
> This does seem to work, but I don't know if it's the same as 1) or which
> libraries I need to include.
>
> 3.) From "Installing Python Modules": "Arbitrary switches intended for
> the compiler or the linker can be supplied with the -Xcompiler arg and
> -Xlinker arg options:
> foo foomodule.c -Xcompiler"
>
> I'm using the syntax:
> odule1 = Extension(modulename ,
>                      sources = sourcecode,
>                      )
> in my setup.py file, and don't know where to put this compiler option.
>
> 4.) From ?: Use compiler option:  python setup.py build --compiler=g++
> I get an error message that ends in:
> distutils.errors.DistutilsPlatformError: don't know how to compile C/C++
> code on platform 'posix' with 'g++' compiler
> Which sounds like distutils doesn't like my compiler (or somehow I need
> to set the platform--I'm on RedHat 7.1).
>
> Thanks for any ideas,
> Zora
>






More information about the Python-list mailing list