Skip to main content
https://codecov.io/github/python-lml/lml/coverage.png https://badge.fury.io/py/lml.svg https://pepy.tech/badge/lml/month https://img.shields.io/github/stars/python-lml/lml.svg?style=social&maxAge=3600&label=Star https://img.shields.io/static/v1?label=continuous%20templating&message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0&color=blue&style=flat-square https://img.shields.io/static/v1?label=coding%20style&message=black&color=black&style=flat-square https://readthedocs.org/projects/lml/badge/?version=latest

lml seamlessly finds the lml based plugins from your current python environment but loads your plugins on demand. It is designed to support plugins that have external dependencies, especially bulky and/or memory hungry ones. lml provides the plugin management system only and the plugin interface is on your shoulder.

lml enabled applications helps your customers [1] in two ways:

  1. Your customers could cherry-pick the plugins from pypi per python environment. They could remove a plugin using pip uninstall command.

  2. Only the plugins used at runtime gets loaded into computer memory.

When you would use lml to refactor your existing code, it aims to flatten the complexity and to shrink the size of your bulky python library by distributing the similar functionalities across its plugins. However, you as the developer need to do the code refactoring by yourself and lml would lend you a hand.

Quick start

The following code tries to get you started quickly with non-lazy loading.

from lml.plugin import PluginInfo, PluginManager


@PluginInfo("cuisine", tags=["Portable Battery"])
class Boost(object):
    def make(self, food=None, **keywords):
        print("I can cook %s for robots" % food)


class CuisineManager(PluginManager):
    def __init__(self):
        PluginManager.__init__(self, "cuisine")

    def get_a_plugin(self, food_name=None, **keywords):
        return PluginManager.get_a_plugin(self, key=food_name, **keywords)


if __name__ == '__main__':
    manager = CuisineManager()
    chef = manager.get_a_plugin("Portable Battery")
    chef.make()

At a glance, above code simply replaces the Factory pattern should you write them without lml. What’s not obvious is, that once you got hands-on with it, you can start work on how to do lazy loading.

Installation

You can install lml via pip:

$ pip install lml

or clone it and install it:

$ git clone https://github.com/python-lml/lml.git
$ cd lml
$ python setup.py install

lml enabled project

Beyond the documentation above, here is a list of projects using lml:

  1. pyexcel

  2. pyecharts

  3. moban

lml is available on these distributions:

  1. ARCH linux

  2. Conda forge

  3. OpenSuse

License

New BSD

Change log

0.2.0 - 16/03/2025

Updated

  1. replace __import__ with importlib

Removed

  1. removed python 2 support

0.1.0 - 21/10/2020

Updated

  1. non class object can be a plugin too

  2. #20: When a plugin was not installed, it now calls raise_exception method

0.0.9 - 7/1/2019

Updated

  1. #11: more test contents for OpenSuse package validation

0.0.8 - 4/1/2019

Updated

  1. #9: include tests, docs for OpenSuse package validation

0.0.7 - 17/11/2018

Fixed

  1. #8: get_primary_key will fail when a module is loaded later

  2. deprecated old style plugin scanner: scan_plugins

0.0.6 - 07/11/2018

Fixed

  1. Revert the version 0.0.5 changes. Raise Import error and log the exception

0.0.5 - 06/11/2018

Fixed

  1. #6: Catch and Ignore ModuleNotFoundError

0.0.4 - 07.08.2018

Added

  1. #4: to find plugin names with different naming patterns

0.0.3 - 12/06/2018

Added

  1. dict can be a pluggable type in addition to function, class

  2. get primary tag of your tag, helping you find out which category of plugins your tag points to

0.0.2 - 23/10/2017

Updated

  1. pyexcel#103: include LICENSE in tar ball

0.0.1 - 30/05/2017

Added

  1. First release

Release files for lml 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lml 0.2.0
File Size Uploaded
lml-0.2.0.tar.gz 41.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lml 0.2.0
File Interpreter ABI Platform
lml-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 52.5 kB

Release files / lml-0.2.0.tar.gz

Download URL lml-0.2.0.tar.gz
Size 41.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8dd5afb4367a593d1cdb2144a05874cd9938f5266bebb0c9e1413200423c0d74
BLAKE2b-256 checksum
How to use checksums
2e338043c7050233e889df10365d32838b276fc51464cc70f9abbb97c92771d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 16, 2025.

Transparency log

Release files / lml-0.2.0-py2.py3-none-any.whl

Download URL lml-0.2.0-py2.py3-none-any.whl
Size 10.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
20c80728189e46e8d986f5d0cdf6d83c493471fc25b1c31a8cb3fa96e80b58f8
BLAKE2b-256 checksum
How to use checksums
c8dac649f3d09155660bcc5bf4f7fb59effae968e4ffd872cdd738f0b6932400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 16, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page