469,356 Members | 1,994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Building Python extensions from sources on Windows

TPJ
Hello, I have another, probably stupid, question.

I'm working on some Python project, and I use some extensions written
in C. I do all the development on my GNU/Linux box, so my setup.py
script works just as it's supposed to work on a GNU/Linux system. But
in the nearest future I'll have to make an executable program for
Windows.

I know, that there are some useful tools to make executables from
Python programs for Windows (Py2Exe, PyInstaller - that's what I have
heard about), but, as far as I understand the subject, I'll need the
extensions modules (dll files? on my GNU/Linux system I always get some
so files - shared libraries) in the compiled form in order to make any
executable program.

In the Python standard documentation I have read, that:

"(...) Since the metadata is taken from the setup script, creating
Windows installers is usually as easy as running:

python setup.py bdist_wininst
(...)

If you have a non-pure distribution, the extensions can only be created
on a Windows platform, and will be Python version dependent. (...)"

And that's the problem: I understand the fact, that in order to build a
non-pure distrubution, all the C sources have to be compiled (to dll
libraries?). But there's the problem: I don't know which one compiler
should I use. Do I have to use the same compiler, that the Python has
been compiled with? If so, which one of the Windows compilers has been
used to compile Python?

Or perhaps could I use an another compiler? Which one, then?

I have no idea what to do. I haven't done anything on Windows for so
long...

Mar 25 '06 #1
1 1430
TPJ wrote:
And that's the problem: I understand the fact, that in order to build a
non-pure distrubution, all the C sources have to be compiled (to dll
libraries?). But there's the problem: I don't know which one compiler
should I use. Do I have to use the same compiler, that the Python has
been compiled with? If so, which one of the Windows compilers has been
used to compile Python?

Or perhaps could I use an another compiler? Which one, then?


You should use the same compiler; for Python 2.4, that was Visual Studio
..NET 2003. More specifically, you need to use the same version of the
C library - the compiler does not matter that much. The C library is
msvcr71.dll.

It is possible to build extensions with other compilers as well, e.g.
GNU mingw32.

If you don't VS 2003, but want to use that compiler, take a look at

http://www.vrplumber.com/programming/mstoolkit/

Regards,
Martin
Mar 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris Gonnerman | last post: by
3 posts views Thread by Matthias Baas | last post: by
1 post views Thread by pcaro8a | last post: by
4 posts views Thread by davidstummer | last post: by
6 posts views Thread by JW | last post: by
4 posts views Thread by vedrandekovic | last post: by
15 posts views Thread by kyosohma | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.