Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
build/bin/sage-dist-helpers (sdh_pip_uninstall): Use build/bin/sage-p…
Browse files Browse the repository at this point in the history
…ip-uninstall, resurrected in simplified form
  • Loading branch information
Matthias Koeppe committed Oct 10, 2021
1 parent 52915b6 commit 2d852ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
6 changes: 1 addition & 5 deletions build/bin/sage-dist-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,7 @@ sdh_store_and_pip_install_wheel() {
}

sdh_pip_uninstall() {
# --disable-pip-version-check: Don't periodically check PyPI to determine whether a new version of pip is available
# --no-input: Disable prompting for input.
# --yes: Don't ask for confirmation of uninstall deletions
# See sage-pip-install for a discussion of the other flags.
python3 -m pip uninstall --isolated --disable-pip-version-check --yes --no-input "$@"
sage-pip-uninstall "$@"
if [ $? -ne 0 ]; then
echo "Warning: pip exited with status $?" >&2
fi
Expand Down
23 changes: 23 additions & 0 deletions build/bin/sage-pip-uninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# This command ensures that any previous installations of the same package
# are uninstalled.

# Note: "sage-pip-uninstall" is meant to be run after $(PYTHON) has
# been installed (either as an spkg or as a venv over a system python3).
# It is then guaranteed by sage-env that PATH is set in a way that "python3"
# refers to the correct python3.
PYTHON=python3

# The PIP variable is only used to determine the name of the lock file.
PIP=pip3

# We should avoid running pip while uninstalling a package because that
# is prone to race conditions. Therefore, we use a lockfile while
# running pip. This is implemented in the Python script sage-flock
LOCK="$SAGE_LOCAL/var/lock/$PIP.lock"

# --disable-pip-version-check: Don't periodically check PyPI to determine whether a new version of pip is available
# --no-input: Disable prompting for input.
# --yes: Don't ask for confirmation of uninstall deletions
# See sage-pip-install for a discussion of the other flags.
sage-flock -x $LOCK $PYTHON -m pip uninstall --isolated --disable-pip-version-check --yes --no-input "$@"

0 comments on commit 2d852ad

Please sign in to comment.