Designing a plugin architecture in Python
summary
A Python codegen tool gains runtime extensions by two concrete patterns: load a plugin file with importlib.spec_from_file_location, execute it, use inspect.getmembers to pick out callables, and inject them into the Jinja/Ginger environment filters dict; or publish parsers via importlib.metadata.entry_points where package metadata maps file suffix → callable and the app resolves by suffix. The talk demonstrates both patterns with a camel-case filter implementation and YAML/JSON parser examples and explains lookup versus registration.
AI-written summary · about
chapters (6)
- 0:00Introduction and speaker background
- 3:05Why use a plugin architecture
- 4:35Real-world plugin example at Intel
- 7:28Dynamic filter loading with importlib
- 12:13Entry points for data parsers
- 16:34Recap and benefits of plugins
related talks
27mPlugin ecosystems for Python web-applications
44mHow to design and implement extensible software with plugins with Simon Willison
23mBuild plugins using Pluggy
19mPatterns for Extensibility
10mArchitecting Native Python Extension Modules
59mA Study of Plugin Architectures for Supporting Extensible Software
30mImporting Without "import": Behind the Scenes of importlib
29mMetaprogramming with Decorators, Metaclasses, and Dynamic Code Generation
