Skip to content

Commit

Permalink
Enhance pip app management file
Browse files Browse the repository at this point in the history
- enable upgrading
- enable specifying version for installing or upgrading
- install bash and zsh completion scripts
- get bitten by pypa/pip#7621 when extending
  tests
- silence command -v output
- use wget -P
  • Loading branch information
pylipp committed Feb 15, 2020
1 parent 0b85a9b commit feb1ff0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 15 additions & 6 deletions lib/sdd/apps/user/pip
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
10 changes: 7 additions & 3 deletions test/apps/pip.bats
Original file line number Diff line number Diff line change
@@ -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".' ]
Expand Down

0 comments on commit feb1ff0

Please sign in to comment.