[ python-Bugs-1706381 ] SWIG options not being followed in all cases

SourceForge.net noreply at sourceforge.net
Tue Apr 24 17:27:34 CEST 2007


Bugs item #1706381, was opened at 2007-04-24 08:49
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1706381&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Morten Lied Johansen (epcylon)
Assigned to: Nobody/Anonymous (nobody)
Summary: SWIG options not being followed in all cases

Initial Comment:
I guess this is an undocumented feature, so maybe I shouldn't complain (but the patch to the docs has been in the patch tracker waiting to go in since 2004 it seems).

Default for SWIG is to produce C code, in a file called xxx_wrap.c. If you want C++, you need to specify the -c++ option (in which case you would normally want a file called xxx_wrap.cpp).


You can specify this option in two ways, either on the commandline, like so:

python setup.py build_ext --swig-opts="-c++"

or as an option to your Extention module in setup.py like so:
...
ext_modules = [Extension("_xxx", ["xxx.i","xxx.cpp"], swig_opts=["-c++"])]
...


The latter is much preferable, as it doesn't mean you have to remember to specify the option on the commandline all the time.

When specifying on the commandline, the -c++ is taken into account for creating the name of the output, and you get a file called xxx_wrap.cpp. Specifying the option in setup.py however, is not taken into account, and you get a file called xxx_wrap.c, which contains C++ code and generally doesn't compile (since the compiler assumes it's pure C).

I've attached a simple patch that seems to solve the problem.



----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2007-04-24 15:27

Message:
Logged In: YES 
user_id=849994
Originator: NO

Thanks for the report, fixed in rev. 54941, 54942 (2.5).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1706381&group_id=5470


More information about the Python-bugs-list mailing list