473,587 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_c ompiler
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\dis tutils\msvccomp iler.py, open
it, and find the following lines (around line 211):

if len (self.__paths) == 0:
raise DistutilsPlatfo rmError, \
("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=mingw3 2
python setup.py install
Ideally, only step 6 should be required to install an
extension.

I submitted the patch for step 5 to
python.sourcefo rge.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 4256
On 2004-05-20, C. Barnes wrote in <ma************ *************** **********@pyth on.org>:

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\u7 95e\u6bbf
Jul 18 '05 #2
C. Barnes wrote:
5. Patch distutils. Locate
\python\lib\dis tutils\msvccomp iler.py, open
it, and find the following lines (around line 211):

if len (self.__paths) == 0:
raise DistutilsPlatfo rmError, \
("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=mingw3 2 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
1963
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 shell sort is pretty easy to use: % sort -t, +2 +5 imputfilename <return> where -t is the field separator, in this case a comma, , and +2 and +4...
35
3057
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 colleagues noted that on her machine the launcher would complain it was missing a DLL - msvcr71.dll However, there's a very grey area concerning the...
2
2352
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 Visual Studio, and extensions need to be built with the same version of the compiler, but it isn't installed. ---
14
4289
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 intervention such as adding type declarations. It uses rather advanced static type inference techniques to deduce type information by itself. In...
17
1868
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 week or two. If there's something you really think just must be in 2.5 and can't wait until 2.6, now is the time to speak up. (Actually, it was time...
1
2847
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 mingw32-g++.exe: /O2: No such file or directory mingw32-g++.exe: /DWIN32: No such file or directory mingw32-g++.exe: /DNDEBUG: No such file or...
5
3930
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 told this is just the header files and .dll and I need to put them somewhere my C compiler can find them. I've searched the web and none of the...
26
2138
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 Studio is required, and other that say that's not true, that MinGW will work. Then there is Mike Fletcher's web page...
4
1583
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 long as the MySQL client lib is built as 32-bit lib, you shouldn't
0
7920
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...
0
7849
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...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
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...
0
5394
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...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
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
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.