Building Python extensions from sources on Windows

T

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...
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

TPJ said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top