11from __future__ import annotations
22
3- from logging import getLogger
4- from os import getenv
53from pathlib import Path
64from platform import machine as platform_machine
75from sys import platform as sys_platform , version_info
108from hatch_build import parse_extra_args_model
119from hatchling .builders .hooks .plugin .interface import BuildHookInterface
1210
13- from .config import HatchCppBuildConfig , HatchCppBuildPlan
11+ from .config import HatchCppBuildConfig , HatchCppBuildPlan , log
1412from .utils import import_string
1513
1614__all__ = ("HatchCppBuildHook" ,)
@@ -20,7 +18,7 @@ class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
2018 """The hatch-cpp build hook."""
2119
2220 PLUGIN_NAME = "hatch-cpp"
23- _logger = getLogger ( __name__ )
21+ _logger = log
2422
2523 def initialize (self , version : str , build_data : dict [str , Any ]) -> None :
2624 """Initialize the plugin."""
@@ -35,12 +33,6 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
3533 self ._logger .info ("ignoring target name %s" , self .target_name )
3634 return
3735
38- # Skip if SKIP_HATCH_CPP is set
39- # TODO: Support CLI once https://github.com/pypa/hatch/pull/1743
40- if getenv ("SKIP_HATCH_CPP" ):
41- self ._logger .info ("Skipping the build hook since SKIP_HATCH_CPP was set" )
42- return
43-
4436 # Get build config class or use default
4537 build_config_class = import_string (self .config ["build-config-class" ]) if "build-config-class" in self .config else HatchCppBuildConfig
4638
@@ -60,10 +52,14 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
6052 build_plan .generate ()
6153
6254 # Log commands if in verbose mode
63- if config .verbose :
55+ if build_plan .verbose :
6456 for command in build_plan .commands :
6557 self ._logger .warning (command )
6658
59+ if build_plan .skip :
60+ self ._logger .warning ("Skipping build" )
61+ return
62+
6763 # Execute build plan
6864 build_plan .execute ()
6965
@@ -114,4 +110,4 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
114110 build_data ["force_include" ][str (path )] = str (path )
115111
116112 for path in build_data ["force_include" ]:
117- self ._logger .warning (f"Force include: { path } " )
113+ self ._logger .info (f"Force include: { path } " )
0 commit comments