patch-package-py 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,3 +8,4 @@ wheels/
8
8
 
9
9
  # Virtual environments
10
10
  .venv
11
+ .coverage
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patch-package-py
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: patch 3rd party Python packages
5
5
  Project-URL: Homepage, https://github.com/nomyfan/patch-package-py
6
6
  Project-URL: Repository, https://github.com/nomyfan/patch-package-py
@@ -15,6 +15,8 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
18
20
  Requires-Python: >=3.9
19
21
  Description-Content-Type: text/markdown
20
22
 
@@ -40,7 +42,8 @@ p12y patch <package_name>
40
42
 
41
43
  This command:
42
44
 
43
- - Resolves the package from your current virtual environment (`.venv`)
45
+ - Resolves the package from an environment path
46
+ - if omitted, it detects from the current directory (`/.venv`)
44
47
  - Creates a temporary virtual environment
45
48
  - Installs the same version of the package without dependencies
46
49
  - Sets up a git repository for tracking changes
@@ -49,7 +52,7 @@ This command:
49
52
  Example:
50
53
 
51
54
  ```bash
52
- p12y patch requests
55
+ p12y patch requests [-e <environment-path>]
53
56
  ```
54
57
 
55
58
  ### 2. Commit changes and create patch file
@@ -73,13 +76,14 @@ p12y commit /tmp/patch-requests-2.28.1-abc123/venv/lib/python3.11/site-packages/
73
76
  ### 3. Apply patches
74
77
 
75
78
  ```bash
76
- p12y apply
79
+ p12y apply [-e <environment-path>]
77
80
  ```
78
81
 
79
82
  This command:
80
83
 
81
84
  - Looks for `.patch` files in the `patches/` directory
82
- - Applies them to the packages in your current virtual environment (`.venv`)
85
+ - Applies them to the packages in the environment path
86
+ - if omitted, it detects from the current directory (`/.venv`)
83
87
  - Reports success/failure for each patch
84
88
 
85
89
  ## Workflow
@@ -96,12 +100,21 @@ This command:
96
100
  - Stores patch files in a `patches/` directory in your project root
97
101
  - Patch files are named using the format: `<package-name>+<version>.patch`
98
102
 
103
+ ## Using with poetry
104
+
105
+ - detect the environment path using `poetry show -v`
106
+ - use the -e / --env-path option for patch and/or apply.
107
+
99
108
  ## Requirements
100
109
 
101
110
  - Python ≥ 3.9
102
111
  - `uv` package manager
103
112
  - `git` version control system
104
113
  - `patch` utility (typically pre-installed on Unix-like systems)
114
+ - for windows you can install
115
+ - using chocolatey: `choco install patch`
116
+ - using winget `winget install --id=GnuWin32.Patch -e`
117
+ - or it might be packed with cygwin.
105
118
 
106
119
  ## License
107
120
 
@@ -20,7 +20,8 @@ p12y patch <package_name>
20
20
 
21
21
  This command:
22
22
 
23
- - Resolves the package from your current virtual environment (`.venv`)
23
+ - Resolves the package from an environment path
24
+ - if omitted, it detects from the current directory (`/.venv`)
24
25
  - Creates a temporary virtual environment
25
26
  - Installs the same version of the package without dependencies
26
27
  - Sets up a git repository for tracking changes
@@ -29,7 +30,7 @@ This command:
29
30
  Example:
30
31
 
31
32
  ```bash
32
- p12y patch requests
33
+ p12y patch requests [-e <environment-path>]
33
34
  ```
34
35
 
35
36
  ### 2. Commit changes and create patch file
@@ -53,13 +54,14 @@ p12y commit /tmp/patch-requests-2.28.1-abc123/venv/lib/python3.11/site-packages/
53
54
  ### 3. Apply patches
54
55
 
55
56
  ```bash
56
- p12y apply
57
+ p12y apply [-e <environment-path>]
57
58
  ```
58
59
 
59
60
  This command:
60
61
 
61
62
  - Looks for `.patch` files in the `patches/` directory
62
- - Applies them to the packages in your current virtual environment (`.venv`)
63
+ - Applies them to the packages in the environment path
64
+ - if omitted, it detects from the current directory (`/.venv`)
63
65
  - Reports success/failure for each patch
64
66
 
65
67
  ## Workflow
