Using Python's import machinery to handle API deprecations
summary
A demonstration of using Python's importlib to implement backward-compatible API deprecations by intercepting imports and redirecting moved, split, or removed modules and attributes. It covers importlib-based techniques to keep deprecated import paths functional (with deprecation warnings) so a single codebase can serve both old and new layouts without maintaining duplicate packages. The approach is practical and extensible for maintainers facing large codebase restructures.
AI-written summary · about
chapters (9)
- 0:00Start
- 9:28The Great IDAES Module Relocation
- 16:03Looking for a deal with the import system
- 22:12Make sure our Finder knows about our relocation mapping
- 23:30Find the spec for the new import path using a Finder for source files
- 24:36Step 4: Create the spec for the old import using the file location from the new
- 26:19Adding a notification for the client
- 26:56Activating the Finder
- 29:41Library code: Enable compatibility from environment
related talks
27mHow We Migrated 3.8 Million Lines of Python 2 Without Interrupting Deve...
35mUpgrading Legacy Projects: Lessons Learned
38mA Developer's-Eye View of API Client Libraries
26mModules 101: how to avoid spaghetti, big balls of mud and houses of straw!
34mKeeping up with Python: what makes upgrades hard, and what can we do about it
57mTechnology mix: From legacy to clean architecture
24mPython for Humans, Designing Python Code Like a User Interface
18mAutomating Product Deprecation
