patch 3rd party Python packages
Project description
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
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 your current virtual environment (
.venv) - 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
2. Commit changes and create patch file
p12y commit <edit_path>
After editing the package files, use this command to:
- Generate a git diff of your changes
- Create a
.patchfile in thepatches/directory - Test that the patch can be applied successfully
Example:
p12y commit /tmp/patch-requests-2.28.1-abc123/venv/lib/python3.11/site-packages/requests
3. Apply patches
p12y apply
This command:
- Looks for
.patchfiles in thepatches/directory - Applies them to the packages in your current virtual environment (
.venv) - 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
- Stores patch files in a
patches/directory in your project root - Patch files are named using the format:
<package-name>+<version>.patch
Requirements
- Python ≥ 3.9
uvpackage managergitversion control systempatchutility (typically pre-installed on Unix-like systems)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patch_package_py-0.1.2.tar.gz.
File metadata
- Download URL: patch_package_py-0.1.2.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
078bf1f3ce6d172e8880dabb41e4a37c7a3680f008373de65dd9c6ebadfdc309
|
|
| MD5 |
a47c37ad701b01794e266c00c5b9cde7
|
|
| BLAKE2b-256 |
032188155d5aef797fde637ad5b589309584f9a46426e2427ce6b2f1a3ee22cb
|
File details
Details for the file patch_package_py-0.1.2-py3-none-any.whl.
File metadata
- Download URL: patch_package_py-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7dd4d63f862a8f6031d956e030a77771b9b5fc2b815d2bb20807731b67c7869
|
|
| MD5 |
3f155c0aa12bf641bafc2ebe6ce8e074
|
|
| BLAKE2b-256 |
f145afe7fdca6bee3174e2c6899ce046f7bc8f0b38e3e0a4acce4adcfee49aae
|