473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sample distutil setup.py script that uses SWIG and C++?

Could anyone post a simple setup.py script that uses a SWIG interface
to C++ code and the mingw compiler?

I followed some online samples, and am using the setup.cfg file to
specify swig-c++=1.

Trying to build using mingw out of the cygwin environment but the
final call to link the extension calls directly to 'cc' which I think
should really be g++ at that point.

Did get everything to build with a Makefile, but that's not the right
way to go.
Jul 18 '05 #1
3 2799
kd*******@yahoo.com (Kevin Dahlhausen) writes:
Could anyone post a simple setup.py script that uses a SWIG interface
to C++ code and the mingw compiler?

I followed some online samples, and am using the setup.cfg file to
specify swig-c++=1.

Trying to build using mingw out of the cygwin environment but the
final call to link the extension calls directly to 'cc' which I think
should really be g++ at that point.

Did get everything to build with a Makefile, but that's not the right
way to go.


That's what I do: a Makefile that runs swig, and setup.py just
compiles the output.

One advantage with this approach is you can include the SWIG'd sources
in your distribution tarball, and your user then doesn't need to have
SWIG installed (assuming you don't use the SWIG runtime library, of
course). I also use pyrex in my project, and I do the same thing with it.

The other advantage is it's easy to pass the appropiate parameters to
swig (mine are -c++ -Wall -python -modern), without digging around
into internals.

If you look at the code in distutils for SWIG support, it's a hack:
pasted on for this one tool, and very annonying to extend. And using
it with C++ is even worse. On some machines, I use a different C++
compiler than the C compiler (GNU C++ with Compaq C, for instance),
and distutils makes a hash of that.

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
Jul 18 '05 #2
kd*******@yahoo.com (Kevin Dahlhausen) wrote in message news:<28**************************@posting.google. com>...
Could anyone post a simple setup.py script that uses a SWIG interface
to C++ code and the mingw compiler?

I followed some online samples, and am using the setup.cfg file to
specify swig-c++=1.

Trying to build using mingw out of the cygwin environment but the
final call to link the extension calls directly to 'cc' which I think
should really be g++ at that point.

Did get everything to build with a Makefile, but that's not the right
way to go.

Maybe my pyMinGW can help you. Though still not 100% done, pyMinGW
includes a patch to distutils so as (among other things) to fix that
which you ask about.

Read about pyMinGW here:
http://jove.prohosting.com/iwave/ipython/pyMinGW.html

There is also a CPP-Swig example found in the Mingw\extensions
directory of both py24a3MinGW-004a.zip, and py234MinGW-015.zip.

Before you do anything, please backup the following files:

[1] Lib/distutils/ccompiler.py
[2] Lib/distutils/cygwinccompiler.py
[3] Lib/distutils/unixccompiler.py
[4] Lib/distutils/command/build_ext.py
in case you don't like the patch, and would like to restore your
distutils to its original state. Once you've done that then you can
replace those four files with the ones in the patch. Hopefully that'll
do it for you.

--
Q. The purpose of life?

[A]: "I created the jinn and humankind only that they might
worship Me." (Translation, Qur'an, 51:56)

[b]: "Let us hear the conclusion of the whole matter:
Fear God, and keep his commandments: for this is the
whole duty of man." (KJV, Ecclesiastes 12:13)
Jul 18 '05 #3
Thanks for the responses. Not forcing a depdency on swig makes sense
to me, so I'm going with that for the moment. I will take a look at
pyMinGW too.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Derek Croxton | last post by:
I just installed a new Linux distribution (MEPIS) and went to install PDO and got the error Traceback (most recent call last): File "setup.py", line 2, in ? from distutils.core import setup...
0
by: Holger Joukl | last post by:
Hi, what version of python are you using? I got the same error when invoking a customized, 2-year-old version of distutils with python 2.3.3 (instead of 1.5.2, as before). Reason is code in...
2
by: Helmut Jarausch | last post by:
Hi, I'd like to install SCons (http://www.scons.org) on my Linux box. There, the cvs version of Python is running. Doing as recommended in the README file export...
0
by: ReaprZero | last post by:
Hi, I'm using Cygwin and ActiveState perl to try to compile a sample application using SWIG. I'm using the short tutorial from http://www.swig.org/tutorial.html (the perl part of it), but with a...
1
by: kpd | last post by:
I am using distutils and mingw to create an extension from some C++ code for Python 2.4.1. It builds fine, but on import the following error comes up: python.exe - Entry Point Not Found The...
0
by: John Ling | last post by:
Hello, I have been trying to install an application which requires Python: http://chip.dfci.harvard.edu/~wli/MAT/ My environment is AIX 5.2. Below is the section of the setup that has failed,...
1
by: Stou Sandalski | last post by:
Hi, I have an application consisting of a main C++ class (and other classes) stored inside a DLL. The application uses a small main executable that links against the main DLL, then initializes...
0
by: mauro | last post by:
Hi all, I am trying to make a package distribution containing some extension module written in C. The problem is that when I run setup.py some files are generated in the wrong position. Suppose...
1
by: =?GB2312?B?zPC5zw==?= | last post by:
The problem is not compiler, but runtime. For example, if python is Thank you for providing this document. Indeed, passing internal pointers of one CRT lib to another is dangerous. But in most...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.