lml - Load Me Later
lml is a Python library that provides a lazy plugin management system. It seamlessly finds lml-based plugins in the Python environment but loads them only on demand, making it suitable for plugins with bulky or memory-hungry external dependencies. The current version is 0.2.0, with releases occurring periodically, the latest being March 2025.
Warnings
- breaking lml dropped official support for Python 2 in version 0.2.0. Users on Python 2.x must use an older version of the library.
- gotcha lml provides the plugin management system but does not dictate the plugin interface. Developers are responsible for defining their own plugin interfaces (e.g., base classes or expected methods for plugins).
Install
-
pip install lml
Imports
- PluginInfo
from lml.plugin import PluginInfo
- PluginManager
from lml.plugin import PluginManager
Quickstart
from lml.plugin import PluginInfo, PluginManager
@PluginInfo("cuisine", tags=["Portable Battery"])
class Boost(object):
def make(self, food=None, **keywords):
print(f"I can cook {food} for robots")
class CuisineManager(PluginManager):
def __init__(self):
PluginManager.__init__(self, "cuisine")
def get_a_plugin(self, food_name=None, **keywords):
# 'key' is the primary key used during registration, often the first tag
return PluginManager.get_a_plugin(self, key=food_name, **keywords)
if __name__ == '__main__':
manager = CuisineManager()
chef = manager.get_a_plugin("Portable Battery")
if chef:
chef.make(food="Portable Battery")
else:
print("No chef found for Portable Battery")