[ python-Bugs-957198 ] C/C++ extensions w/ Python + Mingw (Windows)
SourceForge.net
noreply at sourceforge.net
Wed May 19 23:36:16 EDT 2004
Bugs item #957198, was opened at 2004-05-20 03:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=957198&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Connelly (connelly)
Assigned to: Nobody/Anonymous (nobody)
Summary: C/C++ extensions w/ Python + Mingw (Windows)
Initial Comment:
I am asking you to distribute libpython23.a with Python.
This is a library built by the Mingw compiler
(www.mingw.org). When this file is present, it greatly
simplifies the process of installing a C/C++ extension.
The below document explains how make this library, and
install a C/C++ extension with the Mingw compiler.
Currently, a library is provided for the proprietary
MSVC++ compiler (python23.lib), but not the open source
Mingw compiler.
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/kernr/mingw32/pexports-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.
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
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=957198&group_id=5470
More information about the Python-bugs-list
mailing list