Skip to content

Commit

Permalink
replacing pkg_resources with importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
fondbcn committed Jan 24, 2024
1 parent 2f5cf49 commit d37e598
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d37e598

Please sign in to comment.