Skip to content

Commit

Permalink
Trac #32918: configure: Also check installation records in SAGE_VENV/…
Browse files Browse the repository at this point in the history
…var/lib/sage/installed

For optional Python packages installed using `sage -i SPKG` or `make
SPKG` but not enabled using `configure --enable-SPKG`, #29013/#32442
broke automatic rebuilds.

We fix this by checking installation records in
`SAGE_VENV/var/lib/sage/installed` for Python packages.
With this ticket, `./bootstrap && make pynormaliz && ./config.status
--recheck` should show
{{{
pynormaliz-2.14:                             optional, will be installed
as an SPKG
}}}

URL: https://trac.sagemath.org/32918
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Dec 10, 2021
2 parents 8b176aa + 9eca9ae commit 2168538
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.
4 changes: 1 addition & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ else
SAGE_VENV_AUTO=no
fi
SAGE_SRC="$SAGE_ROOT/src"
SAGE_SPKG_INST="$SAGE_LOCAL/var/lib/sage/installed"

AC_ARG_WITH([sage-venv],
[AS_HELP_STRING([--with-sage-venv={auto (default),yes,no,SAGE_VENV}],
Expand Down Expand Up @@ -488,7 +487,7 @@ AC_CONFIG_COMMANDS(mkdirs,
"$SAGE_LOCAL/bin" "$SAGE_LOCAL/etc" \
"$SAGE_LOCAL/include" "$SAGE_LOCAL/lib" \
"$SAGE_LOCAL/lib/pkgconfig" \
"$SAGE_SHARE" "$SAGE_INST"; do
"$SAGE_SHARE" "$SAGE_LOCAL/var/lib/sage/installed"; do
AC_MSG_NOTICE([creating directory $d])
mkdir -p "$d" || AC_MSG_ERROR(could not create $d)
done
Expand All @@ -507,7 +506,6 @@ AC_CONFIG_COMMANDS(mkdirs,
SAGE_LOGS="$SAGE_ROOT/logs/pkgs"
SAGE_LOCAL="$SAGE_LOCAL"
SAGE_SHARE="$SAGE_LOCAL/share"
SAGE_INST="$SAGE_SPKG_INST"
])

AC_CONFIG_COMMANDS(links, [
Expand Down
58 changes: 33 additions & 25 deletions m4/sage_spkg_collect.m4
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,39 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
fi
SAGE_PACKAGE_TREES="${SAGE_PACKAGE_TREES}$(printf '\ntrees_')${SPKG_NAME} = ${SPKG_TREE_VAR}"
dnl Determine whether it is installed already
AS_VAR_SET([is_installed], [no])
for treevar in ${SPKG_TREE_VAR} SAGE_LOCAL; do
AS_VAR_COPY([t], [$treevar])
AS_IF([test -n "$t" -a -d "$t/var/lib/sage/installed/" ], [
for f in "$t/var/lib/sage/installed/$SPKG_NAME"-*; do
AS_IF([test -r "$f"], [
AS_VAR_IF([SPKG_SOURCE], [normal], [
dnl Only run the multiple installation record test for normal packages,
dnl not for script packages. We actually do not clean up after those...
AS_IF([test "$is_installed" = "yes"], [
AC_MSG_ERROR(m4_normalize([
multiple installation records for $SPKG_NAME:
m4_newline($(ls -l "$t/var/lib/sage/installed/$SPKG_NAME"-*))
m4_newline([only one should exist, so please delete some or all
of these files and re-run "$srcdir/configure"])
]))
])
])
AS_VAR_SET([is_installed], [yes])
])
done
dnl Only check the first existing tree, so that we do not issue "multiple installation" warnings
dnl when SAGE_LOCAL = SAGE_VENV
break
])
done
# Determine whether package is enabled
AS_VAR_IF([SAGE_ENABLE_${SPKG_NAME}], [if_installed],
[AS_VAR_SET([SAGE_ENABLE_${SPKG_NAME}], $is_installed)])
AS_VAR_COPY([want_spkg], [SAGE_ENABLE_${SPKG_NAME}])
uninstall_message=""
SAGE_NEED_SYSTEM_PACKAGES_VAR=SAGE_NEED_SYSTEM_PACKAGES
# Check consistency of 'DIR/type' file
Expand Down Expand Up @@ -229,20 +262,6 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
optional|experimental)
in_sdist=no
uninstall_message=", use \"$srcdir/configure --disable-$SPKG_NAME\" to uninstall"
stampfile=""
for f in "$SAGE_SPKG_INST/$SPKG_NAME"-*; do
AS_IF([test -r "$f"], [
AS_IF([test -n "$stampfile"], [
AC_MSG_ERROR(m4_normalize([
multiple installation records for $SPKG_NAME:
m4_newline($(ls -l "$SAGE_SPKG_INST/$SPKG_NAME"-*))
m4_newline([only one should exist, so please delete some or all
of these files and re-run "$srcdir/configure"])
]))
])
stampfile=yes
])
done
;;
esac
Expand Down Expand Up @@ -307,17 +326,6 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
SAGE_SDIST_PACKAGES="${SAGE_SDIST_PACKAGES} \\$(printf '\n ')${SPKG_NAME}"
fi
# Determine whether package is enabled
AS_VAR_SET([is_installed], [no])
for f in "$SAGE_SPKG_INST/${SPKG_NAME}"-*; do
AS_IF([test -r "$f"],
[AS_VAR_SET([is_installed], [yes])])
done
AS_VAR_IF([SAGE_ENABLE_${SPKG_NAME}}], [if_installed],
[AS_VAR_SET([SAGE_ENABLE_${SPKG_NAME}], $is_installed)])
AS_VAR_COPY([want_spkg], [SAGE_ENABLE_${SPKG_NAME}])
spkg_line=" \\$(printf '\n ')$SPKG_NAME"
AS_CASE([$is_installed-$want_spkg],
[*-yes], [AS_VAR_APPEND(SAGE_OPTIONAL_INSTALLED_PACKAGES, "$spkg_line")],
Expand Down
2 changes: 1 addition & 1 deletion m4/sage_spkg_configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $4
dnl If a version of this package is already installed in local/ we have no
dnl choice but to use it and we will actually also update it even if it is not
dnl required.
AS_IF([test -n "`ls "${SAGE_SPKG_INST}/${sage_spkg_name}"-* 2>/dev/null`"], [
AS_IF([test -n "`ls "${SAGE_LOCAL}/var/lib/sage/installed/${sage_spkg_name}"-* 2>/dev/null`"], [
AC_MSG_NOTICE(m4_normalize(SPKG_NAME[ has already been installed by SageMath]))
AS_VAR_SET(SPKG_INSTALL, [yes])
AS_VAR_SET(SPKG_USE_SYSTEM, [installed])
Expand Down

0 comments on commit 2168538

Please sign in to comment.