From d37e5982299e33a62c1dcbbe756658b0477d6860 Mon Sep 17 00:00:00 2001 From: fondbcn Date: Wed, 24 Jan 2024 12:05:09 +0100 Subject: [PATCH] replacing pkg_resources with importlib --- nikola/nikola.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nikola/nikola.py b/nikola/nikola.py index 62f9279069..226d4e2bd3 100644 --- a/nikola/nikola.py +++ b/nikola/nikola.py @@ -46,7 +46,7 @@ import lxml.html import natsort import PyRSS2Gen as rss -from pkg_resources import resource_filename +from importlib import resources from blinker import signal from . import DEBUG, SHOW_TRACEBACKS, filters, utils, hierarchy_utils, shortcodes @@ -1031,7 +1031,7 @@ def init_plugins(self, commands_only=False, load_all=False): extra_plugins_dirs = self.config['EXTRA_PLUGINS_DIRS'] self._loading_commands_only = commands_only self._plugin_places = [ - resource_filename('nikola', 'plugins'), + resources.files('nikola').joinpath('plugins'), os.path.expanduser(os.path.join('~', '.nikola', 'plugins')), os.path.join(os.getcwd(), 'plugins'), ] + [path for path in extra_plugins_dirs if path] @@ -1694,9 +1694,7 @@ def _register_templated_shortcodes(self): """ self.register_shortcode('template', self._template_shortcode_handler) - builtin_sc_dir = resource_filename( - 'nikola', - os.path.join('data', 'shortcodes', utils.get_template_engine(self.THEMES))) + builtin_sc_dir = resources.files('nikola').joinpath(os.path.join('data', 'shortcodes', utils.get_template_engine(self.THEMES))) for sc_dir in [builtin_sc_dir, 'shortcodes']: if not os.path.isdir(sc_dir):