Last active
November 12, 2022 02:43
-
-
Save EnigmaCurry/5be1a85965097c7f13220732111f0aeb to your computer and use it in GitHub Desktop.
Script to build python as a user without root access
This file contains 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/bash | |
# Script to install Python from source code as an unprivileged user. | |
# Update PYTHON_VERSION to the version you want to install. | |
# Update PYTHON_PREFIX to be where you want it installed. | |
# You can pass both of these as environment variables or just hardcode them. | |
# You can paste this whole file into your terminal as-is and go. | |
PYTHON_VERSION=${PYTHON_VERSION:-3.11.0} | |
PYTHON_PREFIX=${PYTHON_PREFIX:-${HOME}/python-${PYTHON_VERSION}} | |
( | |
set -e | |
check_installed(){ for prog in "$@"; do which ${prog} >/dev/null || (echo "You must install ${prog}" && exit 1); done; } | |
check_installed wget tar gcc make | |
wget --continue https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz | |
tar xfv Python-${PYTHON_VERSION}.tgz | |
cd Python-${PYTHON_VERSION} | |
./configure --prefix=${PYTHON_PREFIX} --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi | |
make -j "$(nproc)" | |
make altinstall | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment