patch-package-py
A Python package patching tool that allows you to make and apply patches to third-party packages in your virtual environment.
Installation
uv add patch-package-py
Agent skill
This repository includes an agent skill for AI agents that support agent skills.
Usage
The tool provides three main commands via the p12y CLI:
1. Create a patch workspace
p12y patch <package_name>
This command:
- Resolves the package from an environment path
- if omitted, it detects from the current directory (
/.venv)
- if omitted, it detects from the current directory (
- Creates a temporary virtual environment
- Installs the same version of the package without dependencies
- Sets up a git repository for tracking changes
- Provides a path where you can edit the package files
Example:
p12y patch requests [-e <environment-path>]
2. Commit changes and create patch file
p12y commit <edit_path> [--skip-restore]
After editing the package files, use this command to:
- Generate a git diff of your changes
- Create a
.patchfile in thepatches/directory - Reinstall the original package in the target environment
- Apply the new patch to the target environment
Example:
p12y commit /tmp/patch-requests-2.28.1-abc123/venv/lib/python3.11/site-packages/requests
Use --skip-restore to write the patch file and apply it to the current target
environment directly.
3. Apply patches
p12y apply [-e <environment-path>]
This command:
- Looks for
.patchfiles in thepatches/directory - Applies them to the packages in the environment path
- if omitted, it detects from the current directory (
/.venv)
- if omitted, it detects from the current directory (
- Reports success/failure for each patch
Workflow
- Prepare for patching: Run
p12y patch <package_name>to set up a workspace - Make your changes: Edit the files in the provided path
- Create the patch: Run
p12y commit <path>to generate the patch file - Apply patches: Run
p12y applyin your project to apply all patches
How it works
- Uses
uvfor fast virtual environment creation and package installation - Leverages git for tracking changes and generating diffs
- Reinstalls the target package during
commitbefore applying the newly generated patch - Stores patch files in a
patches/directory in your project root - Patch files are named using the format:
<package-name>+<version>.patch
Using with Poetry
- Detect the environment path using
poetry env info --path. - Use the
-e/--env-pathoption forpatchandapply. commitreuses the environment path recorded bypatch -e.
p12y patch requests -e "$(poetry env info --path)"
p12y commit <edit_path>
p12y apply -e "$(poetry env info --path)"
Requirements
- Python ≥ 3.9
uvpackage managergitversion control systempatchutility (typically pre-installed on Unix-like systems)- for windows you can install
- using chocolatey:
choco install patch - using winget
winget install --id=GnuWin32.Patch -e - or it might be packed with cygwin.
- using chocolatey:
- for windows you can install
License
MIT
Metadata
Release files for patch-package-py 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| patch_package_py-0.2.1.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| patch_package_py-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / patch_package_py-0.2.1.tar.gz
| Download URL | patch_package_py-0.2.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5addd8c4c897bf7795496f3148d4470f84a4abbebdcab06cea2213a4303de67
|
|
BLAKE2b-256 checksum How to use checksums |
ce6c1a15f563b8506b5fe4edbcd70836d4c481704518aeb5bc5c79602656083e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 31, 2026.
Transparency logRelease files / patch_package_py-0.2.1-py3-none-any.whl
| Download URL | patch_package_py-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
135054c5eb112377c67adcbd7e4502007c24a94d2cd98b5a6fa119fe60ae693e
|
|
BLAKE2b-256 checksum How to use checksums |
876c8cd23d431ee1a3ccbfa2ac9ced565c9df1b91fe51119b1b008e6588131ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 31, 2026.
Transparency log