Building Python Modules on Windows

Python is a great cross platform application development environment. There is a  wide range of python modules (libraries) available. In most cases, module distributors supply platform specific installers which already built or at least they distribute the source code and let it to be built and installed by developers.

It is easy to build and install any python module in a Unix system. Because all *nix systems have a built in  development environment to build python modules ( or any language). So, just typing “python setup.py buil” and “python setup.py install” will be enough to get things done. Hard part is
having a windows. There are some options this issue:

1 -) Using MS Visual Studio ( I hate it)
2 -) Using Cygwin to get gcc for Windows
3 -) Using MinGW to get gcc for Windows

I choosed the 3rd option, it is the easiest one. What you have to do is get MinGW installer
and install required compilers and set it to your OS path. Mine is “C:MinGWbin”. Then, open a command prompt and cd to the source folder of the python module. Run build statement “python setup.py build -c mingw32” this will build your module and get it ready to use. The build tool will generate a folder called “buildlib.win32-*.*” which contains compiled libraries. Copy those libraries to somewhere in python classpath. Mine is located at “C:Python25Lib”. That is it.You are ready to use your module. To test it, you can use pycrypto.