Install python packages via pipx.

master
Icedream 2019-11-22 10:22:54 +01:00
parent f0a50e4d80
commit df41c1fc34
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
3 changed files with 37 additions and 2 deletions

View File

@ -1,5 +1,18 @@
#!/bin/zsh
when_binary_available() {
if has_binary "$@"; then
printf '1'
return
fi
printf '0'
return
}
has_binary() {
command -v "$@" >/dev/null 2>&1
}
ZSH_DEBUG="${ZSH_DEBUG:-0}"
ZSH_ALIAS=${ZSH_ALIAS:-1}
@ -7,6 +20,7 @@ ZSH_COMPAT_BASH_COMPLETION=${ZSH_COMPAT_BASH_COMPLETION:-1}
ZSH_CUSTOM=${ZSH_CUSTOM:-1}
ZSH_DEFAULT_TERM=${ZSH_DEFAULT_TERM:-1}
ZSH_GPG_PINENTRY_FIX=${ZSH_GPG_PINENTRY_FIX:-1}
ZSH_PIPX=${ZSH_PIPX:-$(when_binary_available pipx)}
ZSH_POWERLINE="${ZSH_POWERLINE:-1}"
ZSH_PRINT_REBOOT_REQUIRED=${ZSH_PRINT_REBOOT_REQUIRED:-0} # hacky, see below
ZSH_SYNTAX_HIGHLIGHTING="${ZSH_SYNTAX_HIGHLIGHTING:-1}"
@ -48,9 +62,9 @@ log() {
# Compatibility mode for completions
section "compat: bash completion"
if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ]; then
if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ] || [ $ZSH_PIPX -gt 0 ]; then
log "Enabling compatibility for bash completion scripts..."
autoload bashcompinit
autoload -U bashcompinit
bashcompinit
fi
section_end
@ -80,6 +94,13 @@ if [ -d "$HOME/Library/Python/2.7" ]; then
export PATH
fi
section_end
section "pipx bin"
if [ $ZSH_PIPX -gt 0 ]; then
autoload -U bashcompinit
bashcompinit
eval "$(register-python-argcomplete pipx)"
fi
section_end
# Locale fix
section "locale fix"

View File

@ -85,6 +85,7 @@ for pm in \
pacaur \
pacman \
pip3 \
pipx \
npm \
yaourt \
yarn \

View File

@ -40,6 +40,13 @@ pip3_install() {
pip3 install --ignore-installed --user -U "$@"
}
pipx_install() {
for pkg in "$@"
do
pipx install --force "$pkg"
done
}
download() {
curl -L "$@"
}
@ -151,6 +158,12 @@ fi
if has_tags pm:pip3; then
pip3_install \
pipx
add_tag pm:pipx
fi
if has_tags pm:pipx; then
pipx_install \
powerline-status \
thefuck
fi