Przeglądaj źródła

Adding install_python_versions from Stocker

Modified the Stocker multi-python Dockerfile to enable it to be
installed on multiple systems, removed Python 2.7 which is apparently
now broken, and added Python 3.8 which has now been released.
master
Nate Bohman 4 lat temu
rodzic
commit
0a6cfea0b0
1 zmienionych plików z 102 dodań i 0 usunięć
  1. +102
    -0
      install_python_versions.sh

+ 102
- 0
install_python_versions.sh Wyświetl plik

@@ -0,0 +1,102 @@
#!/usr/bin/env bash

declare -a py_versions=( \
"2" \
"3" \
"3.5" \
"3.6" \
"3.7" \
"3.8" \
)

if [ -f /etc/os-release ]; then
source /etc/os-release
fi

if which apt > /dev/null; then
apt update -qq
apt -y install \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python-openssl \
git \
graphviz \
libxslt1-dev
fi

if which yum > /dev/null; then
yum -y groupinstall "Development Tools"
yum -y install \
bzip2 \
bzip2-devel \
git \
graphviz \
libffi-devel \
libxslt-devel \
openldap-devel \
openssl-devel \
readline-devel \
sqlite \
sqlite-devel \
xz \
xz-devel \
zlib-devel
fi

if [ ! -d ${HOME}/.pyenv ]; then
git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv
fi

cd ${HOME}/.pyenv
git pull
cd ~-

if [ ! -f ${HOME}/.pyenv/bin/get-pip.py ]; then
wget -O ${HOME}/.pyenv/bin/get-pip.py https://bootstrap.pypa.io/get-pip.py
fi

export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:${PATH}"

if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi

${PYENV_ROOT}/plugins/python-build/install.sh

for short_ver in "${py_versions[@]}"; do
echo "Checking Python ${short_ver}";
if [ -z "${short_ver##*.*}" ]; then
export long_ver=$(pyenv install -l | \
grep -Po "(?<=\s)[0-9\.]+$" | \
grep "${short_ver}." | \
tail -n1);
echo "Installing /usr/local/bin/python${short_ver} (${long_ver}) via pyenv."
if [ "${ID}" == "debian" ]; then
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib python-build ${long_ver} /usr/local/
else
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib64 python-build ${long_ver} /usr/local/
fi
echo "Updating pip, setuptools, and virtualenv in /usr/local/bin/python${short_ver}"
/usr/local/bin/python${short_ver} ${HOME}/.pyenv/bin/get-pip.py
/usr/local/bin/python${short_ver} -m pip install -U pip setuptools virtualenv
else
if [ -f /usr/bin/python${short_ver} ]; then
echo "Updating pip, setuptools, and virtualenv in /usr/bin/python${short_ver}"
/usr/bin/python${short_ver} ${HOME}/.pyenv/bin/get-pip.py
/usr/bin/python${short_ver} -m pip install -U pip setuptools virtualenv
fi
fi
done

Ładowanie…
Anuluj
Zapisz