Registry / devops / autowrapt

autowrapt

JSON →
library1.0pypypiunverified

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.

pip install autowrapt
INSTALL
IMPORT
SIG · AUTOWRAPT
A
autowrapt
devopspythonv1.0
Install
2.8s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.8s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

autowrapt.bootstrap
N/A (activated via env var)
Autowrapt's primary function is activated via the AUTOWRAPT_BOOTSTRAP environment variable, not by direct import into user application code. Internally, `autowrapt.bootstrap` contains the core logic.

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
Debug
Known issues
breakingIncorrect installation method can prevent autowrapt from working. Using `python setup.py install` or `easy_install` can cause the critical `.pth` file to be installed incorrectly (e.g., inside an egg directory), preventing activation.
fix
Always install `autowrapt` using `pip` (e.g., `pip install autowrapt` or `pip install -e .` for development).
affects: All versions
gotchaMonkey patching, especially using `.pth` files, is a powerful technique that runs code early in the Python interpreter's startup. This can introduce hard-to-debug issues related to import order, unexpected side effects, and security concerns as code runs implicitly.
fix
Thoroughly test patched applications. Be aware of the 'ordering problem' where other code might import a module before the patch can be applied. Consider explicit patching with `wrapt` if implicit global patching is not strictly necessary. For security, be cautious about installing packages that leverage `.pth` files.
affects: All versions
gotchaThe `autowrapt` project itself has not been updated since 2015 (version 1.0). While its core dependency `wrapt` is actively maintained, `autowrapt` may not fully leverage the latest features or address edge cases in newer Python versions or `wrapt` versions beyond what was available in 2015.
fix
Review the GitHub repository for any open issues or discussions related to compatibility with modern Python versions (e.g., Python 3.9+). Consider whether its specific approach is still the best fit for current project needs or if manual `wrapt` usage or other patching techniques are more appropriate.
affects: All versions
Upgrade
Version history
1.0latest on PyPI · released Apr 9, 2015
Audit
Dependencies
wraptrequiredAutowrapt depends on `wrapt` for its underlying transparent object proxy and monkey patching capabilities.
Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
autowrapt — pip install autowrapt · libregistry