makepatch 0.2.0__tar.gz → 0.2.5__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.
@@ -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
@@ -12,7 +12,7 @@ rebuild-patches = "makepatch.scripts:rebuild_patches"
12
12
 
13
13
  [project]
14
14
  name = "makepatch"
15
- version = "0.2.0"
15
+ version = "0.2.5"
16
16
  authors = [{ name = "Alpha", email = "dev@alpha93.kr" }]
17
17
  description = "Hatch build hook to easily hard-fork packages with patches!"
18
18
  license = "MIT"
@@ -0,0 +1 @@
1
+ from .hooks import PatcherBuildHook
@@ -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,2 +0,0 @@
1
- from .__hook__ import hatch_register_build_hook
2
- from .hooks import PatcherBuildHook
File without changes
File without changes
File without changes