How to compile pycrypto 2.4.1 (python 3.2.2 for Windows 7 x64)

How to compile pycrypto 2.4.1 (python 3.2.2 for Windows 7 x64)

This note is a variation of note that talks about compiling cx_Oracle module for python 3.2 (64-bit), but this time around I wanted to try out pycrypto module v2.4.1 that supports python 3. Let me say that I first tried to build pycrypto with MinGW using TLDR experimental installation package for Windows x64. Making long story short, it was a bummer (I hit several errors that I didn’t know how to resolve), I didn’t even try if 32-bit module could be compiled with MinGW. Anyway, I believe sticking with VC 2008 and bulky SDK (over 5GB of installed SW!) is inevitable, at least for me. Here’re the steps that I followed….

My target platform for the pycrypto build was Windows 7 Professional x64 (SP1) with 64-bit python 3.2.2.

1) Download and install Visual Studio Express 2008 SP1 from MS site

It’s mandatory to build python modules with VC 2008, because this is the compiler that was used
to build python 3.2. Note that I installed default components of Visual Studio 2008 in default location.

2) Because Visual Studio Express 2008 SP1 doesn’t ship with 64-bit compiler, download
and install Windows SDK for Windows 7 and .NET 3.5 SP1
.

Again, don’t be tempted to install newer Windows SDK for Windows 7 and .NET 4, it must be older SDK (released in 2009). I left all installation options at default.

3) Download and install 64-bit python 3.2.2

Ok, this is obvious step. :-)

4) Download pycrypto 2.4.1

After you download unzip pycrypto-2.4.1.tar.gz in some temporary directory, such as C:Temp

5) Prepare command shell for 64-bit compiler:

Start -> Run

%comspec% /k ""C:Program Files (x86)Microsoft Visual Studio 9.0VCinvcvars64.bat""

Then enter the following on the command line:

SET PATH=C:PYTHON32;%PATH%

SET PYTHONHOME=C:Python32

cd C:Temppycrypto-2.4.1

python setup.py build

python setup.py bdist_wininst

In dist directory you’ll find installation file:

pycrypto-2.4.1.win-amd64-py3.2.exe

After you install pycrypto, check that it works:

cmd> python
>>> import Crypto
>>> print(Crypto.__version__)
2.4.1

原文地址:https://www.cnblogs.com/phirothing/p/4279976.html