Skip to content

Instantly share code, notes, and snippets.

@cjavad
Created March 14, 2024 16:17
Show Gist options
  • Save cjavad/a0aff53d2ddade4c37c1479e2b9184d5 to your computer and use it in GitHub Desktop.
Save cjavad/a0aff53d2ddade4c37c1479e2b9184d5 to your computer and use it in GitHub Desktop.
#!/bin/bash
VERSION=3.11.8
VERSION_SHORT=3.11
mkdir -p /usr/local/src
cd /usr/local/src
if [ ! -f Python-${VERSION}.tgz ]; then
wget -O Python-${VERSION}.tgz https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz
fi
tar xzf Python-${VERSION}.tgz
cd Python-${VERSION}
if [ ! -f python ]; then
./configure --enable-optimizations --with-ensurepip=install --prefix=/usr/local --enable-shared --with-lto --enable-ipv6 --with-system-expat --with-system-ffi --with-threads --with-computed-gotos --enable-loadable-sqlite-extensions
fi
echo "### make altinstall"
sudo make altinstall
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python${VERSION_SHORT} 1
echo "### install pip"
/usr/local/bin/python${VERSION_SHORT} -m pip install --upgrade pip
sudo update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip${VERSION_SHORT} 1
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment