From 79531f7013d9f9a54eaa7ac265c4788bd72a8ada Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 28 Dec 2021 14:36:32 +0100 Subject: feat(pip): alias `pip` to `pip3` if pip is missing (#10431) --- plugins/pip/pip.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins/pip') diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 629147bae..a58f5704a 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -82,7 +82,11 @@ zsh-pip-test-clean-packages() { fi } -alias pip="noglob pip" # allows square brackets for pip command invocation +if (( $+commands[pip3] && !$+commands[pip] )); then + alias pip="noglob pip3" +else + alias pip="noglob pip" +fi # Create requirements file alias pipreq="pip freeze > requirements.txt" -- cgit v1.2.3-70-g09d2 From eec34b32fa586559af463b0d61256a7f5d257bea Mon Sep 17 00:00:00 2001 From: Oluwafemi Sule Date: Wed, 29 Dec 2021 12:26:17 +0100 Subject: fix(pip): use `pip3` in `pip3 uninstall` completion (#10271) --- plugins/pip/_pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/pip') diff --git a/plugins/pip/_pip b/plugins/pip/_pip index a5adead4a..e03be6afe 100644 --- a/plugins/pip/_pip +++ b/plugins/pip/_pip @@ -13,7 +13,7 @@ _pip_all() { } _pip_installed() { - installed_pkgs=(`pip freeze | cut -d '=' -f 1`) + installed_pkgs=($($service freeze | cut -d '=' -f 1)) } local -a _1st_arguments -- cgit v1.2.3-70-g09d2 From 2acb3071cade6395c1dbcee31b6b8d198ebed66a Mon Sep 17 00:00:00 2001 From: WH-2099 Date: Wed, 29 Dec 2021 19:55:51 +0800 Subject: fix(pip): don't overwrite `requirements.txt` in internal commands (#10061) --- plugins/pip/pip.plugin.zsh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'plugins/pip') diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index a58f5704a..7eb2d2a35 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -91,11 +91,21 @@ fi # Create requirements file alias pipreq="pip freeze > requirements.txt" -# Update all installed packages -alias pipupall="pipreq && sed -i 's/==/>=/g' requirements.txt && pip install -r requirements.txt --upgrade && rm -rf requirements.txt" - # Install packages from requirements file alias pipir="pip install -r requirements.txt" +# Update all installed packages +function pipupall { + # non-GNU xargs does not support nor need `--no-run-if-empty` + local xargs="xargs --no-run-if-empty" + xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" + pip list --outdated --format freeze | cut -d= -f1 | ${=xargs} pip install --upgrade +} + # Uninstalled all installed packages -alias pipunall="pipreq && pip uninstall -r requirements.txt -y && rm -rf requirements.txt" +function pipunall { + # non-GNU xargs does not support nor need `--no-run-if-empty` + local xargs="xargs --no-run-if-empty" + xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" + pip list --format freeze | cut -d= -f1 | ${=xargs} pip uninstall +} -- cgit v1.2.3-70-g09d2