From c52f2abd3f13a2ea5a57a2a756ad980f2489db8f Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Wed, 2 Oct 2024 21:52:51 +0100 Subject: [PATCH] vis: switch from pkg_resource to importlib_resources --- src/pyg4ometry/visualisation/ViewerBase.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pyg4ometry/visualisation/ViewerBase.py b/src/pyg4ometry/visualisation/ViewerBase.py index 3273a752c..4f0d78303 100644 --- a/src/pyg4ometry/visualisation/ViewerBase.py +++ b/src/pyg4ometry/visualisation/ViewerBase.py @@ -598,7 +598,8 @@ def exportThreeJSScene(self, fileNameBase="test", lightBoxHDR="concrete_tunnel_0 open test.html """ - import pkg_resources + import importlib_resources + from jinja2 import Template gltfFileName = fileNameBase + ".gltf" @@ -613,8 +614,12 @@ def exportThreeJSScene(self, fileNameBase="test", lightBoxHDR="concrete_tunnel_0 "css_file": cssFileName, } - threeHTMLTemplate = pkg_resources.resource_filename(__name__, "threejs.html") - threeCSSTemplate = pkg_resources.resource_filename(__name__, "threejs.css") + threeHTMLTemplate = importlib_resources.as_file( + importlib_resources.files(__name__) / "threejs.html" + ) + threeCSSTemplate = importlib_resources.as_file( + importlib_resources.files(__name__) / "threejs.css" + ) with open(threeHTMLTemplate) as file: template = Template(file.read())