Last active
May 20, 2022 11:02
-
-
Save brosahay/1cf580bf76b97686e6f951b1bb0275e6 to your computer and use it in GitHub Desktop.
Python 3.9 on Ubuntu 22.04 LTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Helper file for supporting Ubuntu 22.04LTS for MATTER(formerly CHIP) development | |
# Install build dependencies | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev | |
# Download and extract source | |
cd /tmp/ | |
wget https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tgz | |
tar xzf Python-3.9.12.tgz | |
cd Python-3.9.12 | |
# Configure and build | |
sudo ./configure --prefix=/opt/python/3.9.12/ --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi --enable-shared | |
sudo make -j "$(nproc)" | |
sudo ./python3.9 -m test -j "$(nproc)" | |
sudo make altinstall | |
sudo rm /tmp/Python-3.9.12.tgz | |
# Install pip | |
sudo /opt/python/3.9.12/bin/python3.9 -m pip install --upgrade pip setuptools wheel | |
# Easy usage | |
sudo ln -s /opt/python/3.9.12/bin/python3.9 /opt/python/3.9.12/bin/python3 | |
sudo ln -s /opt/python/3.9.12/bin/python3.9 /opt/python/3.9.12/bin/python | |
sudo ln -s /opt/python/3.9.12/bin/pip3.9 /opt/python/3.9.12/bin/pip3 | |
sudo ln -s /opt/python/3.9.12/bin/pip3.9 /opt/python/3.9.12/bin/pip | |
sudo ln -s /opt/python/3.9.12/bin/pydoc3.9 /opt/python/3.9.12/bin/pydoc | |
sudo ln -s /opt/python/3.9.12/bin/idle3.9 /opt/python/3.9.12/bin/idle | |
sudo ln -s /opt/python/3.9.12/bin/python3.9-config /opt/python/3.9.12/bin/python-config | |
# Alternate install | |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 | |
sudo update-alternatives --install /usr/bin/python python /opt/python/3.9.12/python3.9 2 | |
# (Optional) | |
sudo update-alternatives --config python | |
python --version | |
## REFERENCES | |
## https://www.build-python-from-source.com/ | |
## https://towardsdatascience.com/installing-multiple-alternative-versions-of-python-on-ubuntu-20-04-237be5177474 | |
## https://www.linuxcapable.com/how-to-install-python-3-9-on-ubuntu-22-04-lts/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment