Building Python extensions from sources on Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TPJ

    #1

    Building Python extensions from sources on Windows

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

  • Martin v. Löwis

    #2
    Re: Building Python extensions from sources on Windows

    TPJ wrote:[color=blue]
    > 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?[/color]

    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



    Regards,
    Martin

    Comment

    Working...