C'est ainsi que j'ai réussi à construire et à installer latéralement Python 3.5.2 en 32 bits sur Ubuntu 16, la version 64 bits étant déjà installée par apt :
# Some prerequisites:
sudo apt install libffi-dev:i386
sudo apt install libssl1.0.0:i386
sudo apt install libssl-dev:i386
sudo apt-get install libncurses-dev:i386 libreadline-dev:i386 # for command history to work in Python terminal
sudo apt-get install binutils-multiarch
sudo ln -s /usr/bin/readelf /usr/bin/i386-linux-gnu-readelf
# Going to be installed to /opt/python-3.5.2-i386
ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes \
CFLAGS=-m32 CXXFLAGS=-m32 \
LDFLAGS="-m32 -L/lib32 -L/usr/lib32 -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu -Wl,-rpath,/lib32 -Wl,-rpath,/usr/lib32 -Wl,-rpath,/lib/i386-linux-gnu -Wl,-rpath,/usr/lib/i386-linux-gnu" \
./configure --build=x86_64-linux-gnu --host=i386-linux-gnu \
--enable-ipv6 --prefix=/opt/python-3.5.2-i386 --with-system-ffi
make
sudo make install
# The following may be needed to build some additional extensions, which are statically
# built-in in existing python3 intallation on host and won't be built otherwise
sudo PATH=/opt/python-3.5.2-i386/bin:$PATH make
sudo PATH=/opt/python-3.5.2-i386/bin:$PATH make install
Après ça :
~$ python3 -V
Python 3.5.2
~$ python3 -c 'import struct; print(struct.calcsize("P") * 8)'
64
~$ /opt/python-3.5.2-i386/bin/python3 -V
Python 3.5.2
~$ /opt/python-3.5.2-i386/bin/python3 -c 'import struct; print(struct.calcsize("P") * 8)'
32