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 <http://www.macports.org/>`_). 2. Install Python 2.7 from `python.org <http://www.python.org>`_. 3. Install `mingw <http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/>`_. 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 :: [build] compiler=mingw32 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 `http://pypi.python.org/pypi/setuptools <http://pypi.python.org/pypi/setuptools>`_ 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/cygwinccompiler.py``, then run easy_install again. For more information, see `python issue 12641 <http://bugs.python.org/issue12641>`_. The diff is as follows: :: 322,326c322,326 < 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 <http://sourceforge.net/projects/numpy/files/NumPy/>`_. Browse to the desired ``numpy-*-win32-superpack-python27.exe``. 9. Compile your extension from within your package source directory :: python setup.py bdist_wininst This will only work if you have a setup.py file, similar to the one at `https://github.com/stefanv/cython_demo.git <https://github.com/stefanv/cython_demo.git>`_. This step should then generate a ``.exe`` in the ``dist/`` directory.