-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.py
More file actions
46 lines (33 loc) · 1.38 KB
/
plugin.py
File metadata and controls
46 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from __future__ import annotations
import logging
import os
import typing as t
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from .structs import HatchCppBuildConfig, HatchCppBuildPlan
__all__ = ("HatchCppBuildHook",)
class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
"""The hatch-cpp build hook."""
PLUGIN_NAME = "hatch-cpp"
_logger = logging.getLogger(__name__)
def initialize(self, version: str, _: dict[str, t.Any]) -> None:
"""Initialize the plugin."""
self._logger.info("Running hatch-cpp")
if self.target_name != "wheel":
self._logger.info("ignoring target name %s", self.target_name)
return
if os.getenv("SKIP_HATCH_CPP"):
self._logger.info("Skipping the build hook since SKIP_HATCH_CPP was set")
return
config = HatchCppBuildConfig(**self.config)
libraries = config.libraries
platform = config.platform
if config.toolchain == "raw":
build_plan = HatchCppBuildPlan(libraries=libraries, platform=platform)
build_plan.generate()
if config.verbose:
for command in build_plan.commands:
self._logger.info(command)
build_plan.execute()
build_plan.cleanup()
self._logger.info("Finished running hatch-cpp")
return