shell-host/install/lang/python/python.lib

60 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/bash
command -v python3 >/dev/null 2>&1 || return
alias python3x="sudo -H python3 -m"
if command -v pyenv >/dev/null 2>&1; then
use_pyenv() {
if command -v pyenv >/dev/null 2>&1; then
export PYENV_ROOT="/opt/python/pyenv"
export PYENV_VERSION=${PYENV_VERSION:-3.8.7}
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
}
[[ $USE_PYENV ]] && use_pyenv
fi
if command -v pip3 >/dev/null 2>&1; then
module_load system-path
alias spip="sudo -H python3 -m pip"
alias spipi="sudo -H python3 -m pip install"
alias spipiu="sudo -H python3 -m pip install -U"
alias spipl="sudo -H python3 -m pip list"
alias spiplo="sudo -H python3 -m pip list --outdated"
alias pip3="sudo -H python3 -m pip"
path_append "/opt/python/bin"
spipua() {
module_load confirm
echo upgrading all base python packages - requires sudo access
# sudo -H python3.8 -m pip list --outdated
local List
local Ver=${1:-3.8}
List="$(sudo -H python$Ver -m pip list -o --format columns)"
echo "$List"
confirm "ATTENTION: upgrade all these packages at once??" || return 0
echo "$List" | cut -d' ' -f1 | xargs -n1 sudo -H python$Ver -m pip install -U
}
if command -v pipx >/dev/null 2>&1; then
path_append "/opt/python/apps/bin"
export PIPX_HOME=/opt/python/apps
export PIPX_BIN_DIR=$PIPX_HOME/bin
alias pipu="pipx upgrade"
alias pipua="pipx upgrade-all"
alias pipupip="pipx upgrade pipx"
alias pipi="pipx install"
alias pipr="pipx uninstall"
alias pipl="pipx list"
alias piplv="pipx list --verbose"
fi
fi