Here is a step-by-step I've just made up on my CentOS server (the sequence assumes you're not root):
LIBGMP INSTALL
Firstly, setup and install libgmp somewhere in your home directory, as follows:
./configure prefix=$HOME
make
make install prefix=$HOME
This will create a ~/lib, a ~/include and a ~/share directory if not existing already.
Then, add the following line to your .bashrc:
export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH
Do a ". ~/.bashrc" to enforce your changes.
PYCRYPTO BUILD & INSTALL
We need to deal with the install process manually.
Firstly, we may download pycrypto as follows:
Then we need to cheat the configuration "a bit":
cd pycrypto-26
./configure --includedir=$HOME/include
Edit the file cd src/config.h and amend the values for the
definitions:
#define HAVE_DECL_MPZ_POWM 0 instead of 1
#define HAVE_DECL_MPZ_POWM_SEC 1 instead of 0
#define HAVE_LIBGMP 1 instead of 0
Then edit the setup.py file by searching for the keyword "_fastmath"
and ensure that the Extension() declaration looks as per below:
Extension("Crypto.PublicKey._fastmath",
include_dirs=['/home/<yourhome>/include','src/','/usr/include/'],
library_dirs=['/home/<yourhome>/lib'],
libraries=['gmp'],
sources=["src/_fastmath.c"]),
Finally, build pycrypto with:
python setup.py build
You should see somewhere in the trace the following line:
...
building 'Crypto.PublicKey._fastmath' extension
...
You can then do a "python setup.py install" or, if like me you prefer pip:
cd ..
pip install ./pycrypto-2.6
Then you should get no error when executing the following lines from python:
>>> from Crypto.PublicKey import _fastmath
>>> import Crypto.Random
>>> _fastmath.HAVE_DECL_MPZ_POWM_SEC
1