Closed shniubobo closed 3 years ago
Ohh, much thanks for investigating this issue :heart:
I am aware that everything got broken since Pelican 4.5 but didn't have any time to look into it yet. Is this really everything needed to make things work again? That would be awesome.
I had an impression that having plugins in a submodule stopped working also (as in, PLUGINS += ['m.htmlsanity']
no longer worked), but maybe that was a consequence of this import error.
At first I tried using the plugin as is instructed in https://mcss.mosra.cz/plugins/htmlsanity/, but pelican
kept saying:
ERROR: Cannot load plugin `m.htmlsanity`
| No module named 'm'
Later I moved htmlsanity.py
outside of the m
directory and tried PLUGINS += ['htmlsanity']
. Although the plugin still did not work, the logging of pelican
changed into:
ERROR: Cannot register plugin `htmlsanity`
| name 'pelican' is not defined
So I guessed pelican
was not correctly imported. After removing the try...except
statements in htmlsanity.py
, I got the following error:
ModuleNotFoundError: No module named 'pelican.signals'
After investigating the blame info of https://github.com/getpelican/pelican/blob/master/pelican/__init__.py, I found the very commit (https://github.com/getpelican/pelican/commit/58edad6897931f21c7c2f4314cfab33c2b167680) that introduced the issue.
With the aforementioned modification to htmlsanity.py
, it can now work with PLUGINS += ['htmlsanity']
, but still not with PLUGINS += ['m.htmlsanity']
🙁
Okay, that's what I feared -- that everyone upgrading to Pelican 4.5 would need to change this in their settings :(
Do you have time to investigate why the submodule no longer works? If not, I'll check myself when I get to it.
I tried to but could not find the reason why m.htmlsanity
is not working 🙁
When I type python -c "import m"
inside the plugins folder, it exits with 0, so the module m
is valid. But when I invoke pelican
, it keeps saying:
ERROR: Cannot load plugin `m.htmlsanity`
| No module named 'm'
Here are my settings:
PLUGINS = [
'm.htmlsanity',
]
PLUGIN_PATHS = [
'plugins',
]
And inside the plugins directory, I have a symlink m
that points to the m.css/plugins/m
directory.
In pelican
's documents, it says that namespace plugins (such as m.htmlsanity
) need to be installable. Maybe a setup.py
could solve the issue? 🤔
As of https://github.com/getpelican/pelican/commit/58edad6897931f21c7c2f4314cfab33c2b167680,
import pelican.signals
is no longer valid, and should be replaced with one of:from pelican import signals
from pelican.plugins import signals
import pelican.plugins.signals
I found this issue when trying to use
plugins/m/htmlsanity.py
, and the plugin works fine after the following modification: