Stray build Python-3.8.5 on CentOS without root privileges

Introduction

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.

Preparation

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.

Build and install OpenSSL

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

Build and install libffi

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

Build and install Python-3.8.5

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

Stray build Python-3.8.5 on CentOS without root privileges
Build a python3 environment on CentOS7
Installation from python, numpy, scipy sources without root privileges on Linux
Build a python environment with ansible on centos6
Install Python3.4 on CentOS 6.6
Install the python module with pip on a server without root privileges
Install Python 2.7.3 on CentOS 5.4
build Python on Ubuntu
Stray build of Python 3 on Sakura's rental server (Note)
Install Python 3.8 on CentOS 7 (SCL)
Build Python environment on Windows
Build python environment on windows
Install Python 3.8 on CentOS 8 (AppStream)
Notes on installing Python on CentOS
Install CaboCha without root privileges.
Build a python environment on CentOS 7.7 for your home server
docker build python based on alpine
[Linux] Install Python 3 without administrator privileges
Set up Python environment on CentOS
Create a python environment on centos
Install Python on CentOS using Pyenv
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Install Python on CentOS using pyenv
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a python environment on MacOS (Catallina)
A memo with Python2.7 and Python3 on CentOS
Build CGI Server running on Python 3 on Docker
Connecting from python to MySQL on CentOS 6.4
Use without installing python 2.x on Windows
Build Python environment with Anaconda on Mac
Build WordPress on CentOS 8 in LAMP environment
Build jupyter notebook on remote server (CentOS)
Build a Python + OpenCV environment on Cloud9
Build python 1.0
Build CentOS 8 on ESXi 6.7 with minimal configuration
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Simply build a Python 3 execution environment on Windows
Build a Python environment on Mac (Mountain Lion)
[Ansible] Install dnf on Centos7 with Python3 interpreter
Build a Python development environment on your Mac
Build a simple Python virtual environment without pyenv
Build Python3 + flask environment on GCP Compute Engine
Run Flask on CentOS with python3.4, Gunicorn + Nginx.
Build a Python development environment on Raspberry Pi
Python2.7 + CentOS7 + OpenCV3
Python on Windows
twitter on python3
python on mac
Python on Windbg
CentOS8 --Install --Python3
Build CentOS8 LAMP
Initial settings for using Python3.8 and pip on CentOS8
[CentOS 7.3] Build an FTP server on the ESXi host
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Install Python3 on Mac and build environment [Definitive Edition]
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Build a machine learning Python environment on Mac OS
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
Build a GVim-based Python development environment on Windows 10 (1) Installation