@@ -76,12 +78,21 @@ This command:
76
78
  - Stores patch files in a `patches/` directory in your project root
77
79
  - Patch files are named using the format: `<package-name>+<version>.patch`
78
80
 
81
+ ## Using with poetry
82
+
83
+ - detect the environment path using `poetry show -v`
84
+ - use the -e / --env-path option for patch and/or apply.
85
+
79
86
  ## Requirements
80
87
 
81
88
  - Python ≥ 3.9
82
89
  - `uv` package manager
83
90
  - `git` version control system
84
91
  - `patch` utility (typically pre-installed on Unix-like systems)
92
+ - for windows you can install
93
+ - using chocolatey: `choco install patch`
94
+ - using winget `winget install --id=GnuWin32.Patch -e`
95
+ - or it might be packed with cygwin.
85
96
 
86
97
  ## License
87
98
 
File without changes
@@ -1,17 +1,18 @@
1
1
  import argparse
2
+ import logging
2
3
  import sys
4
+ from logging import getLogger
3
5
  from pathlib import Path
4
- from patch_package_py import (
5
- prepare_patch_workspace,
6
- commit_changes,
7
- apply_patch,
6
+
7
+ from patch_package_py.core import (
8
+ CLI_NAME,
9
+ PATCH_INFO_FILE,
8
10
  Resolver,
11
+ apply_patch,
12
+ commit_changes,
9
13
  find_site_packages,
10
- PATCH_INFO_FILE,
11
- CLI_NAME,
14
+ prepare_patch_workspace,
12
15
  )
13
- from logging import getLogger
14
- import logging
15
16
 
16
17
  logger = getLogger(__name__)
17
18
  logging.basicConfig(level=logging.INFO, format="%(message)s")
@@ -20,7 +21,12 @@ logging.basicConfig(level=logging.INFO, format="%(message)s")
20
21
  def cmd_patch(args):
21
22
  package_name = args.package
22
23
  resolver = Resolver()
23
- package = resolver.resolve_in_venv(Path.cwd() / ".venv", package_name)
24
+
25
+ env_path = (
26
+ Path(args.env_path) if args.env_path is not None else Path.cwd() / ".venv"
27
+ )
28
+
29
+ package = resolver.resolve_in_venv(env_path, package_name)
24
30
  if not package:
25
31
  logger.error(
26
32
  "Error: No package found",
@@ -46,7 +52,7 @@ def cmd_commit(args):
46
52
  text=True,
47
53
  check=True,
48
54
  ).stdout.strip()
49
- with open(Path(git_dir) / PATCH_INFO_FILE, "r") as f:
55
+ with open(Path(git_dir) / PATCH_INFO_FILE) as f:
50
56
  import json
51
57
 
52
58
  info = json.load(f)
@@ -59,7 +65,11 @@ def cmd_commit(args):
59
65
 
60
66
  def cmd_apply(args):
61
67
  patches_dir = Path.cwd() / "patches"
62
- site_packages_dir = find_site_packages(Path.cwd() / ".venv")
68
+
69
+ env_path = (
70
+ Path(args.env_path) if args.env_path is not None else Path.cwd() / ".venv"
71
+ )
72
+ site_packages_dir = find_site_packages(env_path)
63
73
 
64
74
  if not patches_dir.exists():
65
75
  return
@@ -92,6 +102,7 @@ def cli():
92
102
  "patch", help="Prepare for patching a package"
93
103
  )
94
104
  workspace_parser.add_argument("package", help="Package name")
105
+ workspace_parser.add_argument("-e", "--env-path", help="Environment Path")
95
106
  workspace_parser.set_defaults(func=cmd_patch)
96
107
 
97
108
  # commit command
@@ -103,6 +114,7 @@ def cli():
103
114
 
104
115
  # apply command
105
116
  apply_parser = subparsers.add_parser("apply", help="Apply patches")
117
+ apply_parser.add_argument("-e", "--env-path", help="Environment Path")
106
118
  apply_parser.set_defaults(func=cmd_apply)
107
119
 
108
120
  args = parser.parse_args()
@@ -1,10 +1,11 @@
1
- from pathlib import Path, PurePosixPath
2
- import tempfile
3
1
  import os
2
+ import posixpath
4
3
  import subprocess
5
4
  import sys
5
+ import tempfile
6
6
  from logging import getLogger
7
- import posixpath
7
+ from pathlib import Path, PurePosixPath
8
+ from typing import Union
8
9
 
9
10
  logger = getLogger(__name__)
10
11
 
@@ -30,13 +31,13 @@ def find_site_packages(venv: Path) -> Path:
30
31
  class Resolver:
31
32
  def resolve_in_venv(
32
33
  self, venv: Path, package_name: str
33
- ) -> tuple[PurePosixPath, str] | None:
34
+ ) -> Union[tuple[PurePosixPath, str], None]:
34
35
  site_packages_path = find_site_packages(venv)
35
36
  return self.resolve_in_site_packages(site_packages_path, package_name)
36
37
 
37
38
  def resolve_in_site_packages(
38
39
  self, site_packages_path: Path, package_name: str
39
- ) -> tuple[PurePosixPath, str] | None:
40
+ ) -> Union[tuple[PurePosixPath, str], None]:
40
41
  dist_info = list(
41
42
  site_packages_path.glob(f"{package_name.replace('-', '_')}-*.dist-info")
42
43
  )
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "patch-package-py"
3
- version = "0.1.3"
3
+ version = "0.1.4"
4
4
  description = "patch 3rd party Python packages"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -16,6 +16,8 @@ classifiers = [
16
16
  "Programming Language :: Python :: 3.10",
17
17
  "Programming Language :: Python :: 3.11",
18
18
  "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
19
21
  ]
20
22
 
21
23
  [project.urls]
@@ -30,5 +32,31 @@ p12y = "patch_package_py.cli:cli"
30
32
  requires = ["hatchling"]
31
33
  build-backend = "hatchling.build"
32
34
 
35
+ [tool.hatch.build.targets.wheel]
36
+ packages = ["patch_package_py"]
37
+
38
+ [tool.hatch.build.targets.sdist]
39
+ include = ["/patch_package_py", "/README.md", "/pyproject.toml"]
40
+
33
41
  [dependency-groups]
