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

Loading plugin from module broken in v4.5.1 #2861

Open
2 tasks done
clokep opened this issue Mar 30, 2021 · 3 comments
Open
2 tasks done

Loading plugin from module broken in v4.5.1 #2861

clokep opened this issue Mar 30, 2021 · 3 comments
Assignees
Labels

Comments

@clokep
Copy link

clokep commented Mar 30, 2021

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: macOS 11.2.3

  • Python version: 3.7.7

  • Pelican version: 4.5.1

  • Link to theme: N/A

  • Links to plugins: assets, extract_toc, gravatar, pelican_youtube.youtube, share_post, thumbnailer

  • Link to your site: https://patrick.cloke.us

  • Link to your source: https://github.com/clokep/clokep.github.io @ eba8c9588b5d4f136d0cb73db7fe1752bcbc6055

  • Link to a Gist with the contents of your settings file: See above

Issue

Building of my site broke when upgrading from Pelican 4.5.0 to 4.5.1 (sorry this took so long to file, was trying to track down why). I tracked this down to #2813, reverting 991c00a fixes the issue for me.

The error is:

ERROR: Cannot load plugin `pelican_youtube.youtube`
  | Cannot import plugin `pelican_youtube.youtube`
ERROR: Could not process articles/matrix-live-interview.rst
  | /Users/clokep/code/blog/blog/content/articles/matrix-live-interview.rst:20: (ERROR/3) Unknown directive type "youtube".

.. youtube:: iKx-RHS-p4M
    :nocookie: yes

The first error is the interesting one (since the second is a direct result of it).

Note that I'm not loading this plug-in from a plugin-path, but it is installed as a package (from PyPI).

I did find a workaround, which was to import the module and pass it directly to plugins instead of passing it as a string:

from youtube_pelican import youtube

PLUGINS = [
    ...,
    youtube,
]

I figured I'd file this anyway since it isn't clear to me if what I was doing before is supposed to work or not.

Thanks for your help! (And thanks for working Pelican! 😄 )

@clokep clokep added the bug label Mar 30, 2021
@clokep
Copy link
Author

clokep commented Mar 30, 2021

I should note that Pelican 4.5.1+ has the same behavior (I've tested on 4.5.4 and 4.6.0).

@avaris
Copy link
Member

avaris commented Apr 1, 2021

Interesting. I think this is triggered because there is pelican_youtube inside pelican-plugins but it is not importable. It's in its package/installable form. So it takes precedence and marked as "found" but actual import fails. I'm guessing any one of these would "fix" this:

  • Remove/rename pelican_youtube inside pelican-plugins of your local copy
  • Prepend pelican-plugins/pelican_youtube in PLUGIN_PATHS:
PLUGIN_PATHS = [
    'pelican-plugins/pelican_youtube',
    'pelican-plugins'
]

First, it doesn't make much sense to put pelican_youtube in pelican-plugins like that, since that repository supposed to contain submodules/folders that are importable. Having said that, importer in pelican should be a bit more lenient and be able to resolve this. So I'd still consider this as a bug. Thanks for reporting.

@avaris avaris self-assigned this Apr 1, 2021
@clokep
Copy link
Author

clokep commented Apr 1, 2021

Ah, interesting. That does seem to be the issue. Setting PLUGIN_PATHS = [] works! 🎉 (Of course it means I can't use any other plug-ins except for pelican_youtube.youtube` though.)

Your workaround of removing it from my local copy of pelican-plugins also works.

Thanks so much for taking the time to investigate! I think this is also essentially fixed by the new-style plugins. 👍

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

No branches or pull requests

2 participants