I mainly use distribute or pip to manage Python packages on my Windows machines. And I'm pretty happy eventhough they don't provide many of the features of other package managers.
Nice, but what does that have to do with building Python extensions?
Two very nice Python-based templating libraries Jinja2 and
Mako can take advantage of the native code module
in the MarkupSafe for increased performance.
But you need a way to build MarkupSafe
on your Windows system.
Enter the DevKit from
the RubyInstaller project. While the DevKit
's primary goal
is to enable Ruby-on-Window's users to easily build native Ruby extensions, it's also
handy as a general purpose Windows-based C/C++ toolchain.
But you also need to find a way to tell pip
to use the DevKit
toolchain. Running
pip install --help
shows the --install-option
and --global-option
options,
but there appears to be no way to tell pip
which compiler toolchain to use.
Or is there?
First, create the following file in your %USERPROFILE%
directory:
# file: %USERPROFILE%/pydistutils.cfg
[build]
compiler = mingw32
...and then execute the following in your shell. Pip
uses the DevKit
to build
and install MarkupSafe
and it's native library.
C:\Users\Jon>\DevKit\devkitvars.bat Adding the DevKit to PATH... C:\Users\Jon>pip install markupsafe Downloading/unpacking markupsafe Downloading MarkupSafe-0.11.tar.gz Running setup.py egg_info for package markupsafe Installing collected packages: markupsafe Running setup.py install for markupsafe building 'markupsafe._speedups' extension C:\DevKit\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c markupsafe/_speedups.c -o build\temp.win32-2.7\Release\markupsafe\_speedups.o C:\DevKit\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\markupsafe\_speedups.o build\temp.win32-2.7\Release\markupsafe\_speedups.def -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\markupsafe\_speedups.pyd Successfully installed markupsafe Cleaning up... C:\Users\Jon>
UPDATE: This is a known issue with pip on Windows so add your support to the fix request.