I installed PyCrypto on Windows via pip but i was not able to build Crypto.PublicKey._fastmath because GMP was not found.
I know there is a binary version on voidspace but i would like to build the latest version of PyCrypto
The following one is a way to achieve your goal. There are other, probably better ways (e.g. based on Visual Studio), but this one has worked for me. Additionally, it does not use pip
.
All operations are carried out on a command prompt.
MinGW\bin
and MingGW\msys\1.0\bin
.bash configure
followed by make
.libmpir.a
from mpir-2.5.0\.libs
into C:\Python2.7.1\libs
. This is necessary because distutils
is broken and I could not find a way to direct it to the correct library location.C:\Python2.7.1\Lib\distutils\cygwincompiler.py
and remove any occurrance of the string -mno-cygwin
. The reason is explained here.CPPFLAGS
environment variable to the MPIR directory, which contains mpir.h
.setup.py
and add the following line in build_extension
method:self.__add_compiler_option(os.environ['CPPFLAGS'])
bash configure
. You should see two lines saying:checking for __gmpz_init in -lgmp... no
checking for __gmpz_init in -lmpir... yes 12. Executepython setup.py build -c mingw32
. You should see no errors. 13. Executepython setup.py test
to verify that everything is fine. 14. Executepython setup.py install
to copy the files into your local Python repository. 15. Alternatively, runpython setup.py bdist_wininst
to create an installer.
I really hate all the various hacks, and I'd love to hear if they can be avoided.