Last active
July 1, 2026 03:07
-
-
Save Nexarian/30f57923c2db7dacc69fbfe9dbb4a461 to your computer and use it in GitHub Desktop.
Build Python
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
| export PYTHON_VERSION=3.14.6 | |
| sudo apt-get install -y curl gcc libbz2-dev libev-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev wget zlib1g-dev libgdbm-compat-dev build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev checkinstall libncursesw5-dev lzma-dev lcov libgd-perl libperlio-gzip-perl lzma | |
| cd ~ | |
| curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz | |
| tar -xvzf Python-${PYTHON_VERSION}.tgz | |
| # Alternatively, you an eliminate the prefix parameter and use `sudo make altinstall` to install it in your home directory. | |
| cd ~/Python-${PYTHON_VERSION} | |
| ./configure \ | |
| --prefix=/opt/python/${PYTHON_VERSION} \ | |
| --disable-gil \ | |
| --enable-shared \ | |
| --enable-optimizations \ | |
| --enable-ipv6 \ | |
| CFLAGS="--coverage" \ | |
| LDFLAGS="-lgcov -Wl,-rpath=/opt/python/${PYTHON_VERSION}/lib -Wl,--disable-new-dtags" | |
| make -j $(nproc) | |
| sudo make install | |
| cd ~ | |
| PYTHON_EXEC=/opt/python/${PYTHON_VERSION}/bin/python3 | |
| pip install --upgrade pip # Yes skipping $PYTHON_EXEC | |
| $PYTHON_EXEC -m pip install virtualenv | |
| $PYTHON_EXEC -m virtualenv --python="$PYTHON_EXEC" venv | |
| source venv/bin/activate | |
| python --version # Should equal what you set in $PYTHON_VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment