{"id":3215,"library":"plux","title":"Plux Dynamic Code Loading Framework","description":"Plux is a dynamic code loading framework for building pluggable Python distributions. It facilitates the discovery and loading of plugins defined via Python entry points, streamlining the process of creating extensible applications. The current version is 1.16.0, and the library maintains an active release cadence with several updates per year.","status":"active","version":"1.16.0","language":"en","source_language":"en","source_url":"https://github.com/localstack/plux","tags":["plugin","dynamic loading","entry points","framework","extensibility"],"install":[{"cmd":"pip install plux","lang":"bash","label":"Install core library"},{"cmd":"pip install plux[hatchling]","lang":"bash","label":"Install with Hatchling support"},{"cmd":"pip install plux[setuptools]","lang":"bash","label":"Install with Setuptools support"}],"dependencies":[],"imports":[{"symbol":"PluginManager","correct":"from plux.manager import PluginManager"},{"symbol":"global_plugin_filter","correct":"from plux.runtime.filter import global_plugin_filter"}],"quickstart":{"code":"import sys\nfrom plux.manager import PluginManager\n\n# --- In a real project, you would define your plugin entry point in pyproject.toml ---\n# For example, in 'my_project/pyproject.toml':\n#\n# [project.entry-points.\"my.plugins\"]\n# my_example_plugin = \"my_project.plugins:MyExamplePlugin\"\n#\n# And have a 'my_project/plugins.py' file:\n# class MyExamplePlugin:\n#     def run(self):\n#         return \"MyExamplePlugin is running!\"\n#\n# Then install your project in editable mode: `pip install -e .`\n#\n# --- This quickstart assumes such a plugin is discoverable ---\n\n# Instantiate the PluginManager for a specific namespace\n# Replace 'my.plugins' with your actual entry point group name\nmanager = PluginManager(\"my.plugins\")\n\nprint(f\"Searching for plugins in namespace 'my.plugins'...\")\nfound_plugins = list(manager.discover())\n\nif not found_plugins:\n    print(\"No plugins discovered. Ensure a plugin is defined via entry points and installed.\")\n    print(\"Refer to the comments in this quickstart for typical setup steps.\")\nelse:\n    print(f\"Discovered {len(found_plugins)} plugin(s):\")\n    for name, plugin_class in found_plugins:\n        print(f\" - Name: {name}, Class: {plugin_class.__name__}\")\n        try:\n            plugin_instance = plugin_class()\n            if hasattr(plugin_instance, 'run'):\n                result = plugin_instance.run()\n                print(f\"   Instance result: {result}\")\n        except Exception as e:\n            print(f\"   Could not instantiate or run plugin {name}: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to use `plux.manager.PluginManager` to discover plugins. `plux` relies on Python entry points, typically defined in your project's `pyproject.toml` (or `setup.py`). For the example code to discover actual plugins, you need to define an entry point (e.g., under `[project.entry-points.\"my.plugins\"]`) and ensure your project is installed in a way that makes its entry points discoverable (e.g., `pip install -e .`). The provided code will run without error, but will only report discovered plugins if they are set up externally."},"warnings":[{"fix":"Review your entry point definitions and any code interacting with `stevedore` via Plux. Ensure plugins are correctly defined via standard `pyproject.toml` or `setup.py` entry points and no longer rely on `stevedore`-specific internal mechanisms. The new resolution is designed to be more robust for editable installs.","message":"Prior to v1.10.0, Plux used `stevedore` for entry point resolution. This dependency was removed in v1.10.0, along with a complete rewrite of the resolution procedure. Projects relying on `stevedore`-specific behaviors or directly interacting with it through Plux will break.","severity":"breaking","affected_versions":"<1.10.0"},{"fix":"Ensure your project's `pyproject.toml` or `setup.py` entry point definitions align with current best practices for `plux` and your chosen build backend. Consider installing `plux` with the relevant extra (e.g., `pip install plux[hatchling]`) if your project uses a non-default build system or specific build features.","message":"From v1.14.0 onwards, Plux has added explicit support for `hatchling` and `setuptools` build backends, including new `entrypoint build modes` and configuration options. Incompatible build system configurations or reliance on outdated entry point definition styles may lead to plugins not being discovered.","severity":"gotcha","affected_versions":">=1.14.0"},{"fix":"If plugins are unexpectedly absent, check `plux.runtime.filter.global_plugin_filter` for any active patterns that might be blocking your plugins. Use `global_plugin_filter.remove_pattern()` or `global_plugin_filter.clear()` if necessary to debug discovery issues.","message":"Introduced in v1.11.0, `plux.runtime.filter.global_plugin_filter` allows filtering plugins by namespace patterns. If filters are inadvertently applied or misconfigured, expected plugins may not be discovered without clear error messages, leading to silent failures.","severity":"gotcha","affected_versions":">=1.11.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}