Building Python 3.7.x - linux-on-ibm-z/docs GitHub Wiki

Building Python 3.7.x

Below versions of Python are available in respective distributions at the time of creation of these build instructions:

  • SLES 12 SP5 has 3.4.10
  • SLES 15 SP1, 15 SP2 has 3.6.10
  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2) has 3.6.8
  • Ubuntu 18.04 has 3.7.5

The instructions provided below specify the steps to build Python version 3.7.4 on Linux on IBM Z for following distributions:

  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2)
  • SLES (12 SP5, 15 SP1, 15 SP2)
  • Ubuntu (18.04, 20.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Build and install Python 3.7.x

1.1) Build using script

If you want to build Python using manual steps, go to STEP 1.2.

Use the following commands to build Python using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Python3/3.7.4/build_python3.sh

# Build Python
bash build_python3.sh   

If the build completes successfully, go to STEP 1.7. In case of error, check logs for more details or go to STEP 1.2 to follow manual build steps.

1.2) Install dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.6, 7.7, 7.8)

    sudo yum install -y bzip2-devel gcc gcc-c++ gdbm-devel libdb-devel libffi-devel libuuid-devel make ncurses-devel openssl-devel readline-devel sqlite-devel tar tk-devel wget xz xz-devel zlib-devel
  • RHEL (8.1, 8.2)

    sudo yum install -y bzip2-devel gcc gcc-c++ gdbm-devel libdb libffi-devel libuuid make ncurses openssl readline sqlite tar tk wget xz xz zlib-devel glibc-langpack-en openssl-devel
  • SLES 12 SP5

    sudo zypper install -y gawk gcc gcc-c++ gdbm-devel libbz2-devel libdb-4_8-devel libffi48-devel libopenssl-devel libuuid-devel make ncurses-devel readline-devel sqlite3-devel tar tk-devel wget xz-devel zlib-devel
  • SLES (15 SP1, 15 SP2)

    sudo zypper install -y gawk gcc gcc-c++ gdbm-devel libbz2-devel libdb-4_8-devel libffi-devel libnsl-devel libopenssl-devel libuuid-devel make ncurses-devel readline-devel sqlite3-devel tar tk-devel wget xz-devel zlib-devel
  • Ubuntu (18.04, 20.04)

    sudo apt-get update
    sudo apt-get install -y gcc g++ libbz2-dev libdb-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev libssl-dev make tar tk-dev uuid-dev wget xz-utils zlib1g-dev

1.3) Download source code

cd $SOURCE_ROOT
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
tar -xzf Python-3.7.4.tgz

1.4) Configure the build

Skipping the prefix will result in installing Python in default location /usr/local.

cd $SOURCE_ROOT/Python-3.7.4
./configure --prefix=<build-location> --exec-prefix=<build-location>

For instance,

cd $SOURCE_ROOT/Python-3.7.4
./configure --prefix=/usr/local --exec-prefix=/usr/local

1.5) Build the source and install the binaries

cd $SOURCE_ROOT/Python-3.7.4
make
sudo make install 

1.6) Verify Python3

python3 -V

Step 2: Testing (Optional)

2.1) Run the functional verification test suites

cd $SOURCE_ROOT/Python-3.7.4
make test

Note: User can ignore intermittent test-case failures as it does not affect the functionality.

2.2) Make verbose test suite

cd $SOURCE_ROOT/Python-3.7.4
./python Lib/test/regrtest.py -v test_<suite_name>

For instance,

cd $SOURCE_ROOT/Python-3.7.4
./python Lib/test/regrtest.py -v test_posix

References:

Release notes for Python 3.7.4

⚠️ **GitHub.com Fallback** ⚠️