dotfiles/recipes/python

50 lines
1.4 KiB
Text
Raw Normal View History

#!/bin/bash
2018-04-12 18:07:33 +00:00
# Description: The Python programming language
set -e
2020-04-14 19:17:38 +00:00
__PYTHON_VERSION=3.8.2
_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, skiping."
fi
}
case $_PLATFORM in
darwin)
_recipe brew
_brew pyenv
_brew pyenv-virtualenv
;;
*)
_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)
else
_run "[git] Upgrade pyenv" git -C $(pyenv root) pull
fi
_path "${HOME}/.pyenv/bin"
;;
esac
_profile 'eval "$(pyenv init -)"'
_profile 'eval "$(pyenv virtualenv-init -)"'
_profile 'pyenv global $(pyenv versions --bare --skip-aliases | egrep "^(\.?[[:digit:]]+)+$" | sort -rV)'
if ! [ -d ~/.pyenv/versions/${__PYTHON_VERSION} ]; then
_run "[pyenv] Install python ${__PYTHON_VERSION}" pyenv install ${__PYTHON_VERSION}
fi
pyenv global ${__PYTHON_VERSION}