It's a type of Planche
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

install_python_versions.sh 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env bash
  2. declare -a py_versions=( \
  3. "3" \
  4. "3.5" \
  5. "3.6" \
  6. "3.7" \
  7. "3.8" \
  8. )
  9. if [ -f /etc/os-release ]; then
  10. source /etc/os-release
  11. fi
  12. if which apt > /dev/null; then
  13. apt update -qq
  14. apt -y install \
  15. make \
  16. build-essential \
  17. libssl-dev \
  18. zlib1g-dev \
  19. libbz2-dev \
  20. libreadline-dev \
  21. libsqlite3-dev \
  22. wget \
  23. curl \
  24. llvm \
  25. libncurses5-dev \
  26. libncursesw5-dev \
  27. xz-utils \
  28. tk-dev \
  29. libffi-dev \
  30. liblzma-dev \
  31. libxml2-dev \
  32. libxmlsec1-dev \
  33. python3-openssl \
  34. git \
  35. graphviz \
  36. libxslt1-dev
  37. fi
  38. if which yum > /dev/null; then
  39. yum -y groupinstall "Development Tools"
  40. yum -y install \
  41. bzip2 \
  42. bzip2-devel \
  43. git \
  44. graphviz \
  45. libffi-devel \
  46. libxslt-devel \
  47. openldap-devel \
  48. openssl-devel \
  49. readline-devel \
  50. sqlite \
  51. sqlite-devel \
  52. xz \
  53. xz-devel \
  54. zlib-devel
  55. fi
  56. if [ ! -d ${HOME}/.pyenv ]; then
  57. git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv
  58. fi
  59. cd ${HOME}/.pyenv
  60. git pull
  61. cd ~-
  62. if [ ! -f ${HOME}/.pyenv/bin/get-pip.py ]; then
  63. wget -O ${HOME}/.pyenv/bin/get-pip.py https://bootstrap.pypa.io/get-pip.py
  64. fi
  65. export PYENV_ROOT="${HOME}/.pyenv"
  66. export PATH="${PYENV_ROOT}/bin:${PATH}"
  67. if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi
  68. ${PYENV_ROOT}/plugins/python-build/install.sh
  69. for short_ver in "${py_versions[@]}"; do
  70. echo "Checking Python ${short_ver}";
  71. if [ -z "${short_ver##*.*}" ]; then
  72. export long_ver=$(pyenv install -l | \
  73. grep -Po "(?<=\s)[0-9\.]+$" | \
  74. grep "${short_ver}." | \
  75. tail -n1);
  76. echo "Installing /usr/local/bin/python${short_ver} (${long_ver}) via pyenv."
  77. if [ "${ID}" == "debian" ]; then
  78. CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib python-build ${long_ver} /usr/local/
  79. else
  80. CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib64 python-build ${long_ver} /usr/local/
  81. fi
  82. echo "Updating pip, setuptools, and virtualenv in /usr/local/bin/python${short_ver}"
  83. /usr/local/bin/python${short_ver} ${HOME}/.pyenv/bin/get-pip.py
  84. /usr/local/bin/python${short_ver} -m pip install -U pip setuptools virtualenv
  85. else
  86. if [ -f /usr/bin/python${short_ver} ]; then
  87. echo "Updating pip, setuptools, and virtualenv in /usr/bin/python${short_ver}"
  88. /usr/bin/python${short_ver} ${HOME}/.pyenv/bin/get-pip.py
  89. /usr/bin/python${short_ver} -m pip install -U pip setuptools virtualenv
  90. fi
  91. fi
  92. done