skillfed

whatthepatch

A patch parsing and application library.

whatthepatch v1.0.7 2.6M downloads/30d#2,962 on PyPI78
Permissive license Active released

What it is and what it does

What The Patch is a Python library for parsing patch files and applying them to text. It reads diffs in standard formats (unified, context, normal, ed, rcs) and from source control systems (Git, SVN, CVS), extracting the changes into structured data that describes which lines were added, removed, or kept unchanged. You can then apply those changes to a file's text to reconstruct the patched version.

The library has been stable since its 1.0 release and requires no external dependencies. It works by default without needing the system patch command, though you can opt to use it if available. The maintainer notes that while the functions are reliable, they are not ideally implemented and active development is minimal—pull requests are welcome and will be merged and released, but reported issues may not be fixed.

Use it for:

  • Parse a patch file to inspect what changes it contains before applying it to your codebase.
  • Apply a Git, SVN, or CVS patch to text in memory without invoking external tools.
  • Build a tool that needs to understand or manipulate diffs programmatically.
  • Validate patch compatibility or extract metadata from patch files.
  • Reconstruct a modified version of a file by applying a stored patch to the original text.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses and applies patch files in multiple diff formats (unified, context, normal, ed, rcs) and from several source control systems (Git, SVN, CVS).

Yes. The library is stable, has no dependencies, and solves a clear problem—parsing and applying patches—with low friction. The permissive license and active repository maintenance make it safe to rely on. The caveat is that the maintainer does not actively fix reported issues, so verify that the documented formats cover your use case before adopting it.

Install

whatthepatch on PyPI

pip

pip install whatthepatch

uv

uv add whatthepatch

poetry

poetry add whatthepatch

Installing whatthepatch

Before you install

Low install friction with no runtime dependencies. Maintenance is active but minimal—the library has been stable for years with infrequent updates; pull requests are accepted and released, but issues may not be addressed by the maintainer.

License in practice

Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.

Quickstart

pip install whatthepatch

import whatthepatch
with open('somechanges.patch') as f:
    text = f.read()
for diff in whatthepatch.parse_patch(text):
    result = whatthepatch.apply_diff(diff, original_text)

Verify before relying

  • Whether the library handles all real-world patch edge cases or only the documented diff formats
  • Performance characteristics when parsing or applying very large patch files

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 636 days since the last release
Last repo commit
First released
Downloads 2,648,129/month — #2,962 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: whatthepatch-1.0.7-py3-none-any.whl

Keywords: patch, diff, parser

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Version ControlTopic :: Text Processing

Tags

patch file parserdiff parsing libraryapply patch to textunified diff parsergit patch parserversion control diff
diff-parsingpatch-application

More Software Development packages