2018-02-28 06:28:08 +00:00
|
|
|
#!/bin/bash
|
2018-04-12 18:07:33 +00:00
|
|
|
# Description: The Python programming language
|
2018-02-28 06:28:08 +00:00
|
|
|
set -e
|
|
|
|
|
2023-08-30 16:18:41 +00:00
|
|
|
__PYTHON_VERSION=3.11.4
|
2018-02-28 06:28:08 +00:00
|
|
|
|
2018-02-28 15:07:41 +00:00
|
|
|
_recipe _path
|
2018-09-09 04:46:11 +00:00
|
|
|
_recipe git
|
2018-02-28 15:07:41 +00:00
|
|
|
|
2020-01-02 15:22:15 +00:00
|
|
|
function _pip {
|
|
|
|
local pkg=$1
|
|
|
|
if ! pip show $pkg >/dev/null 2>&1; then
|
|
|
|
_run "[pip] Install $pkg" pip install $pkg
|
|
|
|
else
|
2021-01-22 00:21:46 +00:00
|
|
|
echo "[pip] $pkg is already installed, skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _pyenv {
|
|
|
|
local version=$1
|
|
|
|
if ! pyenv versions --bare | grep -q "^$version$"; then
|
|
|
|
_run "[pyenv] Install Python $version" pyenv install $version
|
|
|
|
else
|
|
|
|
echo "[pyenv] Python $version is already installed, skipping."
|
2020-01-02 15:22:15 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-02-28 06:28:08 +00:00
|
|
|
case $_PLATFORM in
|
|
|
|
darwin)
|
|
|
|
_recipe brew
|
|
|
|
_brew pyenv
|
|
|
|
_brew pyenv-virtualenv
|
|
|
|
;;
|
2021-02-05 00:05:51 +00:00
|
|
|
arch)
|
|
|
|
_recipe _arch
|
|
|
|
_pacman pyenv
|
|
|
|
_yay pyenv-virtualenv
|
|
|
|
;;
|
|
|
|
debian)
|
2018-02-28 06:28:08 +00:00
|
|
|
_recipe _apt
|
|
|
|
for dep in make build-essential libssl-dev zlib1g-dev libbz2-dev \
|
|
|
|
libreadline-dev libsqlite3-dev wget curl llvm \
|
|
|
|
libncurses5-dev libncursesw5-dev xz-utils tk-dev; do
|
|
|
|
_apt $dep
|
|
|
|
done
|
|
|
|
if [ ! -d ~/.pyenv ]; then
|
2020-06-25 02:00:25 +00:00
|
|
|
_run "[git] Install pyenv" bash <(curl -q -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)
|
2018-09-09 04:46:11 +00:00
|
|
|
else
|
|
|
|
_run "[git] Upgrade pyenv" git -C $(pyenv root) pull
|
2018-02-28 06:28:08 +00:00
|
|
|
fi
|
|
|
|
_path "${HOME}/.pyenv/bin"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-12-24 22:16:21 +00:00
|
|
|
_profile 'eval "$(pyenv init --path)"'
|
2018-02-28 15:07:41 +00:00
|
|
|
_profile 'eval "$(pyenv virtualenv-init -)"'
|
2018-08-30 17:35:21 +00:00
|
|
|
_profile 'pyenv global $(pyenv versions --bare --skip-aliases | egrep "^(\.?[[:digit:]]+)+$" | sort -rV)'
|
|
|
|
|
2021-01-22 00:21:46 +00:00
|
|
|
_pyenv $__PYTHON_VERSION
|
|
|
|
pyenv global $(pyenv versions --bare --skip-aliases | egrep "^(\.?[[:digit:]]+)+$" | sort -rV)
|