Skip to main content

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 .patch file in the patches/ 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 .patch files in the patches/ directory
  • Applies them to the packages in your current virtual environment (.venv)
  • Reports success/failure for each patch

Workflow

  1. Prepare for patching: Run p12y patch <package_name> to set up a workspace
  2. Make your changes: Edit the files in the provided path
  3. Create the patch: Run p12y commit <path> to generate the patch file
  4. Apply patches: Run p12y apply in your project to apply all patches

How it works

  • Uses uv for 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
  • uv package manager
  • git version control system
  • patch utility (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

patch_package_py-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patch_package_py-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file patch_package_py-0.1.0.tar.gz.

File metadata

  • Download URL: patch_package_py-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for patch_package_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 457be209c1c595d9e73998b070d3eb9d5c228c2c349f6fbd704638c57a9701b3
MD5 5844cb492ecb806c57b318a8c63eda6b
BLAKE2b-256 b7d34ab0d0dcdf563b8717c784fc935c06fc66c795b904ff9cd284348e16ce36

See more details on using hashes here.

File details

Details for the file patch_package_py-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for patch_package_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf72c17ca197bc6c48d58ab18ec88b225507fc8d0391c727521077582741dc2f
MD5 e87370f599a5ce9e21ecfae55bb65707
BLAKE2b-256 07795bd4b4f49dc688e0c5465e4365b852a8a98b162dcd64581137610c142a6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page