Autowrapt

1.0 · maintenance · verified Thu Apr 16

Autowrapt is a Python library designed to provide a bootstrap mechanism for applying monkey patches to applications without requiring direct modification of the application's source code. It achieves this by working in conjunction with the `wrapt` module and leveraging setuptools entry points, activated via the `AUTOWRAPT_BOOTSTRAP` environment variable. The current version is 1.0, released in 2015, and it functions as a stable utility in maintenance mode, with its core dependency `wrapt` being actively maintained.

Common errors

Warnings

Install

Imports

Quickstart

Autowrapt applies patches via environment variables and setuptools entry points. To quickly test, first define a patch in a module (e.g., `my_patch.py` with `def add_zen_line(module): print('The wrapt package is absolutely amazing and you should use it.')`). Then, in a `setup.py` in the same directory, register this as an entry point: `entry_points={'autowrapt.examples': ['my_patch = my_patch:add_zen_line']}`. Install your package in editable mode (`pip install -e .`). Finally, run your Python script with the `AUTOWRAPT_BOOTSTRAP` environment variable set to activate your patch. This example demonstrates patching Python's `this` module to add an extra line to the Zen of Python.

import this

view raw JSON →