[Python-Dev] The other Py2.4 issue

Paul Moore p.f.moore at gmail.com
Fri Dec 10 13:06:01 CET 2004


On Fri, 10 Dec 2004 10:06:59 +0000, Armin Rigo <arigo at tunes.org> wrote:
> For people like myself, Linux programmers not developing on Windows every day,
> there is precious little information available about how to compile our
> extension modules for the new Windows distribution.  I was actually very
> disappointed to have to google my way around until I found a page that
> explained to me that to use Microsoft's free compilers you need to manually
> patch the distutils included with 2.4.  (I know this is being worked on right
> now but I'd have expected it to be present in the 2.4 release.)  (The only
> page I could find still refers to a pre-final 2.4 so their distutils patch
> doesn't apply without hand-editing, though that should be fixed by now.)
[...]
> In other words, if you want 3rd parties to compile Windows binaries for 2.4,
> tell them how.

I think that the details about the Microsoft free compilers is a bit
misleading. Sure, it's great that it exists, but at the present time,
it is not the best free option (too many downloads required, too many
rough edges).

For most C extensions, the best free option is mingw. This is fully
supported by distutils, and has been for a while. It is documented in
the manuals, but basically all you need is to do the following:

1. Obtain a reasonably recent mingw (3.3.3 definitely works, you need
msvcr71 support).
2. Install it, and make sure it is in your PATH.
3. Build libpython24.a as documented in the Python manuals (recent
versions of mingw can read MS import libraries, so this may no longer
be needed, but I haven't tested this yet).
4. python setup.py build --compiler=mingw32.

The only difficulties are:

1. Obtaining support libraries like jpeg, sdl, etc. It *may* be a
nuisance getting mingw-compatible build, but as I say above, MS-format
libraries may now be fine, and there are good sources of
mingw-compatible libraries like gnuwin32.sourceforge.net.
2. Microsoft-specific code. (As I'm replying to Armin, maybe the fact
that inline assembler formats are different is relevant :-) :-))

To be honest, I'd only ever use the MS free compilers if I had a
critical need to build an extension which had some highly MS-specific
code or build processes. And even then, I'd probably give up and wait
for someone with MSVC7 to produce a binary...

If anyone has any particular modules (of their own, or third party)
they have problems with, I'd be happy to have a go at building, and
report back. Maybe a page on the Python Wiki about building modules
using mingw would be worth adding. Hmm, might do that tonight...

Hope this helps,
Paul.


More information about the Python-Dev mailing list