patch-package is a Python library to automatically create and apply patches from changes made in installed packages. It is heavily inspired by patch-package which is the equivalent for Node packages.
- Compatible with Python 3.8+
- Automatic code change detection between installed package and package source from pip
- Prevent patching when version or code are mismatching
- Automatic matching between import names and package names (e.g. yaml -> PyYAML) and fuzzy matching (e.g. request -> requests)
Install the library from PyPI
pip install patch-package
Make a change in one of your installed package and then generate the corresponding patch
patch-package <package-name>
Then when reinstalling the package you can apply back your patches
patch-package
All patches are contained in the patches/ folder so it can be commited to git and reapply whenever you want
Install the library in editable mode
uv pip install -e .
Do whatever modifications you want and file a pull request, thanks !