Last active
March 24, 2022 06:03
-
-
Save grammy-jiang/bd07d16412b0f250063b703cf988190b to your computer and use it in GitHub Desktop.
Install pyenv and python 3.8.2
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
# Origianl url: | |
# https://gist.githubusercontent.com/grammy-jiang/bd07d16412b0f250063b703cf988190b/raw | |
# Shorten url: | |
# https://git.io/JfLCd | |
# install pyenv and python 3.9.6 | |
# Usage: | |
# foo@bar:~$ curl --location --show-error --silent https://git.io/JfLCd | bash -s - 3.9.6 | |
set -x | |
if [ -z "$1" ]; then | |
echo "No python version supplied, use defautl version 3.9.6 instead." | |
PYTHON_VERSION="3.9.6" | |
else | |
echo "Python version $1 is going to be installed." | |
PYTHON_VERSION=$1 | |
fi | |
sudo -s -- <<EOF | |
apt update | |
if ! [ -x "$(command -v curl)" ]; then | |
apt install --yes curl | |
fi | |
if ! [ -x "$(command -v git)" ]; then | |
apt install --yes git | |
fi | |
EOF | |
if ! [ -x "$(command -v pyenv)" ]; then | |
curl https://pyenv.run | bash | |
echo " | |
export PATH=\"\$HOME/.pyenv/bin:\$PATH\" | |
eval \"\$(pyenv init -)\" | |
eval \"\$(pyenv virtualenv-init -)\" | |
export PYTHON_CONFIGURE_OPTS=\"--enable-shared\"" | tee -a ~/.bashrc > /dev/null | |
export PATH="$HOME/.pyenv/bin:$PATH" | |
eval "$(pyenv init -)" | |
eval "$(pyenv virtualenv-init -)" | |
export PYTHON_CONFIGURE_OPTS="--enable-shared" | |
else | |
pyenv update | |
fi | |
sudo -s -- <<EOF | |
apt install --yes build-essential libbz2-dev libffi-dev libgdbm-compat-dev libgdbm-dev liblzma-dev libreadline-dev libsqlite3-dev libssl-dev zlib1g-dev tk-dev uuid-dev | |
EOF | |
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYTHON_VERSION | |
echo $PYTHON_VERSION | tee -a ~/.pyenv/version > /dev/null | |
PATH="$PYENV_ROOT/versions/$PYTHON_VERSION/bin:$PATH" pip install -U pip setuptools | |
pyenv versions |
Install dependencies on Fedora:
foo@bar:~$ sudo dnf install -y \
bzip2-devel \
gdbm-devel \
libffi-devel \
libnsl2-devel \
libuuid-devel \
openssl-devel \
readline-devel \
sqlite-devel \
tk-devel \
zlib-devel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script only supports Ubuntu now.
Usage
Test in the docker image
ubuntu:latest
TODO