Skip to content

Building Python 3.x

linuxonz edited this page Oct 24, 2024 · 65 revisions

Building Python 3.13.x

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

  • RHEL (8.8, 8.10) have 3.12.3
  • RHEL (9.2, 9.4) have 3.12.1
  • SLES 15 SP5 has 3.12.3
  • SLES 15 SP6 has 3.12.4
  • Ubuntu 20.04 has 3.9.5
  • Ubuntu 22.04 has 3.11.0
  • Ubuntu 24.04 has 3.12.3

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

  • RHEL (8.8, 8.10, 9.2, 9.4)
  • SLES (15 SP5, 15 SP6)
  • Ubuntu (20.04, 22.04, 24.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.

1: Build and Install Python 3.13.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.13.0/build_python3.sh

# Build Python
bash build_python3.sh  [Provide -t option for executing build with tests] 

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 (8.8, 8.10, 9.2, 9.4)

    sudo yum install -y bzip2-devel gcc gcc-c++ gdbm-devel libdb-devel libffi-devel libuuid-devel make ncurses-devel openssl-devel tar tk-devel wget xz zlib-devel diffutils xz-devel patch
  • SLES (15 SP5, 15 SP6)

    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 tar tk-devel wget xz-devel zlib-devel gzip 
  • Ubuntu (20.04, 22.04, 24.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 patch

1.3. Download source code

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

1.5. Configure the build

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

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

For instance,

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

1.6. Build the source and install the binaries

cd $SOURCE_ROOT/Python-3.13.0
make
sudo make install

1.7. Verify Python3 version

python3 -V

The output should be:

Python 3.13.0

2: Testing (Optional)

2.1. Run the functional verification test suites

cd $SOURCE_ROOT/Python-3.13.0

Run the test suites

make test

2.2. Make verbose test suite

cd $SOURCE_ROOT/Python-3.13.0
make test TESTOPTS="-v test_<suite_name>"

For instance,

cd $SOURCE_ROOT/Python-3.13.0
make test TESTOPTS="-v test_pty"

Note: Following python test case has been observed to fail intermittently. It should pass on rerun.

  • test_pty

References:

Clone this wiki locally