34
- dev = ["pyright>=1.1.405", "ruff>=0.12.12"]
42
+ dev = ["pyright>=1.1.405", "ruff>=0.12.12", "pytest>=8.0", "pytest-cov>=7.0.0"]
43
+
44
+ [tool.ruff]
45
+ target-version = "py39"
46
+ line-length = 88
47
+
48
+ [tool.ruff.lint]
49
+ select = ["E", "F", "I", "UP", "B", "SIM"]
50
+ ignore = ["E501"]
51
+
52
+ [tool.ruff.format]
53
+ quote-style = "double"
54
+
55
+ [tool.pyright]
56
+ pythonVersion = "3.9"
57
+ include = ["patch_package_py"]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ python_files = ["test_*.py"]
62
+ python_functions = ["test_*"]
@@ -1 +0,0 @@
1
- 3.12
@@ -1,2 +0,0 @@
1
- from .core import * # noqa: F403
2
- from .cli import cli as cli
@@ -1,79 +0,0 @@
1
- version = 1
2
- revision = 2
3
- requires-python = ">=3.9"
4
-
5
- [[package]]
6
- name = "nodeenv"
7
- version = "1.9.1"
8
- source = { registry = "https://pypi.org/simple" }
9
- sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" }
10
- wheels = [
11
- { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" },
12
- ]
13
-
14
- [[package]]
15
- name = "patch-package-py"
16
- version = "0.1.2"
17
- source = { editable = "." }
18
-
19
- [package.dev-dependencies]
20
- dev = [
21
- { name = "pyright" },
22
- { name = "ruff" },
23
- ]
24
-
25
- [package.metadata]
26
-
27
- [package.metadata.requires-dev]
28
- dev = [
29
- { name = "pyright", specifier = ">=1.1.405" },
30
- { name = "ruff", specifier = ">=0.12.12" },
31
- ]
32
-
33
- [[package]]
34
- name = "pyright"
35
- version = "1.1.405"
36
- source = { registry = "https://pypi.org/simple" }
37
- dependencies = [
38
- { name = "nodeenv" },
39
- { name = "typing-extensions" },
40
- ]
41
- sdist = { url = "https://files.pythonhosted.org/packages/fb/6c/ba4bbee22e76af700ea593a1d8701e3225080956753bee9750dcc25e2649/pyright-1.1.405.tar.gz", hash = "sha256:5c2a30e1037af27eb463a1cc0b9f6d65fec48478ccf092c1ac28385a15c55763", size = 4068319, upload-time = "2025-09-04T03:37:06.776Z" }
42
- wheels = [
43
- { url = "https://files.pythonhosted.org/packages/d5/1a/524f832e1ff1962a22a1accc775ca7b143ba2e9f5924bb6749dce566784a/pyright-1.1.405-py3-none-any.whl", hash = "sha256:a2cb13700b5508ce8e5d4546034cb7ea4aedb60215c6c33f56cec7f53996035a", size = 5905038, upload-time = "2025-09-04T03:37:04.913Z" },
44
- ]
45
-
46
- [[package]]
47
- name = "ruff"
48
- version = "0.12.12"
49
- source = { registry = "https://pypi.org/simple" }
50
- sdist = { url = "https://files.pythonhosted.org/packages/a8/f0/e0965dd709b8cabe6356811c0ee8c096806bb57d20b5019eb4e48a117410/ruff-0.12.12.tar.gz", hash = "sha256:b86cd3415dbe31b3b46a71c598f4c4b2f550346d1ccf6326b347cc0c8fd063d6", size = 5359915, upload-time = "2025-09-04T16:50:18.273Z" }
51
- wheels = [
52
- { url = "https://files.pythonhosted.org/packages/09/79/8d3d687224d88367b51c7974cec1040c4b015772bfbeffac95face14c04a/ruff-0.12.12-py3-none-linux_armv6l.whl", hash = "sha256:de1c4b916d98ab289818e55ce481e2cacfaad7710b01d1f990c497edf217dafc", size = 12116602, upload-time = "2025-09-04T16:49:18.892Z" },
53
- { url = "https://files.pythonhosted.org/packages/c3/c3/6e599657fe192462f94861a09aae935b869aea8a1da07f47d6eae471397c/ruff-0.12.12-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:7acd6045e87fac75a0b0cdedacf9ab3e1ad9d929d149785903cff9bb69ad9727", size = 12868393, upload-time = "2025-09-04T16:49:23.043Z" },
54
- { url = "https://files.pythonhosted.org/packages/e8/d2/9e3e40d399abc95336b1843f52fc0daaceb672d0e3c9290a28ff1a96f79d/ruff-0.12.12-py3-none-macosx_11_0_arm64.whl", hash = "sha256:abf4073688d7d6da16611f2f126be86523a8ec4343d15d276c614bda8ec44edb", size = 12036967, upload-time = "2025-09-04T16:49:26.04Z" },
55
- { url = "https://files.pythonhosted.org/packages/e9/03/6816b2ed08836be272e87107d905f0908be5b4a40c14bfc91043e76631b8/ruff-0.12.12-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:968e77094b1d7a576992ac078557d1439df678a34c6fe02fd979f973af167577", size = 12276038, upload-time = "2025-09-04T16:49:29.056Z" },
56
- { url = "https://files.pythonhosted.org/packages/9f/d5/707b92a61310edf358a389477eabd8af68f375c0ef858194be97ca5b6069/ruff-0.12.12-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:42a67d16e5b1ffc6d21c5f67851e0e769517fb57a8ebad1d0781b30888aa704e", size = 11901110, upload-time = "2025-09-04T16:49:32.07Z" },
57
- { url = "https://files.pythonhosted.org/packages/9d/3d/f8b1038f4b9822e26ec3d5b49cf2bc313e3c1564cceb4c1a42820bf74853/ruff-0.12.12-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b216ec0a0674e4b1214dcc998a5088e54eaf39417327b19ffefba1c4a1e4971e", size = 13668352, upload-time = "2025-09-04T16:49:35.148Z" },
58
- { url = "https://files.pythonhosted.org/packages/98/0e/91421368ae6c4f3765dd41a150f760c5f725516028a6be30e58255e3c668/ruff-0.12.12-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:59f909c0fdd8f1dcdbfed0b9569b8bf428cf144bec87d9de298dcd4723f5bee8", size = 14638365, upload-time = "2025-09-04T16:49:38.892Z" },
59
- { url = "https://files.pythonhosted.org/packages/74/5d/88f3f06a142f58ecc8ecb0c2fe0b82343e2a2b04dcd098809f717cf74b6c/ruff-0.12.12-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ac93d87047e765336f0c18eacad51dad0c1c33c9df7484c40f98e1d773876f5", size = 14060812, upload-time = "2025-09-04T16:49:42.732Z" },
60
- { url = "https://files.pythonhosted.org/packages/13/fc/8962e7ddd2e81863d5c92400820f650b86f97ff919c59836fbc4c1a6d84c/ruff-0.12.12-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:01543c137fd3650d322922e8b14cc133b8ea734617c4891c5a9fccf4bfc9aa92", size = 13050208, upload-time = "2025-09-04T16:49:46.434Z" },
61
- { url = "https://files.pythonhosted.org/packages/53/06/8deb52d48a9a624fd37390555d9589e719eac568c020b27e96eed671f25f/ruff-0.12.12-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2afc2fa864197634e549d87fb1e7b6feb01df0a80fd510d6489e1ce8c0b1cc45", size = 13311444, upload-time = "2025-09-04T16:49:49.931Z" },
62
- { url = "https://files.pythonhosted.org/packages/2a/81/de5a29af7eb8f341f8140867ffb93f82e4fde7256dadee79016ac87c2716/ruff-0.12.12-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:0c0945246f5ad776cb8925e36af2438e66188d2b57d9cf2eed2c382c58b371e5", size = 13279474, upload-time = "2025-09-04T16:49:53.465Z" },
63
- { url = "https://files.pythonhosted.org/packages/7f/14/d9577fdeaf791737ada1b4f5c6b59c21c3326f3f683229096cccd7674e0c/ruff-0.12.12-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:a0fbafe8c58e37aae28b84a80ba1817f2ea552e9450156018a478bf1fa80f4e4", size = 12070204, upload-time = "2025-09-04T16:49:56.882Z" },
64
- { url = "https://files.pythonhosted.org/packages/77/04/a910078284b47fad54506dc0af13839c418ff704e341c176f64e1127e461/ruff-0.12.12-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:b9c456fb2fc8e1282affa932c9e40f5ec31ec9cbb66751a316bd131273b57c23", size = 11880347, upload-time = "2025-09-04T16:49:59.729Z" },
65
- { url = "https://files.pythonhosted.org/packages/df/58/30185fcb0e89f05e7ea82e5817b47798f7fa7179863f9d9ba6fd4fe1b098/ruff-0.12.12-py3-none-musllinux_1_2_i686.whl", hash = "sha256:5f12856123b0ad0147d90b3961f5c90e7427f9acd4b40050705499c98983f489", size = 12891844, upload-time = "2025-09-04T16:50:02.591Z" },
66
- { url = "https://files.pythonhosted.org/packages/21/9c/28a8dacce4855e6703dcb8cdf6c1705d0b23dd01d60150786cd55aa93b16/ruff-0.12.12-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:26a1b5a2bf7dd2c47e3b46d077cd9c0fc3b93e6c6cc9ed750bd312ae9dc302ee", size = 13360687, upload-time = "2025-09-04T16:50:05.8Z" },
67
- { url = "https://files.pythonhosted.org/packages/c8/fa/05b6428a008e60f79546c943e54068316f32ec8ab5c4f73e4563934fbdc7/ruff-0.12.12-py3-none-win32.whl", hash = "sha256:173be2bfc142af07a01e3a759aba6f7791aa47acf3604f610b1c36db888df7b1", size = 12052870, upload-time = "2025-09-04T16:50:09.121Z" },
68
- { url = "https://files.pythonhosted.org/packages/85/60/d1e335417804df452589271818749d061b22772b87efda88354cf35cdb7a/ruff-0.12.12-py3-none-win_amd64.whl", hash = "sha256:e99620bf01884e5f38611934c09dd194eb665b0109104acae3ba6102b600fd0d", size = 13178016, upload-time = "2025-09-04T16:50:12.559Z" },
69
- { url = "https://files.pythonhosted.org/packages/28/7e/61c42657f6e4614a4258f1c3b0c5b93adc4d1f8575f5229d1906b483099b/ruff-0.12.12-py3-none-win_arm64.whl", hash = "sha256:2a8199cab4ce4d72d158319b63370abf60991495fb733db96cd923a34c52d093", size = 12256762, upload-time = "2025-09-04T16:50:15.737Z" },
70
- ]
71
-
72
- [[package]]
73
- name = "typing-extensions"
74
- version = "4.15.0"
75
- source = { registry = "https://pypi.org/simple" }
76
- sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
77
- wheels = [
78
- { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
79
- ]