2020-12-26 12:29:24 -08:00
|
|
|
#!/bin/bash
|
2021-07-05 09:37:32 -07:00
|
|
|
|
2021-10-28 13:14:41 -07:00
|
|
|
use_pyenv() {
|
2021-07-05 09:37:32 -07:00
|
|
|
if command -v pyenv >/dev/null 2>&1; then
|
2021-10-28 13:14:41 -07:00
|
|
|
export PYENV_ROOT="/opt/python/pyenv"
|
|
|
|
export PYENV_VERSION=${PYENV_VERSION:-3.8.7}
|
|
|
|
eval "$(pyenv init -)"
|
|
|
|
eval "$(pyenv virtualenv-init -)"
|
2021-07-05 09:37:32 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-01-30 11:45:46 -08:00
|
|
|
# TODO make alias generating function for versions of python
|
2022-01-13 10:23:49 -08:00
|
|
|
alias python3x="sudo -H python3 -m"
|
|
|
|
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"
|
2020-11-20 15:48:57 -08:00
|
|
|
alias pipu="pipx upgrade"
|
|
|
|
alias pipua="pipx upgrade-all"
|
|
|
|
alias pipupip="pipx upgrade pipx"
|
|
|
|
alias pipi="pipx install"
|
2021-10-28 13:14:41 -07:00
|
|
|
alias pipr="pipx uninstall"
|
2020-11-20 15:48:57 -08:00
|
|
|
alias pipl="pipx list"
|
|
|
|
alias piplv="pipx list --verbose"
|
2020-12-26 12:29:24 -08:00
|
|
|
|
2021-01-30 11:45:46 -08:00
|
|
|
path_append "/opt/python/bin"
|
|
|
|
|
2021-07-05 09:37:32 -07:00
|
|
|
if command -v pipx >/dev/null 2>&1; then
|
2021-10-28 13:14:41 -07:00
|
|
|
path_append "/opt/python/apps/bin"
|
|
|
|
export PIPX_HOME=/opt/python/apps
|
|
|
|
export PIPX_BIN_DIR=$PIPX_HOME/bin
|
2021-07-05 09:37:32 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
[[ $USE_PYENV ]] && use_pyenv
|
2020-12-26 12:29:24 -08:00
|
|
|
|
2021-10-28 13:14:41 -07:00
|
|
|
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
|
2020-12-26 12:29:24 -08:00
|
|
|
}
|