diff --git a/src/sage/features/threejs.py b/src/sage/features/threejs.py index 4517523918d..4f65c5bd48e 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, @@ -46,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