From e9e66a7fd07342e5d0e53e2e6d28d8f75465bdbc Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 14 Feb 2024 23:58:32 -0800 Subject: [PATCH 1/2] src/sage/features/threejs.py: Do not fail when the version file does not exist --- src/sage/features/threejs.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sage/features/threejs.py b/src/sage/features/threejs.py index 4517523918d..701b5749976 100644 --- a/src/sage/features/threejs.py +++ b/src/sage/features/threejs.py @@ -25,8 +25,6 @@ def __init__(self): """ from sage.env import SAGE_SHARE, THREEJS_DIR - version = self.required_version() - threejs_search_path = THREEJS_DIR or ( os.path.join(SAGE_SHARE, "jupyter", "nbextensions", "threejs-sage"), os.path.join(SAGE_SHARE, "sagemath", "threejs-sage"), @@ -34,9 +32,15 @@ def __init__(self): os.path.join(SAGE_SHARE, "threejs-sage") ) + try: + version = self.required_version() + filename = os.path.join(version, "three.min.js") + except FileNotFoundError: + filename = 'unknown' + StaticFile.__init__( self, name="threejs", - filename=os.path.join(version, "three.min.js"), + filename=filename, spkg="threejs", type="standard", search_path=threejs_search_path, From a2ce28c1c6d1730afb19aff8de5f173370242bbd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 14 Feb 2024 23:59:10 -0800 Subject: [PATCH 2/2] src/sage/features/threejs.py: Add documentation --- src/sage/features/threejs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sage/features/threejs.py b/src/sage/features/threejs.py index 701b5749976..4f65c5bd48e 100644 --- a/src/sage/features/threejs.py +++ b/src/sage/features/threejs.py @@ -50,6 +50,11 @@ def required_version(self): """ Return the version of threejs that Sage requires. + Defining what version is required is delegated to the distribution package + that provides the file ``threejs-version.txt`` in :mod:`sage.ext_data.threejs`. + + If the file is not provided, :class:`FileNotFoundError` is raised. + EXAMPLES:: sage: from sage.features.threejs import Threejs