From 9b595c0c54d6e3591ab6d11462a60f0f03c71fce Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 2 Apr 2021 08:30:43 -0400 Subject: [PATCH] Trac #29617: modify Kenzo interface to support system ECL. We repeat all of the recent changes made to the maxima interface for kenzo, which also needs to support system installations of ECL. --- build/pkgs/ecl/spkg-configure.m4 | 3 +++ build/pkgs/kenzo/spkg-install.in | 8 +++++--- build/pkgs/sage_conf/src/sage_conf.py.in | 3 +++ src/sage/env.py | 1 + src/sage/features/kenzo.py | 7 ++++++- src/sage/interfaces/kenzo.py | 8 ++++++-- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/build/pkgs/ecl/spkg-configure.m4 b/build/pkgs/ecl/spkg-configure.m4 index 52d13fb4f9b..bcb3c6c1493 100644 --- a/build/pkgs/ecl/spkg-configure.m4 +++ b/build/pkgs/ecl/spkg-configure.m4 @@ -38,4 +38,7 @@ SAGE_SPKG_CONFIGURE([ecl], [ # Maxima cannot yet be provided by the system, so we always use # the SAGE_LOCAL path for now. AC_SUBST(SAGE_MAXIMA_FAS, ['${prefix}'/lib/ecl/maxima.fas]) + + # Likewise for the optional Kenzo SPKG + AC_SUBST(SAGE_KENZO_FAS, ['${prefix}'/lib/ecl/kenzo.fas]) ]) diff --git a/build/pkgs/kenzo/spkg-install.in b/build/pkgs/kenzo/spkg-install.in index 3c8e5946547..7bf5982be3a 100644 --- a/build/pkgs/kenzo/spkg-install.in +++ b/build/pkgs/kenzo/spkg-install.in @@ -5,9 +5,11 @@ cd src ecl < compile.lisp -# Install Kenzo into ECL's library directory (installation procedure -# copied from Maxima's spkg-install.in file): -ECLLIB=`ecl -eval "(princ (SI:GET-LIBRARY-PATHNAME))" -eval "(quit)"` +# Install Kenzo into ECL's library directory. +# Ensure that the $ECLLIB directory exists in +# case we're using ECL from the system. +ECLLIB="${SAGE_LOCAL}/lib/ecl" +mkdir -p "${ECLLIB}" echo echo "Now installing Kenzo as '$ECLLIB/kenzo.fas'..." cp -f kenzo--all-systems.fasb "$ECLLIB/kenzo.fas" \ diff --git a/build/pkgs/sage_conf/src/sage_conf.py.in b/build/pkgs/sage_conf/src/sage_conf.py.in index a86db8c09de..f3407bd5b19 100644 --- a/build/pkgs/sage_conf/src/sage_conf.py.in +++ b/build/pkgs/sage_conf/src/sage_conf.py.in @@ -14,6 +14,9 @@ MAXIMA = "@prefix@/bin/maxima" # Delete this line if your ECL can load maxima without further prodding. MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL) +# Delete this line if your ECL can load Kenzo without further prodding. +KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL) + ARB_LIBRARY = "@SAGE_ARB_LIBRARY@" NTL_INCDIR = "@NTL_INCDIR@" diff --git a/src/sage/env.py b/src/sage/env.py index 2908f5d04fa..cc9971c6784 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -207,6 +207,7 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st PPLPY_DOCS = var("PPLPY_DOCS", join(SAGE_SHARE, "doc", "pplpy")) MAXIMA = var("MAXIMA", "maxima") MAXIMA_FAS = var("MAXIMA_FAS") +KENZO_FAS = var("KENZO_FAS") SAGE_NAUTY_BINS_PREFIX = var("SAGE_NAUTY_BINS_PREFIX", "") ARB_LIBRARY = var("ARB_LIBRARY", "arb") CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas") diff --git a/src/sage/features/kenzo.py b/src/sage/features/kenzo.py index c3c68ede71b..ba36288eadd 100644 --- a/src/sage/features/kenzo.py +++ b/src/sage/features/kenzo.py @@ -46,7 +46,12 @@ def _is_present(self): ecl_eval("(setf *standard-output* *dev-null*)") try: - ecl_eval("(require :kenzo)") + from sage.env import KENZO_FAS + if KENZO_FAS is not None: + ecl_eval("(require :kenzo \"{}\")".format(KENZO_FAS)) + else: + ecl_eval("(require :kenzo)") + except RuntimeError: return FeatureTestResult(self, False, reason="Unable to make ECL require kenzo") return FeatureTestResult(self, True) diff --git a/src/sage/interfaces/kenzo.py b/src/sage/interfaces/kenzo.py index b501749cb89..b0a8874132c 100644 --- a/src/sage/interfaces/kenzo.py +++ b/src/sage/interfaces/kenzo.py @@ -40,7 +40,6 @@ from sage.libs.ecl import EclObject, ecl_eval, EclListIterator from sage.features.kenzo import Kenzo - # defining the auxiliary functions as wrappers over the kenzo ones kenzo_names = ['add', 'array-dimensions', @@ -107,7 +106,12 @@ # example __sphere__ is defined as EclObject("sphere"). Hyphens # are replaced with underscores to get valid Python identifiers. if Kenzo().is_present(): - ecl_eval("(require :kenzo)") + from sage.env import KENZO_FAS + if KENZO_FAS is not None: + ecl_eval("(require :kenzo \"{}\")".format(KENZO_FAS)) + else: + ecl_eval("(require :kenzo)") + ecl_eval("(in-package :cat)") ecl_eval("(setf *HOMOLOGY-VERBOSE* nil)") for s in kenzo_names: