Skip to content


StevenSilvester edited this page · 3 revisions
Clone this wiki locally
How to build a Windows installer under Linux or OSX

These are instructions for building a Windows installer (.exe) of your package under a foreign operating system.  For this purposes, Wine is used to emulate Windows, although there is no reason why the extension cannot be built on a virtual machine.

1. Install Wine (`sudo apt-get install wine` or available on OSX via `macports <>`_).

2. Install Python 2.7 from ` <>`_.

3. Install `mingw <>`_.  Click on the latest mingw-get-inst folder and download the exe file. Select the C, C++, and Fortran Compilers.  You may get a log error when installing, but it should still work.

4. Start the registry editor (wine regedit) and setup the system path:

 - Browse to the ``PATH`` key at ``HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment``, or use Edit > Find > PATH.
 - Append to it: ``c:\python27;c:\mingw\bin;c:\python27\scripts``.
 - Right click and select New > String Value to create a new key called ``HOME`` and set it to ``c:\users\yourusername``

5. Create a new file in ``~/.wine/dosdevices/c:/users/yourusername/`` called ``pydistutils.cfg`` containing



This tells distutils not to look for the Microsoft Compilers, but to use mingw as the
default compiler.

6. Get the ``setuptools-*.win32-py2.7.exe`` from ` <>`_ and install.

7. Install Cython (using ``wine easy_install cython``).
Note: If you get ``error: unrecognized command line option '-mno-cygwin'``,
remove the ``-mno-cygwin`` flags in the ``Mingw32CCompiler`` class in
``~/.wine/dosdevices/c:/Python27/Lib/distutils/``, then run easy_install again.
For more information, see `python issue 12641 <>`_.
The diff is as follows:


    <         self.set_executables(compiler='gcc -O -Wall',
    <                              compiler_so='gcc -mdll -O -Wall',
    <                              compiler_cxx='g++ -O -Wall',
    <                              linker_exe='gcc',
    <                              linker_so='%s %s %s'
    >         self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
    >                              compiler_so='gcc -mno-cygwin -mdll -O -Wall',
    >                              compiler_cxx='g++ -mno-cygwin -O -Wall',
    >                              linker_exe='gcc -mno-cygwin',
    >                              linker_so='%s -mno-cygwin %s %s'

8. Optionally, install Numpy from `provided installer <>`_.  Browse to the desired ``numpy-*-win32-superpack-python27.exe``.

9. Compile your extension from within your package source directory


  python bdist_wininst

This will only work if you have a file, similar to the one at
` <>`_.

This step should then generate a ``.exe`` in the ``dist/`` directory.
Something went wrong with that request. Please try again.