makepatch 0.2.0__py3-none-any.whl → 0.2.5__py3-none-any.whl

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.
makepatch/__init__.py CHANGED
@@ -1,2 +1 @@
1
- from .__hook__ import hatch_register_build_hook
2
- from .hooks import PatcherBuildHook
1
+ from .hooks import PatcherBuildHook
makepatch/hooks/_patch.py CHANGED
@@ -1,60 +1,61 @@
1
- from typing import override
2
-
3
- from hatchling.builders.hooks.plugin.interface import BuildHookInterface
4
-
5
- import shutil
6
-
7
- from makepatch._config import PatcherConfig
8
- from makepatch.core import PatchApplier
9
-
10
- if __debug__ and __import__("typing").TYPE_CHECKING:
11
- from typing import Any, Final
12
-
13
-
14
- class PatcherBuildHook(BuildHookInterface):
15
- PLUGIN_NAME = "makepatch"
16
-
17
- def __init__(self, /, *args, **kwargs):
18
- super().__init__(*args, **kwargs)
19
- self.__config: Final = PatcherConfig.from_hatch(self)
20
- self.__patcher: Final = PatchApplier(self.__config)
21
-
22
- @override
23
- def initialize(self, version: str, build_data: dict[str, Any]) -> None:
24
- config = self.__config
25
- patcher = self.__patcher
26
-
27
- if patcher.setup_required():
28
- patcher.resolve_sources()
29
- patcher.resolve_src()
30
-
31
- dst = config.project_root / "work/patched"
32
- if dst.exists():
33
- if not dst.is_dir(): raise RuntimeError(f"{dst} is not a directory")
34
- shutil.rmtree(dst)
35
- dst.mkdir(parents=True)
36
-
37
- patcher.copy(dst)
38
- patcher.apply(dst / config.module_source)
39
- self.__success = False
40
- return
41
-
42
- patcher.resolve_src()
43
-
44
- dst = self.__dst = config.project_root / "src" / config.module_name
45
- if dst.exists():
46
- if not dst.is_dir(): raise RuntimeError(f"{dst} is not a directory")
47
- shutil.rmtree(dst)
48
- dst.mkdir(parents=True)
49
-
50
- patcher.copy(dst)
51
- self.__success = patcher.apply(dst)
52
-
53
- @override
54
- def finalize(self, version: str, build_data: dict[str, Any], artifact_path: str) -> None:
55
- if not self.__success:
56
- return
57
-
58
- if not self.__dst.exists() or not self.__dst.is_dir():
59
- raise RuntimeError(f"{self.__dst} does not exists or is not a directory")
60
- shutil.rmtree(self.__dst)
1
+ from typing import override
2
+
3
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
4
+
5
+ import shutil
6
+
7
+ from makepatch._config import PatcherConfig
8
+ from makepatch.core import PatchApplier
9
+
10
+ if __debug__ and __import__("typing").TYPE_CHECKING:
11
+ from typing import Any, Final
12
+
13
+
14
+ class PatcherBuildHook(BuildHookInterface):
15
+ PLUGIN_NAME = "makepatch"
16
+
17
+ def __init__(self, /, *args, **kwargs):
18
+ super().__init__(*args, **kwargs)
19
+ self.__config: Final = PatcherConfig.from_hatch(self)
20
+ self.__patcher: Final = PatchApplier(self.__config)
21
+
22
+ @override
23
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
24
+ config = self.__config
25
+ patcher = self.__patcher
26
+
27
+ if patcher.setup_required():
28
+ patcher.resolve_sources()
29
+ patcher.resolve_src()
30
+
31
+ dst = config.project_root / "work/patched"
32
+ if dst.exists():
33
+ if not dst.is_dir(): raise RuntimeError(f"{dst} is not a directory")
34
+ shutil.rmtree(dst)
35
+ dst.mkdir(parents=True)
36
+
37
+ patcher.copy(dst)
38
+ patcher.apply(dst / config.module_source)
39
+ self.__success = False
40
+ return
41
+
42
+ patcher.resolve_src()
43
+
44
+ dst = self.__dst = config.project_root / "src" / config.module_name
45
+ if dst.exists():
46
+ if not dst.is_dir(): raise RuntimeError(f"{dst} is not a directory")
47
+ shutil.rmtree(dst)
48
+ dst.mkdir(parents=True)
49
+
50
+ patcher.copy(dst)
51
+ self.__success = patcher.apply(dst)
52
+ build_data["force_include"][str(dst.relative_to(config.project_root))] = dst.name
53
+
54
+ @override
55
+ def finalize(self, version: str, build_data: dict[str, Any], artifact_path: str) -> None:
56
+ if not self.__success:
57
+ return
58
+
59
+ if not self.__dst.exists() or not self.__dst.is_dir():
60
+ raise RuntimeError(f"{self.__dst} does not exists or is not a directory")
61
+ shutil.rmtree(self.__dst)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: makepatch
3
- Version: 0.2.0
3
+ Version: 0.2.5
4
4
  Summary: Hatch build hook to easily hard-fork packages with patches!
