473,783 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2816
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)phy sics(dot)mcmast er(dot)ca
Jul 18 '05 #2
kd*******@yahoo .com (Kevin Dahlhausen) wrote in message news:<28******* *************** ****@posting.go ogle.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\extension s
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.p y
[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
1311
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 ImportError: No module named distutils.core Undaunted, I downloaded the Distutils package, which is supposed to be able to install itself with the usual "python setup.py install."
0
1666
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 dist.py, using dir() to look up the attributes of a class instance. But dir() nowadays also returns the class methods, __doc__ etc. Changing this in the old distutils/dist.py made it work for me, again (line
2
1662
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 SCONS_LIB_DIR=`pwd`/src/engine python src/script/scons.py build/scons I get after some time
0
2407
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 simplified version of their example (just a void hello() {printf("Hello, world!\n");} and corresponding .i interface file, %module hello \ extern void hello();). I first do swig -perl5 hello.i which works fine.
1
2299
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 procedure entry point _ctype could not be locatid in the dynamic link library msvcr71.dll I am not using ctype directly, but references to it apprear to be linked in by mingw in the resulting pyd file.
0
1382
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, which BTW works fine on Fedora 5. I suspect it has to do with Python on AIX and/or the setup.py script. Has anyone experienced this before? MAT-2.04182006python setup.py install Found make and swig.
1
1314
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 and runs the core class. The python bindings are inside a .pyd module that also links against the core DLL file. I was able to generate the python bindings against the core class using SWIG. The application can now be run either by the...
0
1173
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 that this is my setup.py: from distutils.core import setup, Extension setup(name='foo', package_dir = {"foo" : "src"},
1
159
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 cases, the python extension only focus on computational-intensive jobs rather than API-intensive jobs. Therefore it is safe to let VS2003-built python to call VS2005-built extensions with some attentions. When you use distutil to trigger...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.