GCC-9.3.0 and [OpenMPI-3.1.6](https: //qiita.com/yonedat/items/78baf03597fe2341fbf8) and [OpenMPI-3.1.6](https://s: Based on //qiita.com/yonedat/items/d4a764a9a527364ac954), this time I would like to build Python-3.8.5 with a stray build and add mpi4py for parallelization.
Download Python, OpenSSL, and libffi.
-https://sourceware.org/libffi/ -https://github.com/openssl/openssl -https://www.python.org/downloads/source/
The versions used this time are libffi-3.3, openssl-1.1.1g, and python-3.8.5. I could build Python-3.8.5 without pre-building libffi and OpenSSL, but I get an OpenSSL error when piping. If you search for "pip OpenSSL" etc., you will find various things, but it seems that you need a new version of OpenSSL from Python 3.7. Also, by installing a new OpenSSL, numpy etc. can be entered with pip, but mpi4py will generate an error of "ModuleNotFoundError: No module named'_ctypes'" at the time of pip. This seems to be solved by installing libffi, but there seems to be a bug that you can not link with libffi if you build Python-3.8.5 as it is.
I tried to build OpenSSL with GCC-9.3.0, but for some reason I got an error, so I built it with the default GCC-4.8.5 for the time being.
tar xzvf openssl-OpenSSL_1_1_1g.tar.gz
cd openssl-OpenSSL_1_1_1g
./config --prefix=$HOME/tools/OpenSSL-1.1.1g shared zlib enable-tls1_3
make -j 24
make install
After installing OpenSSL, add the following to .bash_profile.
PATH=$HOME/tools/OpenSSL-1.1.1g/bin:$PATH
LD_LIBRARY_PATH=$HOME/tools/OpenSSL-1.1.1g/lib:LD_LIBRARY_PATH
As with OpenSSL, I got an error when trying to build with GCC-9.3.0. I think there is probably a problem with the path settings, but I will consider it later. For the time being, let's build it as it is with GCC-4.8.5 which was included as standard.
tar -zxvf libffi-3.3.tar.gz
mv libffi-3.3 libffi_work
cd libffi_work
mkdir build
cd build
../configure --prefix=$HOME/tools/libffi-3.3
make -j 24
make install
After the installation of libffi is completed, I added the following to .bash_profile.
export LD_LIBRARY_PATH=$HOME/tools/libffi-3.3/lib64:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$HOME/tools/libffi-3.3/lib/pkgconfig:$PKG_CONFIG_PATH
As mentioned above, if you do not install OpenSSL and libffi in advance, an error will occur when piping after installing Python, but there seems to be a bug that you can not link with libffi when building Python. Modify for 4 files of Makefile.pre.in, configure, configure.ac, setup.py in the top directory after unzipping Python. There was commits / 62384c971db4a8c309e2a95764f06e7bf601c014), so correct it and save it by overwriting. After that, install according to the following procedure.
tar Jxfv Python-3.8.5.tar.xz
mv Python-3.8.5 py_work
cd py_work
mkdir build
cd build
../configure --prefix=$HOME/tools/Python-3.8.5 --enable-shared --with-openssl=$HOME/tools/OpenSSL-1.1.1g --with-ensurepip LDFLAGS=-Wl,-rpath,$HOME/tools/Python-3.8.5/lib CC=$HOME/tools/gcc-9.3.0/bin/gcc CPP=$HOME/tools/gcc-9.3.0/bin/cpp CPPFLAGS="-I$HOME/tools/gcc-9.3.0/include -I$HOME/tools/OpenSSL-1.1.1g/include -I$HOME/tools/libffi-3.3/include"
make j 36
make install
After the installation is complete, add the following to .bash_profile.
PYTHON_HOME=$HOME/tools/Python-3.8.5
PYTHONPATH=$PYTHON_HOME/lib/python3.8/site-packages
PATH=$PYTHON_HOME/bin:$PATH
export PYTHON_HOME PYTHONPATH PATH
I created a symbolic link as shown below.
cd ~/bin/
ln -s ~/tools/Python-3.8.5/bin/python3.8 python38
Also, try adding numpy and mpi4py.
cd ~/tools/Python-3.8.5/bin
pip3 install numpy
pip3 install mpi4py
With the above, Python-3.8.5 based on GCC-9.3.0 and OpenMPI-3.1.6 can be built with a stray build. For the time being, numpy and mpi4py seem to work without problems.
Recommended Posts