5
5
  Project-URL: source, https://github.com/AlphaKR93/packages/tree/main/python/makepatch
6
6
  Project-URL: issues, https://github.com/AlphaKR93/packages/issues
@@ -1,15 +1,15 @@
1
1
  makepatch/__hooks__.py,sha256=Twwvsdvf5-wFb4aqUD9ApiTj_hpf_kOh_nedyX4a5yE,163
2
- makepatch/__init__.py,sha256=VGfjjIEpPnILrFlZqLzYhbUL6tqmhx1-e9uZOuVpQh4,86
2
+ makepatch/__init__.py,sha256=fOrYHKD0SUUvbJBX8T7g3unWGKFo_aVS_TtixjjKcjg,36
3
3
  makepatch/_config.py,sha256=OA0SPKb8R5Q00cs6DwDu79kN6gW8vnDrKGvp6DCUfG8,2492
4
4
  makepatch/_types/__init__.pyi,sha256=SlDWSyq8IncNQKcgvjc9F7jyqKjTCSLW4HLTxgsSYcM,39
5
5
  makepatch/_types/hatch.pyi,sha256=MWAwNXZx1RXrdZ8sVLY8pinoOleSajjDatylnFsLprQ,1604
6
6
  makepatch/core/__init__.py,sha256=F943qvL-FwY0zkSuMxHuVzG55EVDICJYouAE1-3NrOU,36
7
7
  makepatch/core/_patcher.py,sha256=m5IsO66AC40i7rpHH1y5PE5VFW390svgZxA4SIw1930,4403
8
8
  makepatch/hooks/__init__.py,sha256=I7QNThkPOzPtvQiocyUoQKKdWNYWk5wiF-FVRz4LTjo,38
9
- makepatch/hooks/_patch.py,sha256=kSuzOjyeYTWEO457e5ikZI5RN8KGn22n5BVQEj1GOL8,1971
9
+ makepatch/hooks/_patch.py,sha256=Wazt-MSXuDEFbAkqBJZ1YgaTN34dfyqm8wnhesNjoOU,2001
10
10
  makepatch/scripts/__init__.py,sha256=dggERiHtxr-wWJ6sHvfsfW3a9a3Io3CmNd7xvIC5AnY,769
11
11
  makepatch/scripts/_rebuild.py,sha256=iisw0dza8cr4o_FBvzcrNGmxeeje98XW2g6dHlJqsJ0,2810
12
- makepatch-0.2.0.dist-info/METADATA,sha256=Cp_Qi2UyIpNqoKsvTNebZNtXQT2XQrTIOgnmPZI_hRE,1003
13
- makepatch-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
14
- makepatch-0.2.0.dist-info/entry_points.txt,sha256=tDk_T8AJNcjy0KhBEXxf9wZBIAhv3l4pGekKOqXpNpY,159
15
- makepatch-0.2.0.dist-info/RECORD,,
12
+ makepatch-0.2.5.dist-info/METADATA,sha256=qXOkKka0-rANOI6yzKEaVKEJSVd35n_CoRTvTqzz5jM,1003
13
+ makepatch-0.2.5.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
14
+ makepatch-0.2.5.dist-info/entry_points.txt,sha256=tDk_T8AJNcjy0KhBEXxf9wZBIAhv3l4pGekKOqXpNpY,159
15
+ makepatch-0.2.5.dist-info/RECORD,,