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 (available on OSX via macports).
  2. Install Python 2.5 from python.org
  3. Install mingw. Install the base system and g++.
  4. Start the registry editor (wine regedit) and setup the system path:
  • Search for Environment and find the PATH key
  • Append to it c:\python25;c:\mingw\bin;c:\python25\scripts
  • Add a new key called HOME and set it to c:\windows\profiles\yourusername
  1. Create a new file in ~/.wine/drive_c/windows/profiles/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.

  1. Install setuptools (not necessary, but convenient if you want to install other packages).
  1. Install Cython (either from source as in 6 or using easy_install cython).
  2. Compile you 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 in http://dip.sun.ac.za/~stefan/code/cython_demo.git.

This step should then generate a .exe in the dist/ directory.

If your package requires NumPy to work, you'll have to install that prior to step 8 via the provided installer or by

  • Extracting the numpy source tree
  • python setup.py build -c mingw32
  • python setup.py install --skip-build

BuildingWindowsInstaller (last edited 2009-06-17 08:56:56 by StefanVanDerWalt)