Compiling Python

Download the Python source code of the corresponding version from https://www.python.org/downloads/source/.

Take Python 3.8.17 as an example. Run the following commands to compile and install Python:

# Decompress the source code file and go to the directory.
tar -xvf Python-3.8.17.tgz
cd Python-3.8.17

# Configure the compilation environment (the BiSheng compiler needs to be pre-installed).
export CC=clang
export CXX=clang++

# Compile and install Python (<install_path> indicates the absolute path of the Python installation directory.)
mkdir -p <install_path>
./configure --prefix=<install_path> --with-lto --enable-optimizations
make -j
make install

After the compilation is complete, the python3 and pip3 executable files for compilation optimization are generated in the <install_path>/bin directory.