Skip to content

Instantly share code, notes, and snippets.

@sunfkny
Last active June 16, 2023 06:53
Show Gist options
  • Save sunfkny/d6d65ea2a4a59fc09040f311153a720f to your computer and use it in GitHub Desktop.
Save sunfkny/d6d65ea2a4a59fc09040f311153a720f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
PYTHON_VERSION="3.10.12"
PYTHON_MINOR_VERSION="$(echo $PYTHON_VERSION | cut -d'.' -f 2)"
PYTHON_BUILD_VERSION="$(echo $PYTHON_VERSION | cut -d'.' -f 3)"
yum -y install epel-release
yum -y install gcc zlib zlib-devel libffi libffi-devel readline-devel mysql-devel sqlite-devel
yum -y install wget
if [[ "$(rpm -E %{rhel})" == "7" ]]; then
yum -y install openssl11 openssl11-devel
export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)
elif [[ "$(rpm -E %{rhel})" == "8" ]]; then
yum -y install openssl openssl-devel
export LD_LIBRARY_PATH=/usr/lib64
else
echo "Unsupported CentOS version"
exit 1
fi
cd /root
wget https://registry.npmmirror.com/-/binary/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz -O Python-$PYTHON_VERSION.tgz
tar -xzf Python-$PYTHON_VERSION.tgz
cd /root/Python-$PYTHON_VERSION
./configure --with-ssl --enable-loadable-sqlite-extensions
make -j$(nproc) && make altinstall
alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.$PYTHON_MINOR_VERSION 0
python3 -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment