From 18593aeb1cc333aac4e0b74d37d3183ef9c0264d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 20 Nov 2023 16:59:19 -0800 Subject: [PATCH 1/5] build/bin/{sage-spkg,sage-dist-helpers}: For non-sudo DESTDIR-staged installation, defer installation of wheel to post-install phase --- build/bin/sage-dist-helpers | 50 ++++++++++++++++++++++++++----------- build/bin/sage-spkg | 22 +++++++++++++--- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index b6259ca9ef1..c2355a2afbb 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -355,38 +355,58 @@ sdh_store_and_pip_install_wheel() { shift done sdh_store_wheel "$@" - if [ -n "$SAGE_SUDO" ]; then - # Trac #29585: Do the SAGE_DESTDIR staging of the wheel installation - # ONLY if SAGE_SUDO is set (in that case, we still do the staging so - # that we do not invoke pip as root). + + wheel_basename="${wheel##*/}" + distname="${wheel_basename%%-*}" + + if [ -d "$SAGE_BUILD_DIR/$PKG_NAME" ]; then + # Normal package install through sage-spkg; + # scripts live in the package's build directory + # until copied to the final destination by sage-spkg. + script_dir="$SAGE_BUILD_DIR/$PKG_NAME" + else + script_dir="$SAGE_SPKG_SCRIPTS/$PKG_BASE" + fi + + if [ -n "$SAGE_DESTDIR" -a -z "$SAGE_SUDO" ]; then + # We stage the wheel file and do the actual installation in post. + echo "sdh_actually_pip_install_wheel $distname $pip_options -r \"\$SAGE_SPKG_SCRIPTS/\$PKG_BASE/spkg-requirements.txt\"" >> "$script_dir"/spkg-pipinst + else if [ -n "$SAGE_DESTDIR" ]; then + # Trac #29585: Do the SAGE_DESTDIR staging of the wheel installation + # ONLY if SAGE_SUDO is set (in that case, we still do the staging so + # that we do not invoke pip as root). # --no-warn-script-location: Suppress a warning caused by --root local sudo="" local root="--root=$SAGE_DESTDIR --no-warn-script-location" - else - # Trac #32361: Of course, this can only be done for normal packages, - # whose installation goes through sage-spkg. - # For script packages, we do have to invoke pip as root. + elif [ -n "$SAGE_SUDO" ]; then + # Trac #32361: For script packages, we do have to invoke pip as root. local sudo="$SAGE_SUDO" local root="" + else + # + local sudo="" + local root="" fi - else - local sudo="" - local root="" + sdh_actually_pip_install_wheel $distname $root $pip_options -r "$SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-requirements.txt" fi + echo "sdh_pip_uninstall -r \"\$SAGE_SPKG_SCRIPTS/\$PKG_BASE/spkg-requirements.txt\"" >> "$script_dir"/spkg-piprm +} + +sdh_actually_pip_install_wheel() { + distname=$1 + shift # Trac #32659: pip no longer reinstalls local wheels if the version is the same. # Because neither (1) applying patches nor (2) local changes (in the case # of sage-conf, sage-setup, etc.) bump the version number, we need to # override this behavior. The pip install option --force-reinstall does too # much -- it also reinstalls all dependencies, which we do not want. - wheel_basename="${wheel##*/}" - distname="${wheel_basename%%-*}" $sudo sage-pip-uninstall "$distname" if [ $? -ne 0 ]; then echo "(ignoring error)" >&2 fi - $sudo sage-pip-install $root $pip_options "$wheel" || \ - sdh_die "Error installing ${wheel##*/}" + $sudo sage-pip-install "$@" || \ + sdh_die "Error installing $@" } sdh_pip_uninstall() { diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index b540c8e866f..da732bae464 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -548,9 +548,13 @@ WRAPPED_SCRIPTS="build install check preinst postinst $INSTALLED_SCRIPTS" # Prepare script for uninstallation of packages that use sdh_pip_install # or sdh_store_and_pip_install_wheel. -echo 'sdh_pip_uninstall -r $SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-requirements.txt' > spkg-piprm.in +touch spkg-piprm.in -for script in $WRAPPED_SCRIPTS; do +# Prepare script for deferred installation of packages that use sdh_pip_install +# or sdh_store_and_pip_install_wheel. +touch spkg-pipinst.in + +for script in $WRAPPED_SCRIPTS pipinst; do # pipinst can be added to WRAPPED_SCRIPTS later # 'Installed' scripts are not run immediately out of the package build # directory, and may be run later, so set their root directory to # $SAGE_ROOT @@ -706,10 +710,11 @@ INSTALLED_SCRIPTS_DEST="$SAGE_SPKG_SCRIPTS/$PKG_BASE" if [ ! -f $INSTALLED_SCRIPTS_DEST/spkg-requirements.txt ]; then # No packages to uninstall with pip, so remove the prepared uninstall script - rm -f spkg-piprm spkg-piprm.in + # and the prepared deferred installation script + rm -f spkg-piprm spkg-piprm.in spkg-pipinst spkg-pipinst.in fi -for script in $INSTALLED_SCRIPTS; do +for script in $INSTALLED_SCRIPTS pipinst; do # pipinst can be added to WRAPPED_SCRIPTS later script="spkg-$script" if [ -f "$script" ]; then @@ -729,6 +734,15 @@ done # Run the post-install script, if any +# But first complete the delayed installation of wheels. +if [ -f spkg-pipinst ]; then + echo "Running pip-install script for $PKG_NAME." + $SAGE_SUDO ./spkg-pipinst + if [ $? -ne 0 ]; then + error_msg "Error running the pipinst script for $PKG_NAME." + exit 1 + fi +fi if [ -f spkg-postinst ]; then echo "Running post-install script for $PKG_NAME." time $SAGE_SUDO ./spkg-postinst From 96d251281d90113ee4898d29110d4b831e0e6e9e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 20 Nov 2023 18:00:36 -0800 Subject: [PATCH 2/5] build/pkgs/texttable: Update to 1.7.0 --- build/pkgs/texttable/checksums.ini | 6 +++--- build/pkgs/texttable/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/texttable/checksums.ini b/build/pkgs/texttable/checksums.ini index 380a205bdd3..d8725b785b2 100644 --- a/build/pkgs/texttable/checksums.ini +++ b/build/pkgs/texttable/checksums.ini @@ -1,5 +1,5 @@ tarball=texttable-VERSION.tar.gz -sha1=25e1b92e02c8e919dc0da053efbe8c4874418a8d -md5=83eb15fb541dd857ff051a8d0c979b9c -cksum=3183998721 +sha1=0fa175fa6e0fefea31434746641bedc8cbb60248 +md5=e5d380c04fab132ccf0bbfd4f761bd51 +cksum=274394355 upstream_url=https://pypi.io/packages/source/t/texttable/texttable-VERSION.tar.gz diff --git a/build/pkgs/texttable/package-version.txt b/build/pkgs/texttable/package-version.txt index 400084b1bf2..bd8bf882d06 100644 --- a/build/pkgs/texttable/package-version.txt +++ b/build/pkgs/texttable/package-version.txt @@ -1 +1 @@ -1.6.7 +1.7.0 From bd9aa02ec3238b929ea5755b5c4b561c42263e11 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 30 Nov 2023 17:21:22 -0800 Subject: [PATCH 3/5] build/pkgs/pip/spkg-install.in: Delay setting the Python path for self-install to post --- build/pkgs/pip/spkg-install.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/pip/spkg-install.in b/build/pkgs/pip/spkg-install.in index 651f5c1dc1e..728694365cd 100644 --- a/build/pkgs/pip/spkg-install.in +++ b/build/pkgs/pip/spkg-install.in @@ -4,7 +4,7 @@ sdh_setup_bdist_wheel # pip can install its own wheel! But first we need to ensure that the pip # source directory in on the PYTHONPATH -export PYTHONPATH="$(pwd)/src" +echo "export PYTHONPATH=\"$(pwd)/src\"" >> ../spkg-pipinst # --ignore-installed makes sure that pip does not mistake # its own source tree as an existing installation From 1f0bc9d143507dd00d4219fd535c8743caa892f8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 30 Nov 2023 18:34:31 -0800 Subject: [PATCH 4/5] Simplification --- build/pkgs/pip/spkg-install.in | 4 ---- build/pkgs/pip/spkg-pipinst.in | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 build/pkgs/pip/spkg-pipinst.in diff --git a/build/pkgs/pip/spkg-install.in b/build/pkgs/pip/spkg-install.in index 728694365cd..6712a1583bc 100644 --- a/build/pkgs/pip/spkg-install.in +++ b/build/pkgs/pip/spkg-install.in @@ -2,10 +2,6 @@ cd src sdh_setup_bdist_wheel -# pip can install its own wheel! But first we need to ensure that the pip -# source directory in on the PYTHONPATH -echo "export PYTHONPATH=\"$(pwd)/src\"" >> ../spkg-pipinst - # --ignore-installed makes sure that pip does not mistake # its own source tree as an existing installation sdh_store_and_pip_install_wheel --ignore-installed . diff --git a/build/pkgs/pip/spkg-pipinst.in b/build/pkgs/pip/spkg-pipinst.in new file mode 100644 index 00000000000..3e3f6bbc94e --- /dev/null +++ b/build/pkgs/pip/spkg-pipinst.in @@ -0,0 +1,5 @@ +cd src + +# pip can install its own wheel! But first we need to ensure that the pip +# source directory in on the PYTHONPATH +export PYTHONPATH="$(pwd)/src" From f981b15c3ff5869e9292dfda7a6760d36db0a2e9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Dec 2023 21:55:45 -0800 Subject: [PATCH 5/5] Fix installation of pip with SAGE_SUDO --- build/bin/sage-dist-helpers | 4 ++-- build/pkgs/pip/spkg-install.in | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index c2355a2afbb..b159d696745 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -388,7 +388,7 @@ sdh_store_and_pip_install_wheel() { local sudo="" local root="" fi - sdh_actually_pip_install_wheel $distname $root $pip_options -r "$SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-requirements.txt" + sdh_actually_pip_install_wheel $distname $root $pip_options "$wheel" fi echo "sdh_pip_uninstall -r \"\$SAGE_SPKG_SCRIPTS/\$PKG_BASE/spkg-requirements.txt\"" >> "$script_dir"/spkg-piprm } @@ -406,7 +406,7 @@ sdh_actually_pip_install_wheel() { echo "(ignoring error)" >&2 fi $sudo sage-pip-install "$@" || \ - sdh_die "Error installing $@" + sdh_die "Error installing $distname" } sdh_pip_uninstall() { diff --git a/build/pkgs/pip/spkg-install.in b/build/pkgs/pip/spkg-install.in index 6712a1583bc..651f5c1dc1e 100644 --- a/build/pkgs/pip/spkg-install.in +++ b/build/pkgs/pip/spkg-install.in @@ -2,6 +2,10 @@ cd src sdh_setup_bdist_wheel +# pip can install its own wheel! But first we need to ensure that the pip +# source directory in on the PYTHONPATH +export PYTHONPATH="$(pwd)/src" + # --ignore-installed makes sure that pip does not mistake # its own source tree as an existing installation sdh_store_and_pip_install_wheel --ignore-installed .