Skip to content

Commit aac663b

Browse files
author
Release Manager
committed
Trac #32659: sdh_pip_install: Force reinstallation of built wheels; add sage_setup source deps
After #32492, we may get {{{ [sage_conf-9.5.beta2] sage-conf is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel. }}} Because of this behavior of pip, some configuration changes made in `configure` will not be updated in an incremental build. Likewise for other Python packages when we add a patch, or for `sage-setup` when we edit files there (as happened in #32607). However, as discussed in pypa/pip#8711, the `pip install` option `--force-reinstall` does too much -- it also reinstalls all dependencies, which we definitely do not want. Instead, we just use `pip uninstall` before `pip install`. We also add some dependencies on source files to `sage_setup`. This is also for #32607. URL: https://trac.sagemath.org/32659 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Lorenz Panny
2 parents 056b8d4 + d435781 commit aac663b

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

build/bin/sage-dist-helpers

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ sdh_store_and_pip_install_wheel() {
306306
local sudo=""
307307
local root=""
308308
fi
309+
# Trac #32659: pip no longer reinstalls local wheels if the version is the same.
310+
# Because neither (1) applying patches nor (2) local changes (in the case
311+
# of sage-conf, sage-setup, etc.) bump the version number, we need to
312+
# override this behavior. The pip install option --force-reinstall does too
313+
# much -- it also reinstalls all dependencies, which we do not want.
314+
wheel_basename="${wheel##*/}"
315+
distname="${wheel_basename%%-*}"
316+
$sudo sage-pip-uninstall "$distname"
317+
if [ $? -ne 0 ]; then
318+
echo "(ignoring error)" >&2
319+
fi
309320
$sudo sage-pip-install $root $pip_options "$wheel" || \
310321
sdh_die "Error installing ${wheel##*/}"
311322
if [ -n "${SAGE_PKG_DIR}" ]; then
@@ -316,11 +327,7 @@ sdh_store_and_pip_install_wheel() {
316327
}
317328

318329
sdh_pip_uninstall() {
319-
# --disable-pip-version-check: Don't periodically check PyPI to determine whether a new version of pip is available
320-
# --no-input: Disable prompting for input.
321-
# --yes: Don't ask for confirmation of uninstall deletions
322-
# See sage-pip-install for a discussion of the other flags.
323-
python3 -m pip uninstall --isolated --disable-pip-version-check --yes --no-input "$@"
330+
sage-pip-uninstall "$@"
324331
if [ $? -ne 0 ]; then
325332
echo "Warning: pip exited with status $?" >&2
326333
fi

build/bin/sage-pip-uninstall

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# This command ensures that any previous installations of the same package
3+
# are uninstalled.
4+
5+
# Note: "sage-pip-uninstall" is meant to be run after $(PYTHON) has
6+
# been installed (either as an spkg or as a venv over a system python3).
7+
# It is then guaranteed by sage-env that PATH is set in a way that "python3"
8+
# refers to the correct python3.
9+
PYTHON=python3
10+
11+
# The PIP variable is only used to determine the name of the lock file.
12+
PIP=pip3
13+
14+
# We should avoid running pip while uninstalling a package because that
15+
# is prone to race conditions. Therefore, we use a lockfile while
16+
# running pip. This is implemented in the Python script sage-flock
17+
LOCK="$SAGE_LOCAL/var/lock/$PIP.lock"
18+
19+
# --disable-pip-version-check: Don't periodically check PyPI to determine whether a new version of pip is available
20+
# --no-input: Disable prompting for input.
21+
# --yes: Don't ask for confirmation of uninstall deletions
22+
# See sage-pip-install for a discussion of the other flags.
23+
sage-flock -x $LOCK $PYTHON -m pip uninstall --isolated --disable-pip-version-check --yes --no-input "$@"

build/pkgs/sage_setup/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$(PYTHON) cython pkgconfig | $(PYTHON_TOOLCHAIN)
1+
$(PYTHON) cython pkgconfig $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/autogen/interpreters/specs/*.py | $(PYTHON_TOOLCHAIN)
22

33
----------
44
All lines of this file are ignored except the first.

0 commit comments

Comments
 (0)