getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 444 forks source link

nikola does not work with current git yapsy - multiple tests fail with `KeyError` in the plugin template injection code #3700

Closed AdamWill closed 1 year ago

AdamWill commented 1 year ago

Environment

Python Version: 3.12

Nikola Version: 8.2.4

Operating System: Fedora Rawhide

Description:

We're landing Python 3.12 in Fedora Rawhide. As part of this, I had to backport https://github.com/tibonihoo/yapsy/pull/11 to make yapsy use importlib instead of imp. But that actually breaks nikola's template injection, because of an interesting change to what winds up in sys.modules with the different way of importing plugin modules. The errors look like this:

self = <mdx_gist.GistExtension object at 0x7fded7e16420>

    def inject_templates(self):
        """Inject 'templates/<engine>' (if exists) very early in the theme chain."""
        try:
            # Sorry, found no other way to get this
>           mod_path = sys.modules[self.__class__.__module__].__file__
E           KeyError: 'mdx_gist'

nikola/plugin_categories.py:79: KeyError

I have a fix for this ready to submit; I'm just filing an issue because the guidelines say there must be an issue for the PR.