473,387 Members | 1,553 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,387 software developers and data experts.

How to Build Python 2.3.3 C/C++ Extensions in Windows Using Mingw32


Normally, one uses the following procedure to build
and install a C/C++
extension:

python setup.py build --compiler=your_compiler
python setup.py install

For Python 2.3.3 on Windows, with the Mingw
(Minimalist GNU) compiler,
the following steps must be taken:

1. Find your Mingw bin directory. Copy gcc.exe to
cc.exe.

2. Get PExports from either of:

http://sebsauvage.net/python/pexports-0.42h.zip

http://starship.python.net/crew/kern...orts-0.42h.zip

Extract pexports.exe to your Mingw bin directory.

3. Find pythonxx.dll. It should be in your main
Python directory. Do
the following:

pexports python23.dll > python23.def
dlltool --dllname python23.dll --def python23.def
--output-lib libpython23.a

4. Copy libpythonxx.a to \python\libs.

5. Patch distutils. Locate
\python\lib\distutils\msvccompiler.py, open
it, and find the following lines (around line 211):

if len (self.__paths) == 0:
raise DistutilsPlatformError, \
("Python was built with version %s
of Visual Studio, "
"and extensions need to be built
with the same "
"version of the compiler, but it
isn't installed." % self.__version)

Delete these.

6. Move back to the directory of your extension. Do
the following:

python setup.py build --compiler=mingw32
python setup.py install
Ideally, only step 6 should be required to install an
extension.

I submitted the patch for step 5 to
python.sourceforge.net.
Steps 2-4 can be avoided if the libpythonxx.a file is
distributed
with Python. I'll email the Python folks and ask
them to do this.
Step 1 can probably be avoided with another patch.

This document is based on
http://sebsauvage.net/python/mingw.html,
which was written for Mingw + Python 2.2.

Thanks,
Connelly Barnes

PS:
To test this process, try compiling myspell-python, a
spell checking library for Python. See
http://oregonstate.edu/~barnesc/mysp...on-1.01.tar.gz

__________________________________
Do you Yahoo!?
Yahoo! Domains – Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer

Jul 18 '05 #1
2 4241
On 2004-05-20, C. Barnes wrote in <ma*************************************@python.or g>:

2. Get PExports from either of:
This is awfully outdated.

http://sebsauvage.net/python/pexports-0.42h.zip

http://starship.python.net/crew/kern...orts-0.42h.zip

Extract pexports.exe to your Mingw bin directory.


Rather go to http://mingw.org/ and download the mingw-utils package.
Hopefully that's the same place you obtained your compiler, linker and
libraries.

A better writer wants to submit a patch for the distutils manual?

--
Alejandro López-Valencia
qenqhy ng rgo qbg arg qbg pb http://dradul.tripod.com/
\u864e\u306e\u795e\u6bbf
Jul 18 '05 #2
C. Barnes wrote:
5. Patch distutils. Locate
\python\lib\distutils\msvccompiler.py, open
it, and find the following lines (around line 211):

if len (self.__paths) == 0:
raise DistutilsPlatformError, \
("Python was built with version %s
of Visual Studio, "
"and extensions need to be built
with the same "
"version of the compiler, but it
isn't installed." % self.__version)

Delete these.


You don't need that. Do this instead:

python setup.py build --compiler=mingw32 bdist_wininst

Roger
Jul 18 '05 #3

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

Similar topics

10
by: Kotlin Sam | last post by:
For a while at least I have to work in Windows rather than UNIX, which is more familiar. I'm trying to do with Python some of the things that I've done for years in shell, in particular, sort. The...
35
by: Michael Kearns | last post by:
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my...
2
by: . | last post by:
Hi, how can I build python modules on windows? I tried to build numarray using Microsoft Visual C++ 2003 Toolkit, but got the following error: --- error: Python was built with version 7.1 of...
14
by: Mark Dufour | last post by:
After nine months of hard work, I am proud to introduce my baby to the world: an experimental Python-to-C++ compiler. It can convert many Python programs into optimized C++ code, without any user...
17
by: nnorwitz | last post by:
For more details about the plan for Python 2.5, see: http://www.python.org/doc/peps/pep-0356/ The highlights are that we are hoping to put out the first alpha Real Soon Now, hopefully in a...
1
by: Michael Sgier | last post by:
HI why those errors? i found some in the build options. What are those used for? What shall i do? mingw32-g++.exe: /W3: No such file or directory mingw32-g++.exe: /GX: No such file or directory...
5
by: Sile | last post by:
Hi, I've been trying to get f2py working on Windows XP, I am using Python 2.3. I'm new to python so I'm not too sure what I'm doing yet. I need the python-dev package to run f2py. I have been...
26
by: Kevin D. Smith | last post by:
I've written a simple Python extension for UNIX, but I need to get it working on Windows now. I'm having some difficulties figuring out how to do this. I've seen web pages that say that MS Visual...
4
by: M.-A. Lemburg | last post by:
Hi Robin, On 2008-10-23 17:55, Robin Becker wrote: That looks like a classical name clash between C header files. It also suggests that you have 64-bit client libs of MySQL installed. As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.