As a follow up, here's an explanation of how to do this without pip or virtualenv. To do it with virtualenv, just place the wrapper scripts in your virtualenv's bin directory:
To build python:
Install python build dependencies (on Centos 6). Make sure to get the i686 packages:
tk-devel, tcl-devel, libX11-devel, libXau-devel, sqlite-devel,
gdbm-devel, readline-devel, zlib-devel, bzip2-devel, openssl-devel,
krb5-devel, ncurses-devel, valgrind-devel, valgrind, libxcb-devel,
libXft-devel, tk
CFLAGS="-g -O2 -m32" LDFLAGS="-m32 -Wl,-rpath,/opt/python/ia32/
lib" ./configure --enable-unicode=ucs4 --enable-shared --prefix=/opt/python/ia32 --with-valgrind
make
make testall
To build numpy:
Install numpy dependencies:
atlas-devel, lapack-devel, blas-devel, libgfortran
Now
you just need to use some compiler wrappers, so the "setup.py build"
command will append the -m32 to flag to every call to the compilers. You
need to wrap gcc and gfortran, and possibly g++ as well. Place the
wrapper scripts and a link to your python executable in a directory,
e.g. ~/bin. You could also use virtualenv to make this easier:
cd ~/bin
ln -sfn /opt/python/ia32/bin/python
touch gcc g++ gfortan
chmod u+x gcc g++ gfortran
Now edit the wrapper scripts:
#### gcc ####
#!/bin/sh
/usr/bin/gcc -m32 "$@"
#### g++ ####
#!/bin/sh
/usr/bin/gcc -m32 "$@"
#### gfotran ####
#!/bin/sh
/usr/bin/gfortan -m32 "$@"
Add ~/bin to the front of your path:
export PATH=$HOME/bin:$PATH
Build numpy:
python setup.py build