February 2008

Building Python Packages from Source on Windows

I always forget how to build Python packages, such as psyco and simplejson that require C/C++ code to be compiled. The usual error I get from running "python setup.py install" is

error: Python was built with Visual Studio 2003; extensions must be
built with a compiler than can generate compatible binaries. Visual
Studio 2003 was not found on this system. If you have Cygwin
installed, you can try compiling with MingW32, by passing "-c
mingw32" to setup.py.

Now, I do not have Visual Studio 2003, but I do have mingw32. (Grab cygwin and when selecting packages, make sure than mingw-runtime and gcc are selected.) Now, back with our setup.py file, execute:

python setup.py build_ext --compiler=mingw32 install

Hopefully that should solve any issues.

CPAN on Windows

To use Perl's CPAN <http://www.cpan.org>`_on Windows with `cygwin, you need to install some additional programs in cygwin. Run cygwin's setup.exe (I like clicking the "View" button to change the listing to Full, so I get an alphabetical list of the packages). Make sure that you install the following packages:

  • perl (just in case you do not have it)
  • gzip
  • tar
  • unzip
  • make
  • lynx
  • wget
  • ncftp
  • gnupg

Open the Cygwin bash shell and enter:

perl -MCPAN -e shell

Accept the defaults, and you are good to go. Once in the CPAN shell, you can install modules with commands like:

install Date::Parse