diff --git a/Changelog.md b/Changelog.md index 951b507..2e273e9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - App management file for [shfmt](https://github.com/mvdan/sh) - When installing shellcheck, the corresponding man page is installed if pandoc is available. ### Changed +- Specifying a version for installing or upgrading pip is possible. ### Deprecated ### Removed ### Fixed diff --git a/lib/sdd/apps/user/pip b/lib/sdd/apps/user/pip index 64b28b3..14fe096 100755 --- a/lib/sdd/apps/user/pip +++ b/lib/sdd/apps/user/pip @@ -1,17 +1,26 @@ #! /bin/bash sdd_install() { - command -v python3 || return 1 + command -v python3 >/dev/null 2>&1 || return 1 - cd /tmp || return 1 - wget https://bootstrap.pypa.io/get-pip.py + wget -P /tmp https://bootstrap.pypa.io/get-pip.py + python3 /tmp/get-pip.py --user + sdd_upgrade "$1" - python3 get-pip.py --user - rm get-pip.py + mkdir -p "$SDD_INSTALL_PREFIX"/share/{bash_completion,zsh/site-functions} + ~/.local/bin/pip completion --bash > "$SDD_INSTALL_PREFIX"/share/bash_completion/pip + ~/.local/bin/pip completion --zsh > "$SDD_INSTALL_PREFIX"/share/zsh/site-functions/_pip + + rm /tmp/get-pip.py +} + +sdd_upgrade() { + ~/.local/bin/pip install --user --upgrade pip=="$1" } sdd_uninstall() { - "$SDD_INSTALL_PREFIX"/bin/pip uninstall --yes pip + ~/.local/bin/pip uninstall --yes pip + rm -rvf ~/.local/share/{bash_completion/pip,zsh/site-functions/_pip} } sdd_fetch_latest_version() { diff --git a/test/apps/pip.bats b/test/apps/pip.bats index 45ac750..5d503e2 100644 --- a/test/apps/pip.bats +++ b/test/apps/pip.bats @@ -1,12 +1,16 @@ -@test "pip of recent version can be installed and uninstalled" { - run sdd install pip +@test "pip of recent version can be installed, upgraded and uninstalled" { + run sdd install pip=19.0 [ $status -eq 0 ] - [[ "${lines[0]}" = 'Latest version available: '* ]] + [ "${lines[0]}" = 'Specified version: 19.0' ] [ "${lines[-1]}" = 'Succeeded to install "pip".' ] run pip --version [ $status -eq 0 ] + run sdd upgrade pip=20.0.1 + [ $status -eq 0 ] + [ "${lines[-1]}" = 'Succeeded to upgrade "pip".' ] + run sdd uninstall pip [ $status -eq 0 ] [ "${lines[-1]}" = 'Succeeded to uninstall "pip".' ]