Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins cannot be loaded with Pelican 4.5.0 #181

Closed
shniubobo opened this issue Oct 10, 2020 · 12 comments
Closed

Plugins cannot be loaded with Pelican 4.5.0 #181

shniubobo opened this issue Oct 10, 2020 · 12 comments

Comments

@shniubobo
Copy link
Contributor

With Pelican 4.5.0, the plugins cannot be loaded with PLUGINS += ['m.x'] (where x is the plugin's name). A workaround is to put plugins outside of the m directory and use PLUGINS += ['x'] instead.

This is to be fixed in later versions of Pelican.

Related issues: #178, getpelican/pelican#2805

@egberts
Copy link

egberts commented Oct 14, 2020

Yeah, I got the same.
Did some debugging.
Noticed that Pelican 4.5 cannot use namespace_plugins approach, so it resorts to load_legacy() approach.

@egberts
Copy link

egberts commented Oct 14, 2020

I'm running Pelican 4.5.0 and am still experiencing load_legacy() not found issue.

$ python3.8 -c "import pelican;print(pelican.__version__)"
4.5.0

At 7a6686f4 (origin/master, origin/HEAD) Fix SUMMARY_END_SUFFIX variable name in changelog

I've done a git submodule checkout of m.css into the working area of a website such that this directory layout is:

+ egbert.net
|-- content
|-- output
|-- plugins
|-- m.css
   |
   +-- plugins
      +-- ansilexer.py
      +-- dot2svg.py
      +-- latex2svg.py
      +-- latex2svgextra.py
      +-- m
         +-- htmlsanity.py
         +-- metadata.py 
...

I used the following plugin settings:

PLUGIN_PATHS = [ './plugins', 'm.css/plugins' ]
PLUGINS = [
#          'i18n_subsites',
          'collate_content',
          'sitemap',
          'dateish',
          'tag_cloud',
          'm.alias',
          'm.htmlsanity',
          'm.images',
          'm.math',
          'just_table',
          'code_include',
]

And my console output for Pelican was:

ERROR: Cannot load plugin `m.alias`
  | No module named 'm'
ERROR: Cannot load plugin `m.htmlsanity`
  | No module named 'm'
ERROR: Cannot load plugin `m.images`
  | No module named 'm'
ERROR: Cannot load plugin `m.math`
  | No module named 'm'

Surely, I must be misreading the documentation or something, am I?

@shniubobo
Copy link
Contributor Author

Surely, I must be misreading the documentation or something, am I?

From #181 (comment):

This is to be fixed in later versions of Pelican.

@egberts
Copy link

egberts commented Oct 15, 2020

I wonder if it would be made easier if the period in m.css is replaced with an underscore “_” symbol.

@mosra
Copy link
Owner

mosra commented Oct 15, 2020

Nooo, that's ugly! :trollface:

In all seriousness, there's a proposed patch, so I think it's easier for everyone involved to just stay on 4.2 until this behavior is restored. Changing everything to an underscore means I need to change all docs, break compatibility with 4.2 (which would make a lot of existing users angry) and break also Python and Doxygen themes (because these use those plugins too).

@egberts
Copy link

egberts commented Oct 15, 2020

Unfortunately, I’ve taken the proposed fix and tried a few variants of my own but it looks like legacy plugins are screwed until next Python subsubversion.

@ikeingtonbear
Copy link

I seem to be having a related issue, but not with m.[plugin] plugins, rather the plugins directly under the m.css/plugins directory. I'm trying to use the code plugin, but it's unable to load the ansilexer moulde.

Here is some of my debug output:

DEBUG: Pelican version: 4.5.3
DEBUG: Python version: 3.9.1
DEBUG: Adding current directory to system path
DEBUG: Finding namespace plugins
DEBUG: Loading plugin `m.htmlsanity`
DEBUG: Loading plugin `m.code`
ERROR: Cannot load plugin `m.code`
  | No module named 'ansilexer'
DEBUG: Loading plugin `m.components`
DEBUG: Loading plugin `m.images`
DEBUG: Registering plugin `m.htmlsanity`
DEBUG: Registering plugin `m.components`
DEBUG: Registering plugin `m.images`

Snippets from my pelicanconf.py file:

PLUGIN_PATHS = ['m.css/plugins']
PLUGINS = ['m.htmlsanity', 'm.code', 'm.components', 'm.images']

If this is unrelated please let me know and I'll submit a new issue.

blairconrad added a commit to blairconrad/blairconrad.github.io that referenced this issue Apr 30, 2021
Unable to import ansilexer from m.code. This breaks all syntax
highlighting and also causes several articles not to render
at all.

Suggestion at mosra/m.css#181 is to pin
the pelican version for now.
@benlawraus
Copy link

Same problem on Pelican 4.7.

@shniubobo
Copy link
Contributor Author

Same problem on Pelican 4.7.

I cannot reproduce the problem on either pelican 4.7.0 or 4.7.1 with the methods specified at getpelican/pelican#2805 (the second one). Could you please specify how to reproduce it on pelican 4.7?

@lpirl
Copy link
Contributor

lpirl commented Nov 21, 2021

@benlawraus: I can confirm the statement of @shniubobo that plugin loading generally works again (tested Pelican 4.7.0 and 4.7.1); e.g. with:

PLUGIN_PATHS.append('themes/m.css/plugins')
PLUGINS.append('m.htmlsanity')

But I also did experience the behavior that @ikeingtonbear mentioned. In my case the plugin m.dot could not be loaded (got No module named 'dot2svg'). So apparently putting themes/m.css/plugins in PLUGIN_PATHS does not suffice to have this path in the sys.path/PYTHONPATH. I don't know where this should be fixed (plugin, Pelican, …?) but putting themes/m.css/plugins in the sys.path worked for me as a workaround. In your Pelican configuration, this would look like:

import sysPLUGIN_PATHS.append('themes/m.css/plugins')
…
PLUGINS.append('m.dot')
# maybe add a comment here:
sys.path.append('themes/m.css/plugins')

@MinchinWeb
Copy link

I was mucking around with my Pelican plugins and ran into this same issue (I think). I was able to solve it my moving the plugin from a "raw" file into the __init__.py file of a folder. So cname.py became cname/__init__.py. Your call on whether that is "beautiful" enough to implement :)

@mosra
Copy link
Owner

mosra commented Jan 3, 2022

Okay, sorry everyone that it took half a century for me to finally act on this matter. The remaining issue with the paths should be hacked up fixed in 47c005b (@lpirl thanks for providing a simple-enough idea for a fix). I'm now running on Pelican 4.7.1 locally and my excessive use of all plugins seems to work almost as good as it did back then with 4.2.

Now onto the remaining 100s of unresolved issues...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants