pypatch-url


Namepypatch-url JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummaryUtility to apply unified diff patches (possibly from URLs) to installed python modules (with --strip support).
upload_time2025-07-27 13:38:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT
keywords build tool patch unified diff
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pypatch-url
===========

Automatically apply patches to third-party libraries as part of your build.

Now and again, a specific fix is needed for a python package that isn't available from the vendor/community.
This project was created to allow a way for us to patch specific python modules during the build process.

pypatch-url is a fork of Sitka Technology Group's PyPatch tool, which itself is a command wrapper based around Anatoly Techtonik's patch.py utility. This fork adds two important features that were already present in the underlying patch.py utility but weren't accessible from the command line:

1. **Path stripping** with `-p NUM` or `--strip=NUM` to strip leading components from file names (matching the standard Unix `patch` tool)
2. **URL support** to automatically download patches when a URL is specified instead of a local file path

These enhancements were contributed by sfinktah@github.spamtrak.org, although the underlying functionality already existed in Anatoly Techtonik's patch.py library.

Usage
---
```
pypatch-url apply custom_diff.patch [library.package]```
With the new options:
```

pypatch-url apply -p 1 custom_diff.patch [library.package]  # Strip one directory level from paths
pypatch-url apply https://example.com/patches/fix.patch [library.package]  # Download and apply patch
```
As a part of the work flow:
```

c:\project\pip install django
c:\project\pip install pypatch-url
c:\project\pypatch-url apply c:\project\patches\my_auth_fix.patch django.contrib.auth
```
How it works
------------
pypatch-url applies patches to files relative to the root directory of the named package. So it does have to be installed into the target environment.

For example, if the django package was installed to "C:\Python27\Lib\site-packages\django" and you needed to patch the auth contrib package (django.contrib.auth), your command might look like
```
pypatch-url apply c:\project\patches\my_auth_fix.patch django.contrib.auth```
and the files named in my_auth_fix.patch would use relative pathing from the package directory:
```

--- models.py    2013-05-06 15:12:14.212220100 -0700
+++ models.py	2013-05-06 14:36:20.535220100 -0700
```
If you used
```
pypatch-url apply c:\project\patches\my_auth_fix.patch django.contrib```
instead, your diff patch would read
```

--- auth/models.py	2013-05-06 15:12:14.212220100 -0700
+++ auth/models.py	2013-05-06 14:36:20.535220100 -0700
```
Path Stripping
-------------
The `-p NUM` or `--strip=NUM` option allows you to strip leading path components from file names in the patch. This is especially useful when applying patches created from different directory structures:
```

pypatch-url apply -p 1 c:\project\patches\my_fix.patch django
```
This would strip the first directory component from each path in the patch file.

URL Support
----------
You can directly specify a URL instead of a local patch file:
```

pypatch-url apply https://example.com/patches/fix.patch django
```
This will automatically download the patch file from the URL and apply it to the specified module.

Build
-----
To build the distributable python package, run 'sdist' from the Project Root Directory.
Recommended: setting the output directory to our Libraries folder
```
sdist --dist-dir="C:\outputdir"```
This will build the zipped python package that can be installed via pip or easy_install

Other
-----
Information on the Unified Diff format can be found at
https://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html#Unified-Format

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pypatch-url",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "build, tool, patch, unified, diff",
    "author": null,
    "author_email": "sfinktah <sfinktah@github.spamtrak.org>",
    "download_url": "https://files.pythonhosted.org/packages/69/a6/f08df21a88dd14c2da2add0385493ada86d97c8de2e252df3754a3ff0e91/pypatch_url-1.0.3.tar.gz",
    "platform": null,
    "description": "pypatch-url\r\n===========\r\n\r\nAutomatically apply patches to third-party libraries as part of your build.\r\n\r\nNow and again, a specific fix is needed for a python package that isn't available from the vendor/community.\r\nThis project was created to allow a way for us to patch specific python modules during the build process.\r\n\r\npypatch-url is a fork of Sitka Technology Group's PyPatch tool, which itself is a command wrapper based around Anatoly Techtonik's patch.py utility. This fork adds two important features that were already present in the underlying patch.py utility but weren't accessible from the command line:\r\n\r\n1. **Path stripping** with `-p NUM` or `--strip=NUM` to strip leading components from file names (matching the standard Unix `patch` tool)\r\n2. **URL support** to automatically download patches when a URL is specified instead of a local file path\r\n\r\nThese enhancements were contributed by sfinktah@github.spamtrak.org, although the underlying functionality already existed in Anatoly Techtonik's patch.py library.\r\n\r\nUsage\r\n---\r\n```\r\npypatch-url apply custom_diff.patch [library.package]```\r\nWith the new options:\r\n```\r\n\r\npypatch-url apply -p 1 custom_diff.patch [library.package]  # Strip one directory level from paths\r\npypatch-url apply https://example.com/patches/fix.patch [library.package]  # Download and apply patch\r\n```\r\nAs a part of the work flow:\r\n```\r\n\r\nc:\\project\\pip install django\r\nc:\\project\\pip install pypatch-url\r\nc:\\project\\pypatch-url apply c:\\project\\patches\\my_auth_fix.patch django.contrib.auth\r\n```\r\nHow it works\r\n------------\r\npypatch-url applies patches to files relative to the root directory of the named package. So it does have to be installed into the target environment.\r\n\r\nFor example, if the django package was installed to \"C:\\Python27\\Lib\\site-packages\\django\" and you needed to patch the auth contrib package (django.contrib.auth), your command might look like\r\n```\r\npypatch-url apply c:\\project\\patches\\my_auth_fix.patch django.contrib.auth```\r\nand the files named in my_auth_fix.patch would use relative pathing from the package directory:\r\n```\r\n\r\n--- models.py    2013-05-06 15:12:14.212220100 -0700\r\n+++ models.py\t2013-05-06 14:36:20.535220100 -0700\r\n```\r\nIf you used\r\n```\r\npypatch-url apply c:\\project\\patches\\my_auth_fix.patch django.contrib```\r\ninstead, your diff patch would read\r\n```\r\n\r\n--- auth/models.py\t2013-05-06 15:12:14.212220100 -0700\r\n+++ auth/models.py\t2013-05-06 14:36:20.535220100 -0700\r\n```\r\nPath Stripping\r\n-------------\r\nThe `-p NUM` or `--strip=NUM` option allows you to strip leading path components from file names in the patch. This is especially useful when applying patches created from different directory structures:\r\n```\r\n\r\npypatch-url apply -p 1 c:\\project\\patches\\my_fix.patch django\r\n```\r\nThis would strip the first directory component from each path in the patch file.\r\n\r\nURL Support\r\n----------\r\nYou can directly specify a URL instead of a local patch file:\r\n```\r\n\r\npypatch-url apply https://example.com/patches/fix.patch django\r\n```\r\nThis will automatically download the patch file from the URL and apply it to the specified module.\r\n\r\nBuild\r\n-----\r\nTo build the distributable python package, run 'sdist' from the Project Root Directory.\r\nRecommended: setting the output directory to our Libraries folder\r\n```\r\nsdist --dist-dir=\"C:\\outputdir\"```\r\nThis will build the zipped python package that can be installed via pip or easy_install\r\n\r\nOther\r\n-----\r\nInformation on the Unified Diff format can be found at\r\nhttps://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html#Unified-Format\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utility to apply unified diff patches (possibly from URLs) to installed python modules (with --strip support).",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "http://sitkatech.com"
    },
    "split_keywords": [
        "build",
        " tool",
        " patch",
        " unified",
        " diff"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "69a6f08df21a88dd14c2da2add0385493ada86d97c8de2e252df3754a3ff0e91",
                "md5": "589b04a6298e9462050d8fc2f8f2f6c1",
                "sha256": "fd12874ed078392190fa693bf25667e4fb4ba3ed43e0d013dea27284e45b75d7"
            },
            "downloads": -1,
            "filename": "pypatch_url-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "589b04a6298e9462050d8fc2f8f2f6c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 21395,
            "upload_time": "2025-07-27T13:38:58",
            "upload_time_iso_8601": "2025-07-27T13:38:58.487502Z",
            "url": "https://files.pythonhosted.org/packages/69/a6/f08df21a88dd14c2da2add0385493ada86d97c8de2e252df3754a3ff0e91/pypatch_url-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-27 13:38:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pypatch-url"
}
        
Elapsed time: 1.42633s