AutoLoader is a plugin for Pelican, a static site generator written in Python.
AutoLoader is a “meta plugin” in that it doesn’t directly affect your Pelican
site, but rather works to make your other plugins better. By way of background,
Pelican 4.5 added the ability to autoload plugins that exist in the
pelican.plugins
namespace. This plugin allows you to extend this autoload
ability to any arbitrary namespace. In particlar, it defaults to extending this
ability to my minchin.pelican.plugins
namespace, and thus will autoload my
other plugins, if installed. It can also be used to add plugin autoloading to
earlier version of Pelican.
Personally, these two abilities (to autoload my other plugins and to add
autoloading to older versions of Pelican) are significant, because I am
currently in the process of upgrading from Pelican 3.7 to the current version
(4.7) and what was holding me back was the effort to move my plugins from their
current minchin.pelican.plugins
namespace. With AutoLoader, it makes it
simple to upgrade my Pelican version, regardless of whether the plugins have
(yet? ever?) moved namespaces. It also allows me to continue creating
custom/personal versions of plugins in my namespace, particularly in cases
where the original author is no longer updating their plugin.
Installation
The simplest way to install AutoLoader is to use pip
:
pip install minchin.pelican.plugins.autoloader
Configuration
If you are running Pelican 4.5 or newer, and haven’t manually defined PLUGINS
in your pelicanconf.py
site configuration file, nothing more is needed:
AutoLoader will autoload itself :) Without further configuration, it will
autoload any installed plugins in the minchin.pelican.plugins
namespace (and
Pelican itself will autoload any installed plugins in the pelican.plugins
namespace).
If you are using a older version of Pelican (i.e. before v4.5) and/or you have
defined PLUGINS
, you’ll need to add AutoLoader to your list of plugins,
like this:
# pelicanconf.py
from minchin.pelican.plugins import autoloader
PLUGINS = [
# others...
autoloader,
]
If you want to add additional namespaces for AutoLoader to work from, define
AUTOLOADER_NAMESPACES
(as a list or other iterable) in your pelicanconf.py
file. For example, if you want to autoload the pelican.plugins
namespace
(useful if you’re still using Pelican 3.7 or 4.2 or have defined PLUGINS
, and
the configuration this site is currently using):
# pelicanconf.py
from minchin.pelican.plugins import autoloader
AUTOLOADER_NAMESPACES = autoloader.DEFAULT_NAMESPACE_LIST + [
"pelican.plugins",
# other namespaces
]
This Release
v1.0.2 is the first public release. Earlier version numbers got “eaten” making sure the version pushed to PyPI would work as expected.
Known Issues
- the release machinery used relies on
invoke
, which has not yet been updated to be compatible with Python 3.10. Beyond pushing out releases, this plugin should work with Python 3.10. - plugins activated by AutoLoader do not show running
pelican-plugins
. (pelican-plugins
was a script added by Pelican 4.5 to show namespace plugins currently active). AutoLoader however should be itself listed (although likely aspelican.plugins.autoloader
).
Forward Looking Thoughts
In my last plugin release post, I’d
commented that there were “only 10 more plugins to go!” (i.e. to move to the
pelican.plugins
namespace, and presumably under the
Pelican-Plugins organization on GitHub).
This handily sidesteps those transitions from keeping me from upgrading Pelican
on my personal site! I’m feeling much closer to getting this site upgraded to
the current version of Pelican.
I plan on making releases of my other plugins shortly to rely on this and to update the installation instructions to that end.
Comments
There are no comments yet. Will you add the first one?