From 01a5cbba3733d496ce4fc4c7fb9a1aa44181c33b Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 11 Jan 2022 16:53:19 +0100 Subject: [PATCH] Fix resolving mako paths for installed Galaxy --- lib/galaxy/webapps/base/webapp.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/galaxy/webapps/base/webapp.py b/lib/galaxy/webapps/base/webapp.py index 902b1974294..9c10c58c4e8 100644 --- a/lib/galaxy/webapps/base/webapp.py +++ b/lib/galaxy/webapps/base/webapp.py @@ -1,6 +1,7 @@ """ """ import datetime +import importlib.resources import inspect import logging import os @@ -90,16 +91,13 @@ class WebApplication(base.WebApplication): def create_mako_template_lookup(self, galaxy_app, name): paths = [] - # FIXME: should be os.path.join (galaxy_root, 'templates')? - if galaxy_app.config.template_path == './templates': - template_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')) - else: - template_path = galaxy_app.config.template_path + base_template_path = importlib.resources.files('galaxy.webapps.base') / 'templates' + app_template_path = base_template_path / 'webapps' # First look in webapp specific directory if name is not None: - paths.append(os.path.join(template_path, 'webapps', name)) + paths.append(app_template_path / name) # Then look in root directory - paths.append(template_path) + paths.append(base_template_path) # Create TemplateLookup with a small cache return mako.lookup.TemplateLookup(directories=paths, module_directory=galaxy_app.config.template_cache_path,