mirror of
https://github.com/correl/dotfiles.git
synced 2024-11-23 11:09:50 +00:00
60 lines
1.7 KiB
Bash
60 lines
1.7 KiB
Bash
#!/bin/bash
|
|
# Description: The Python programming language
|
|
set -e
|
|
|
|
__PYTHON_VERSION=3.11.4
|
|
|
|
_recipe _path
|
|
_recipe git
|
|
|
|
function _pip {
|
|
local pkg=$1
|
|
if ! pip show $pkg >/dev/null 2>&1; then
|
|
_run "[pip] Install $pkg" pip install $pkg
|
|
else
|
|
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."
|
|
fi
|
|
}
|
|
|
|
case $_PLATFORM in
|
|
darwin)
|
|
_recipe brew
|
|
_brew pyenv
|
|
_brew pyenv-virtualenv
|
|
;;
|
|
arch)
|
|
_recipe _arch
|
|
_pacman pyenv
|
|
_yay pyenv-virtualenv
|
|
;;
|
|
debian)
|
|
_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
|
|
_run "[git] Install pyenv" bash <(curl -q -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)
|
|
else
|
|
_run "[git] Upgrade pyenv" git -C $(pyenv root) pull
|
|
fi
|
|
_path "${HOME}/.pyenv/bin"
|
|
;;
|
|
esac
|
|
|
|
_profile 'eval "$(pyenv init --path)"'
|
|
_profile 'eval "$(pyenv virtualenv-init -)"'
|
|
_profile 'pyenv global $(pyenv versions --bare --skip-aliases | egrep "^(\.?[[:digit:]]+)+$" | sort -rV)'
|
|
|
|
_pyenv $__PYTHON_VERSION
|
|
pyenv global $(pyenv versions --bare --skip-aliases | egrep "^(\.?[[:digit:]]+)+$" | sort -rV)
|