hatch-cpp 0.1.6__tar.gz → 0.1.7__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.
Files changed (43) hide show
  1. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/.gitignore +1 -0
  2. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/PKG-INFO +2 -1
  3. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/__init__.py +1 -1
  4. hatch_cpp-0.1.7/hatch_cpp/plugin.py +113 -0
  5. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/structs.py +92 -25
  6. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/CMakeLists.txt +92 -0
  7. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/Makefile +140 -0
  8. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/pyproject.toml +39 -0
  9. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.cpp +5 -0
  10. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.hpp +17 -0
  11. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_projects.py +9 -1
  12. hatch_cpp-0.1.7/hatch_cpp/tests/test_structs.py +48 -0
  13. hatch_cpp-0.1.7/hatch_cpp/toolchains/cmake.py +0 -0
  14. hatch_cpp-0.1.7/hatch_cpp/utils.py +12 -0
  15. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/pyproject.toml +3 -2
  16. hatch_cpp-0.1.6/hatch_cpp/plugin.py +0 -91
  17. hatch_cpp-0.1.6/hatch_cpp/tests/test_structs.py +0 -26
  18. hatch_cpp-0.1.6/hatch_cpp/utils.py +0 -132
  19. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/LICENSE +0 -0
  20. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/README.md +0 -0
  21. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/hooks.py +0 -0
  22. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_basic/cpp/project/basic.cpp +0 -0
  23. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_basic/cpp/project/basic.hpp +0 -0
  24. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_basic/project/__init__.py +0 -0
  25. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_basic/pyproject.toml +0 -0
  26. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_limited_api → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake}/cpp/project/basic.cpp +0 -0
  27. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_limited_api → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake}/cpp/project/basic.hpp +0 -0
  28. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_limited_api → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake}/project/__init__.py +0 -0
  29. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_override_classes → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api}/cpp/project/basic.cpp +0 -0
  30. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_override_classes → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api}/cpp/project/basic.hpp +0 -0
  31. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_nanobind → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api}/project/__init__.py +0 -0
  32. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_limited_api/pyproject.toml +0 -0
  33. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.cpp +0 -0
  34. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.hpp +0 -0
  35. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_override_classes → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_nanobind}/project/__init__.py +0 -0
  36. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_nanobind/pyproject.toml +0 -0
  37. {hatch_cpp-0.1.6/hatch_cpp/tests/test_project_pybind → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes}/project/__init__.py +0 -0
  38. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_override_classes/pyproject.toml +0 -0
  39. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_pybind/cpp/project/basic.cpp +0 -0
  40. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_pybind/cpp/project/basic.hpp +0 -0
  41. {hatch_cpp-0.1.6/hatch_cpp/toolchains → hatch_cpp-0.1.7/hatch_cpp/tests/test_project_pybind/project}/__init__.py +0 -0
  42. {hatch_cpp-0.1.6 → hatch_cpp-0.1.7}/hatch_cpp/tests/test_project_pybind/pyproject.toml +0 -0
  43. /hatch_cpp-0.1.6/hatch_cpp/toolchains/cmake.py → /hatch_cpp-0.1.7/hatch_cpp/toolchains/__init__.py +0 -0
@@ -20,6 +20,7 @@ dist/
20
20
  downloads/
21
21
  eggs/
22
22
  .eggs/
23
+ include/
23
24
  lib/
24
25
  lib64/
25
26
  parts/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hatch-cpp
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Hatch plugin for C++ builds
5
5
  Project-URL: Repository, https://github.com/python-project-templates/hatch-cpp
6
6
  Project-URL: Homepage, https://github.com/python-project-templates/hatch-cpp
@@ -30,6 +30,7 @@ Requires-Dist: pybind11; extra == 'develop'
30
30
  Requires-Dist: pytest; extra == 'develop'
31
31
  Requires-Dist: pytest-cov; extra == 'develop'
32
32
  Requires-Dist: ruff<0.9,>=0.3; extra == 'develop'
33
+ Requires-Dist: toml; extra == 'develop'
33
34
  Requires-Dist: twine; extra == 'develop'
34
35
  Requires-Dist: wheel; extra == 'develop'
35
36
  Description-Content-Type: text/markdown
@@ -1,4 +1,4 @@
1
- __version__ = "0.1.6"
1
+ __version__ = "0.1.7"
2
2
 
3
3
  from .hooks import hatch_register_build_hook
4
4
  from .plugin import HatchCppBuildHook
@@ -0,0 +1,113 @@
1
+ from __future__ import annotations
2
+
3
+ from logging import getLogger
4
+ from os import getenv
5
+ from pathlib import Path
6
+ from platform import machine as platform_machine
7
+ from sys import platform as sys_platform, version_info
8
+ from typing import Any
9
+
10
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
11
+
12
+ from .structs import HatchCppBuildConfig, HatchCppBuildPlan
13
+ from .utils import import_string
14
+
15
+ __all__ = ("HatchCppBuildHook",)
16
+
17
+
18
+ class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
19
+ """The hatch-cpp build hook."""
20
+
21
+ PLUGIN_NAME = "hatch-cpp"
22
+ _logger = getLogger(__name__)
23
+
24
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
25
+ """Initialize the plugin."""
26
+ # Log some basic information
27
+ project_name = self.metadata.config["project"]["name"]
28
+ self._logger.info("Initializing hatch-cpp plugin version %s", version)
29
+ self._logger.info(f"Running hatch-cpp: {project_name}")
30
+
31
+ # Only run if creating wheel
32
+ # TODO: Add support for specify sdist-plan
33
+ if self.target_name != "wheel":
34
+ self._logger.info("ignoring target name %s", self.target_name)
35
+ return
36
+
37
+ # Skip if SKIP_HATCH_CPP is set
38
+ # TODO: Support CLI once https://github.com/pypa/hatch/pull/1743
39
+ if getenv("SKIP_HATCH_CPP"):
40
+ self._logger.info("Skipping the build hook since SKIP_HATCH_CPP was set")
41
+ return
42
+
43
+ # Get build config class or use default
44
+ build_config_class = import_string(self.config["build-config-class"]) if "build-config-class" in self.config else HatchCppBuildConfig
45
+
46
+ # Instantiate build config
47
+ config = build_config_class(name=project_name, **self.config)
48
+
49
+ # Get build plan class or use default
50
+ build_plan_class = import_string(self.config["build-plan-class"]) if "build-plan-class" in self.config else HatchCppBuildPlan
51
+
52
+ # Instantiate builder
53
+ build_plan = build_plan_class(**config.model_dump())
54
+
55
+ # Generate commands
56
+ build_plan.generate()
57
+
58
+ # Log commands if in verbose mode
59
+ if config.verbose:
60
+ for command in build_plan.commands:
61
+ self._logger.warning(command)
62
+
63
+ # Execute build plan
64
+ build_plan.execute()
65
+
66
+ # Perform any cleanup actions
67
+ build_plan.cleanup()
68
+
69
+ if build_plan.libraries:
70
+ # force include libraries
71
+ for library in build_plan.libraries:
72
+ name = library.get_qualified_name(build_plan.platform.platform)
73
+ build_data["force_include"][name] = name
74
+
75
+ build_data["pure_python"] = False
76
+ machine = platform_machine()
77
+ version_major = version_info.major
78
+ version_minor = version_info.minor
79
+ if "darwin" in sys_platform:
80
+ os_name = "macosx_11_0"
81
+ elif "linux" in sys_platform:
82
+ os_name = "linux"
83
+ else:
84
+ os_name = "win"
85
+ if all([lib.py_limited_api for lib in build_plan.libraries]):
86
+ build_data["tag"] = f"cp{version_major}{version_minor}-abi3-{os_name}_{machine}"
87
+ else:
88
+ build_data["tag"] = f"cp{version_major}{version_minor}-cp{version_major}{version_minor}-{os_name}_{machine}"
89
+ else:
90
+ build_data["pure_python"] = False
91
+ machine = platform_machine()
92
+ version_major = version_info.major
93
+ version_minor = version_info.minor
94
+ # TODO abi3
95
+ if "darwin" in sys_platform:
96
+ os_name = "macosx_11_0"
97
+ elif "linux" in sys_platform:
98
+ os_name = "linux"
99
+ else:
100
+ os_name = "win"
101
+ build_data["tag"] = f"cp{version_major}{version_minor}-cp{version_major}{version_minor}-{os_name}_{machine}"
102
+
103
+ # force include libraries
104
+ for path in Path(".").rglob("*"):
105
+ if path.is_dir():
106
+ continue
107
+ if str(path).startswith(str(build_plan.cmake.build)) or str(path).startswith("dist"):
108
+ continue
109
+ if path.suffix in (".pyd", ".dll", ".so", ".dylib"):
110
+ build_data["force_include"][str(path)] = str(path)
111
+
112
+ for path in build_data["force_include"]:
113
+ self._logger.warning(f"Force include: {path}")
@@ -1,12 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from os import environ, system
3
+ from os import environ, system as system_call
4
4
  from pathlib import Path
5
5
  from re import match
6
6
  from shutil import which
7
- from sys import executable, platform as sys_platform
7
+ from sys import executable, platform as sys_platform, version_info
8
8
  from sysconfig import get_path
9
- from typing import Any, List, Literal, Optional
9
+ from typing import Any, Dict, List, Literal, Optional
10
10
 
11
11
  from pydantic import AliasChoices, BaseModel, Field, field_validator, model_validator
12
12
 
@@ -20,7 +20,7 @@ __all__ = (
20
20
  BuildType = Literal["debug", "release"]
21
21
  CompilerToolchain = Literal["gcc", "clang", "msvc"]
22
22
  Language = Literal["c", "c++"]
23
- Binding = Literal["cpython", "pybind11", "nanobind"]
23
+ Binding = Literal["cpython", "pybind11", "nanobind", "generic"]
24
24
  Platform = Literal["linux", "darwin", "win32"]
25
25
  PlatformDefaults = {
26
26
  "linux": {"CC": "gcc", "CXX": "g++", "LD": "ld"},
@@ -65,9 +65,9 @@ class HatchCppLibrary(BaseModel, validate_assignment=True):
65
65
 
66
66
  def get_qualified_name(self, platform):
67
67
  if platform == "win32":
68
- suffix = "dll" if self.binding == "none" else "pyd"
68
+ suffix = "dll" if self.binding == "generic" else "pyd"
69
69
  elif platform == "darwin":
70
- suffix = "dylib" if self.binding == "none" else "so"
70
+ suffix = "dylib" if self.binding == "generic" else "so"
71
71
  else:
72
72
  suffix = "so"
73
73
  if self.py_limited_api and platform != "win32":
@@ -78,6 +78,8 @@ class HatchCppLibrary(BaseModel, validate_assignment=True):
78
78
  def check_binding_and_py_limited_api(self):
79
79
  if self.binding == "pybind11" and self.py_limited_api:
80
80
  raise ValueError("pybind11 does not support Py_LIMITED_API")
81
+ if self.binding == "generic" and self.py_limited_api:
82
+ raise ValueError("Generic binding can not support Py_LIMITED_API")
81
83
  return self
82
84
 
83
85
 
@@ -119,7 +121,8 @@ class HatchCppPlatform(BaseModel):
119
121
  flags = ""
120
122
 
121
123
  # Python.h
122
- library.include_dirs.append(get_path("include"))
124
+ if library.binding != "generic":
125
+ library.include_dirs.append(get_path("include"))
123
126
 
124
127
  if library.binding == "pybind11":
125
128
  import pybind11
@@ -217,36 +220,100 @@ class HatchCppPlatform(BaseModel):
217
220
  return flags
218
221
 
219
222
 
220
- class HatchCppBuildPlan(BaseModel):
221
- build_type: BuildType = "release"
223
+ class HatchCppCmakeConfiguration(BaseModel):
224
+ root: Path
225
+ build: Path = Field(default_factory=lambda: Path("build"))
226
+ install: Optional[Path] = Field(default=None)
227
+
228
+ cmake_arg_prefix: Optional[str] = Field(default=None)
229
+ cmake_args: Dict[str, str] = Field(default_factory=dict)
230
+ cmake_env_args: Dict[Platform, Dict[str, str]] = Field(default_factory=dict)
231
+
232
+ include_flags: Optional[Dict[str, Any]] = Field(default=None)
233
+
234
+
235
+ class HatchCppBuildConfig(BaseModel):
236
+ """Build config values for Hatch C++ Builder."""
237
+
238
+ verbose: Optional[bool] = Field(default=False)
239
+ name: Optional[str] = Field(default=None)
222
240
  libraries: List[HatchCppLibrary] = Field(default_factory=list)
223
- platform: HatchCppPlatform = Field(default_factory=HatchCppPlatform.default)
241
+ cmake: Optional[HatchCppCmakeConfiguration] = Field(default=None)
242
+ platform: Optional[HatchCppPlatform] = Field(default_factory=HatchCppPlatform.default)
243
+
244
+ @model_validator(mode="after")
245
+ def check_toolchain_matches_args(self):
246
+ if self.cmake and self.libraries:
247
+ raise ValueError("Must not provide libraries when using cmake toolchain.")
248
+ return self
249
+
250
+
251
+ class HatchCppBuildPlan(HatchCppBuildConfig):
252
+ build_type: BuildType = "release"
224
253
  commands: List[str] = Field(default_factory=list)
225
254
 
226
255
  def generate(self):
227
256
  self.commands = []
228
- for library in self.libraries:
229
- compile_flags = self.platform.get_compile_flags(library, self.build_type)
230
- link_flags = self.platform.get_link_flags(library, self.build_type)
231
- self.commands.append(
232
- f"{self.platform.cc if library.language == 'c' else self.platform.cxx} {' '.join(library.sources)} {compile_flags} {link_flags}"
233
- )
257
+ if self.libraries:
258
+ for library in self.libraries:
259
+ compile_flags = self.platform.get_compile_flags(library, self.build_type)
260
+ link_flags = self.platform.get_link_flags(library, self.build_type)
261
+ self.commands.append(
262
+ f"{self.platform.cc if library.language == 'c' else self.platform.cxx} {' '.join(library.sources)} {compile_flags} {link_flags}"
263
+ )
264
+ elif self.cmake:
265
+ # Derive prefix
266
+ if self.cmake.cmake_arg_prefix is None:
267
+ self.cmake.cmake_arg_prefix = f"{self.name.replace('.', '_').replace('-', '_').upper()}_"
268
+
269
+ # Append base command
270
+ self.commands.append(f"cmake {Path(self.cmake.root).parent} -DCMAKE_BUILD_TYPE={self.build_type} -B {self.cmake.build}")
271
+
272
+ # Setup install path
273
+ if self.cmake.install:
274
+ self.commands[-1] += f" -DCMAKE_INSTALL_PREFIX={self.cmake.install}"
275
+ else:
276
+ self.commands[-1] += f" -DCMAKE_INSTALL_PREFIX={Path(self.cmake.root).parent}"
277
+
278
+ # TODO: CMAKE_CXX_COMPILER
279
+ if self.platform.platform == "win32":
280
+ # TODO: prefix?
281
+ self.commands[-1] += f' -G "{environ.get("GENERATOR", "Visual Studio 17 2022")}"'
282
+
283
+ # Put in CMake flags
284
+ args = self.cmake.cmake_args.copy()
285
+ for platform, env_args in self.cmake.cmake_env_args.items():
286
+ if platform == self.platform.platform:
287
+ for key, value in env_args.items():
288
+ args[key] = value
289
+ for key, value in args.items():
290
+ self.commands[-1] += f" -D{self.cmake.cmake_arg_prefix}{key.upper()}={value}"
291
+
292
+ # Include customs
293
+ if self.cmake.include_flags:
294
+ if self.cmake.include_flags.get("python_version", False):
295
+ self.commands[-1] += f" -D{self.cmake.cmake_arg_prefix}PYTHON_VERSION={version_info.major}.{version_info.minor}"
296
+ if self.cmake.include_flags.get("manylinux", False) and self.platform.platform == "linux":
297
+ self.commands[-1] += f" -D{self.cmake.cmake_arg_prefix}MANYLINUX=ON"
298
+
299
+ # Include mac deployment target
300
+ if self.platform.platform == "darwin":
301
+ self.commands[-1] += f" -DCMAKE_OSX_DEPLOYMENT_TARGET={environ.get('OSX_DEPLOYMENT_TARGET', '11')}"
302
+
303
+ # Append build command
304
+ self.commands.append(f"cmake --build {self.cmake.build} --config {self.build_type}")
305
+
306
+ # Append install command
307
+ self.commands.append(f"cmake --install {self.cmake.build} --config {self.build_type}")
308
+
234
309
  return self.commands
235
310
 
236
311
  def execute(self):
237
312
  for command in self.commands:
238
- system(command)
313
+ system_call(command)
239
314
  return self.commands
240
315
 
241
316
  def cleanup(self):
242
317
  if self.platform.platform == "win32":
243
318
  for temp_obj in Path(".").glob("*.obj"):
244
319
  temp_obj.unlink()
245
-
246
-
247
- class HatchCppBuildConfig(BaseModel):
248
- """Build config values for Hatch C++ Builder."""
249
-
250
- verbose: Optional[bool] = Field(default=False)
251
- libraries: List[HatchCppLibrary] = Field(default_factory=list)
252
- platform: Optional[HatchCppPlatform] = Field(default_factory=HatchCppPlatform.default)
@@ -0,0 +1,92 @@
1
+ cmake_minimum_required(VERSION 3.20.0)
2
+ project(hatch-cpp-test-project-basic VERSION "0.1.0")
3
+ set(CMAKE_CXX_STANDARD 20)
4
+ include(CheckCCompilerFlag)
5
+ include(CheckLinkerFlag)
6
+
7
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
8
+ set(WIN32 ON)
9
+ set(MACOS OFF)
10
+ set(LINUX OFF)
11
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
12
+ set(WIN32 OFF)
13
+ set(MACOS ON)
14
+ set(LINUX OFF)
15
+ else()
16
+ set(WIN32 OFF)
17
+ set(MACOS OFF)
18
+ set(LINUX ON)
19
+ endif()
20
+
21
+ option(CMAKE_BUILD_TYPE "Release/Debug build" RELEASE)
22
+ option(HATCH_CPP_TEST_PROJECT_BASIC_BUILD_TESTS "Build tests" OFF)
23
+ option(HATCH_CPP_TEST_PROJECT_BASIC_MANYLINUX "Build for python's manylinux setup" OFF)
24
+
25
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
26
+
27
+ set(BUILD_SHARED_LIBS TRUE)
28
+ set(CMAKE_MACOSX_RPATH TRUE)
29
+ set(CMAKE_SKIP_RPATH FALSE)
30
+ set(CMAKE_SKIP_BUILD_RPATH FALSE)
31
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
32
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
33
+ set(CMAKE_INSTALL_NAME_DIR "@rpath")
34
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
35
+
36
+ string(REGEX REPLACE "[ ]*-O[^ ]+[ ]*" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
37
+ string(REGEX REPLACE "[ ]*-Wl,-O2 -Wl,[^ ]+[ ]*" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
38
+ string(REGEX REPLACE "[ ]*-Wl,-O2 -Wl,[^ ]+[ ]*" " " CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
39
+
40
+
41
+ if(MACOS)
42
+ set(CMAKE_THREAD_LIBS_INIT "-lpthread")
43
+ set(CMAKE_HAVE_THREADS_LIBRARY 1)
44
+ set(CMAKE_USE_WIN32_THREADS_INIT 0)
45
+ set(CMAKE_USE_PTHREADS_INIT 1)
46
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
47
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
48
+ endif()
49
+
50
+
51
+ if(MACOS)
52
+ set(CMAKE_INSTALL_RPATH "@loader_path/")
53
+ elseif(LINUX)
54
+ set(CMAKE_INSTALL_RPATH "\$ORIGIN")
55
+ endif()
56
+
57
+ if(WIN32)
58
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj")
59
+ foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
60
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}")
61
+ endforeach(warning)
62
+ else()
63
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
64
+ -g \
65
+ -Wall \
66
+ -Werror \
67
+ -Wno-deprecated-declarations \
68
+ -Wno-deprecated \
69
+ ")
70
+ endif()
71
+
72
+
73
+ find_package(Python ${CSP_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development.Module)
74
+ link_directories(${Python_LIBRARY_DIRS})
75
+ include_directories(${Python_INCLUDE_DIRS})
76
+
77
+ set(CMAKE_SHARED_LIBRARY_PREFIX "")
78
+ if(NOT WIN32)
79
+ set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
80
+ else()
81
+ set(CMAKE_SHARED_LIBRARY_SUFFIX .pyd)
82
+ endif()
83
+
84
+ include_directories("${CMAKE_SOURCE_DIR}/cpp")
85
+
86
+ add_library(extension SHARED cpp/project/basic.cpp)
87
+ set_target_properties(extension PROPERTIES PUBLIC_HEADER cpp/project/basic.hpp)
88
+ install(TARGETS extension
89
+ PUBLIC_HEADER DESTINATION project/include/project
90
+ RUNTIME DESTINATION project/
91
+ LIBRARY DESTINATION project/
92
+ )
@@ -0,0 +1,140 @@
1
+ # CMAKE generated file: DO NOT EDIT!
2
+ # Generated by "Unix Makefiles" Generator, CMake Version 3.31
3
+
4
+ # Default target executed when no arguments are given to make.
5
+ default_target: all
6
+ .PHONY : default_target
7
+
8
+ # Allow only one "make -f Makefile2" at a time, but pass parallelism.
9
+ .NOTPARALLEL:
10
+
11
+ #=============================================================================
12
+ # Special targets provided by cmake.
13
+
14
+ # Disable implicit rules so canonical targets will work.
15
+ .SUFFIXES:
16
+
17
+ # Disable VCS-based implicit rules.
18
+ % : %,v
19
+
20
+ # Disable VCS-based implicit rules.
21
+ % : RCS/%
22
+
23
+ # Disable VCS-based implicit rules.
24
+ % : RCS/%,v
25
+
26
+ # Disable VCS-based implicit rules.
27
+ % : SCCS/s.%
28
+
29
+ # Disable VCS-based implicit rules.
30
+ % : s.%
31
+
32
+ .SUFFIXES: .hpux_make_needs_suffix_list
33
+
34
+ # Command-line flag to silence nested $(MAKE).
35
+ $(VERBOSE)MAKESILENT = -s
36
+
37
+ #Suppress display of executed commands.
38
+ $(VERBOSE).SILENT:
39
+
40
+ # A target that is always out of date.
41
+ cmake_force:
42
+ .PHONY : cmake_force
43
+
44
+ #=============================================================================
45
+ # Set environment variables for the build.
46
+
47
+ # The shell in which to execute make rules.
48
+ SHELL = /bin/sh
49
+
50
+ # The CMake executable.
51
+ CMAKE_COMMAND = /opt/homebrew/bin/cmake
52
+
53
+ # The command to remove a file.
54
+ RM = /opt/homebrew/bin/cmake -E rm -f
55
+
56
+ # Escaping for special characters.
57
+ EQUALS = =
58
+
59
+ # The top-level source directory on which CMake was run.
60
+ CMAKE_SOURCE_DIR = /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake
61
+
62
+ # The top-level build directory on which CMake was run.
63
+ CMAKE_BINARY_DIR = /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake
64
+
65
+ #=============================================================================
66
+ # Targets provided globally by CMake.
67
+
68
+ # Special rule for the target edit_cache
69
+ edit_cache:
70
+ @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
71
+ /opt/homebrew/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
72
+ .PHONY : edit_cache
73
+
74
+ # Special rule for the target edit_cache
75
+ edit_cache/fast: edit_cache
76
+ .PHONY : edit_cache/fast
77
+
78
+ # Special rule for the target rebuild_cache
79
+ rebuild_cache:
80
+ @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
81
+ /opt/homebrew/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
82
+ .PHONY : rebuild_cache
83
+
84
+ # Special rule for the target rebuild_cache
85
+ rebuild_cache/fast: rebuild_cache
86
+ .PHONY : rebuild_cache/fast
87
+
88
+ # The main all target
89
+ all: cmake_check_build_system
90
+ $(CMAKE_COMMAND) -E cmake_progress_start /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake/CMakeFiles /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake//CMakeFiles/progress.marks
91
+ $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
92
+ $(CMAKE_COMMAND) -E cmake_progress_start /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake/CMakeFiles 0
93
+ .PHONY : all
94
+
95
+ # The main clean target
96
+ clean:
97
+ $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
98
+ .PHONY : clean
99
+
100
+ # The main clean target
101
+ clean/fast: clean
102
+ .PHONY : clean/fast
103
+
104
+ # Prepare targets for installation.
105
+ preinstall: all
106
+ $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
107
+ .PHONY : preinstall
108
+
109
+ # Prepare targets for installation.
110
+ preinstall/fast:
111
+ $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
112
+ .PHONY : preinstall/fast
113
+
114
+ # clear depends
115
+ depend:
116
+ $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
117
+ .PHONY : depend
118
+
119
+ # Help Target
120
+ help:
121
+ @echo "The following are some of the valid targets for this Makefile:"
122
+ @echo "... all (the default if no target is provided)"
123
+ @echo "... clean"
124
+ @echo "... depend"
125
+ @echo "... edit_cache"
126
+ @echo "... rebuild_cache"
127
+ .PHONY : help
128
+
129
+
130
+
131
+ #=============================================================================
132
+ # Special targets to cleanup operation of make.
133
+
134
+ # Special rule to run CMake to check the build system integrity.
135
+ # No rule that depends on this can have commands that come from listfiles
136
+ # because they might be regenerated.
137
+ cmake_check_build_system:
138
+ $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
139
+ .PHONY : cmake_check_build_system
140
+
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.20"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hatch-cpp-test-project-basic"
7
+ description = "Basic test project for hatch-cpp"
8
+ version = "0.1.0"
9
+ requires-python = ">=3.9"
10
+ dependencies = [
11
+ "hatchling>=1.20",
12
+ "hatch-cpp",
13
+ ]
14
+
15
+ [tool.hatch.build]
16
+ artifacts = [
17
+ "project/*.dll",
18
+ "project/*.dylib",
19
+ "project/*.so",
20
+ ]
21
+
22
+ [tool.hatch.build.sources]
23
+ src = "/"
24
+
25
+ [tool.hatch.build.targets.sdist]
26
+ packages = ["project"]
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["project"]
30
+
31
+ [tool.hatch.build.hooks.hatch-cpp]
32
+ verbose = true
33
+
34
+ [tool.hatch.build.hooks.hatch-cpp.cmake]
35
+ root = "CMakeLists.txt"
36
+ cmake_args = {"BUILD_TESTS" = "OFF"}
37
+ include_flags = {"python_version" = true}
38
+ [tool.hatch.build.hooks.hatch-cpp.cmake.cmake_env_args]
39
+ linux = {"MANYLINUX" = "ON"}
@@ -0,0 +1,5 @@
1
+ #include "project/basic.hpp"
2
+
3
+ PyObject* hello(PyObject*, PyObject*) {
4
+ return PyUnicode_FromString("A string");
5
+ }
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+ #include "Python.h"
3
+
4
+ PyObject* hello(PyObject*, PyObject*);
5
+
6
+ static PyMethodDef extension_methods[] = {
7
+ {"hello", (PyCFunction)hello, METH_NOARGS},
8
+ {nullptr, nullptr, 0, nullptr}
9
+ };
10
+
11
+ static PyModuleDef extension_module = {
12
+ PyModuleDef_HEAD_INIT, "extension", "extension", -1, extension_methods};
13
+
14
+ PyMODINIT_FUNC PyInit_extension(void) {
15
+ Py_Initialize();
16
+ return PyModule_Create(&extension_module);
17
+ }
@@ -9,7 +9,15 @@ import pytest
9
9
 
10
10
  class TestProject:
11
11
  @pytest.mark.parametrize(
12
- "project", ["test_project_basic", "test_project_override_classes", "test_project_pybind", "test_project_nanobind", "test_project_limited_api"]
12
+ "project",
13
+ [
14
+ "test_project_basic",
15
+ "test_project_override_classes",
16
+ "test_project_pybind",
17
+ "test_project_nanobind",
18
+ "test_project_limited_api",
19
+ "test_project_cmake",
20
+ ],
13
21
  )
14
22
  def test_basic(self, project):
15
23
  # cleanup
@@ -0,0 +1,48 @@
1
+ from pathlib import Path
2
+ from sys import version_info
3
+
4
+ import pytest
5
+ from pydantic import ValidationError
6
+ from toml import loads
7
+
8
+ from hatch_cpp.structs import HatchCppBuildConfig, HatchCppBuildPlan, HatchCppLibrary, HatchCppPlatform
9
+
10
+
11
+ class TestStructs:
12
+ def test_validate_py_limited_api(self):
13
+ with pytest.raises(ValidationError):
14
+ library = HatchCppLibrary(
15
+ name="test",
16
+ sources=["test.cpp"],
17
+ py_limited_api="42",
18
+ )
19
+ library = HatchCppLibrary(
20
+ name="test",
21
+ sources=["test.cpp"],
22
+ py_limited_api="cp39",
23
+ )
24
+ assert library.py_limited_api == "cp39"
25
+ platform = HatchCppPlatform.default()
26
+ flags = platform.get_compile_flags(library)
27
+ assert "-DPy_LIMITED_API=0x030900f0" in flags or "/DPy_LIMITED_API=0x030900f0" in flags
28
+
29
+ with pytest.raises(ValidationError):
30
+ library.binding = "pybind11"
31
+
32
+ def test_cmake_args(self):
33
+ txt = (Path(__file__).parent / "test_project_cmake" / "pyproject.toml").read_text()
34
+ toml = loads(txt)
35
+ hatch_build_config = HatchCppBuildConfig(name=toml["project"]["name"], **toml["tool"]["hatch"]["build"]["hooks"]["hatch-cpp"])
36
+ hatch_build_plan = HatchCppBuildPlan(**hatch_build_config.model_dump())
37
+ hatch_build_plan.generate()
38
+
39
+ assert hatch_build_plan.commands[0].startswith("cmake .")
40
+ assert hatch_build_plan.commands[1].startswith("cmake --build build")
41
+ assert hatch_build_plan.commands[2].startswith("cmake --install build")
42
+
43
+ assert "-DCMAKE_BUILD_TYPE=release" in hatch_build_plan.commands[0]
44
+ assert "-B build" in hatch_build_plan.commands[0]
45
+ assert "-DHATCH_CPP_TEST_PROJECT_BASIC_BUILD_TESTS=OFF" in hatch_build_plan.commands[0]
46
+ assert f"-DHATCH_CPP_TEST_PROJECT_BASIC_PYTHON_VERSION=3.{version_info.minor}" in hatch_build_plan.commands[0]
47
+ if hatch_build_plan.platform.platform == "darwin":
48
+ assert "-DCMAKE_OSX_DEPLOYMENT_TARGET=11" in hatch_build_plan.commands[0]
File without changes
@@ -0,0 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ from functools import lru_cache
4
+
5
+ from pydantic import ImportString, TypeAdapter
6
+
7
+ _import_string_adapter = TypeAdapter(ImportString)
8
+
9
+
10
+ @lru_cache(maxsize=None)
11
+ def import_string(input_string: str):
12
+ return _import_string_adapter.validate_python(input_string)
@@ -8,7 +8,7 @@ authors = [{name = "the hatch-cpp authors", email = "t.paine154@gmail.com"}]
8
8
  description = "Hatch plugin for C++ builds"
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
11
- version = "0.1.6"
11
+ version = "0.1.7"
12
12
  requires-python = ">=3.9"
13
13
  keywords = [
14
14
  "hatch",
@@ -49,6 +49,7 @@ develop = [
49
49
  "pybind11",
50
50
  "pytest",
51
51
  "pytest-cov",
52
+ "toml",
52
53
  ]
53
54
 
54
55
  [project.entry-points.hatch]
@@ -62,7 +63,7 @@ Repository = "https://github.com/python-project-templates/hatch-cpp"
62
63
  Homepage = "https://github.com/python-project-templates/hatch-cpp"
63
64
 
64
65
  [tool.bumpversion]
65
- current_version = "0.1.6"
66
+ current_version = "0.1.7"
66
67
  commit = true
67
68
  tag = false
68
69
 
@@ -1,91 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import logging
4
- import os
5
- import platform as sysplatform
6
- import sys
7
- import typing as t
8
-
9
- from hatchling.builders.hooks.plugin.interface import BuildHookInterface
10
-
11
- from .structs import HatchCppBuildConfig, HatchCppBuildPlan
12
- from .utils import import_string
13
-
14
- __all__ = ("HatchCppBuildHook",)
15
-
16
-
17
- class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
18
- """The hatch-cpp build hook."""
19
-
20
- PLUGIN_NAME = "hatch-cpp"
21
- _logger = logging.getLogger(__name__)
22
-
23
- def initialize(self, version: str, build_data: dict[str, t.Any]) -> None:
24
- """Initialize the plugin."""
25
- # Log some basic information
26
- self._logger.info("Initializing hatch-cpp plugin version %s", version)
27
- self._logger.info("Running hatch-cpp")
28
-
29
- # Only run if creating wheel
30
- # TODO: Add support for specify sdist-plan
31
- if self.target_name != "wheel":
32
- self._logger.info("ignoring target name %s", self.target_name)
33
- return
34
-
35
- # Skip if SKIP_HATCH_CPP is set
36
- # TODO: Support CLI once https://github.com/pypa/hatch/pull/1743
37
- if os.getenv("SKIP_HATCH_CPP"):
38
- self._logger.info("Skipping the build hook since SKIP_HATCH_CPP was set")
39
- return
40
-
41
- # Get build config class or use default
42
- build_config_class = import_string(self.config["build-config-class"]) if "build-config-class" in self.config else HatchCppBuildConfig
43
-
44
- # Instantiate build config
45
- config = build_config_class(**self.config)
46
-
47
- # Grab libraries and platform
48
- libraries = config.libraries
49
- platform = config.platform
50
-
51
- # Get build plan class or use default
52
- build_plan_class = import_string(self.config["build-plan-class"]) if "build-plan-class" in self.config else HatchCppBuildPlan
53
-
54
- # Instantiate builder
55
- build_plan = build_plan_class(libraries=libraries, platform=platform)
56
-
57
- # Generate commands
58
- build_plan.generate()
59
-
60
- # Log commands if in verbose mode
61
- if config.verbose:
62
- for command in build_plan.commands:
63
- self._logger.warning(command)
64
-
65
- # Execute build plan
66
- build_plan.execute()
67
-
68
- # Perform any cleanup actions
69
- build_plan.cleanup()
70
-
71
- # force include libraries
72
- for library in libraries:
73
- name = library.get_qualified_name(build_plan.platform.platform)
74
- build_data["force_include"][name] = name
75
-
76
- if libraries:
77
- build_data["pure_python"] = False
78
- machine = sysplatform.machine()
79
- version_major = sys.version_info.major
80
- version_minor = sys.version_info.minor
81
- # TODO abi3
82
- if "darwin" in sys.platform:
83
- os_name = "macosx_11_0"
84
- elif "linux" in sys.platform:
85
- os_name = "linux"
86
- else:
87
- os_name = "win"
88
- if all([lib.py_limited_api for lib in libraries]):
89
- build_data["tag"] = f"cp{version_major}{version_minor}-abi3-{os_name}_{machine}"
90
- else:
91
- build_data["tag"] = f"cp{version_major}{version_minor}-cp{version_major}{version_minor}-{os_name}_{machine}"
@@ -1,26 +0,0 @@
1
- import pytest
2
- from pydantic import ValidationError
3
-
4
- from hatch_cpp.structs import HatchCppLibrary, HatchCppPlatform
5
-
6
-
7
- class TestStructs:
8
- def test_validate_py_limited_api(self):
9
- with pytest.raises(ValidationError):
10
- library = HatchCppLibrary(
11
- name="test",
12
- sources=["test.cpp"],
13
- py_limited_api="42",
14
- )
15
- library = HatchCppLibrary(
16
- name="test",
17
- sources=["test.cpp"],
18
- py_limited_api="cp39",
19
- )
20
- assert library.py_limited_api == "cp39"
21
- platform = HatchCppPlatform.default()
22
- flags = platform.get_compile_flags(library)
23
- assert "-DPy_LIMITED_API=0x030900f0" in flags or "/DPy_LIMITED_API=0x030900f0" in flags
24
-
25
- with pytest.raises(ValidationError):
26
- library.binding = "pybind11"
@@ -1,132 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from functools import lru_cache
4
-
5
- from pydantic import ImportString, TypeAdapter
6
-
7
- _import_string_adapter = TypeAdapter(ImportString)
8
-
9
-
10
- @lru_cache(maxsize=None)
11
- def import_string(input_string: str):
12
- return _import_string_adapter.validate_python(input_string)
13
-
14
-
15
- # import multiprocessing
16
- # import os
17
- # import os.path
18
- # import platform
19
- # import subprocess
20
- # import sys
21
- # from shutil import which
22
- # from skbuild import setup
23
-
24
- # CSP_USE_VCPKG = os.environ.get("CSP_USE_VCPKG", "1").lower() in ("1", "on")
25
- # # Allow arg to override default / env
26
- # if "--csp-no-vcpkg" in sys.argv:
27
- # CSP_USE_VCPKG = False
28
- # sys.argv.remove("--csp-no-vcpkg")
29
-
30
- # # CMake Options
31
- # CMAKE_OPTIONS = (
32
- # ("CSP_BUILD_NO_CXX_ABI", "0"),
33
- # ("CSP_BUILD_TESTS", "1"),
34
- # ("CSP_MANYLINUX", "0"),
35
- # ("CSP_BUILD_KAFKA_ADAPTER", "1"),
36
- # ("CSP_BUILD_PARQUET_ADAPTER", "1"),
37
- # ("CSP_BUILD_WS_CLIENT_ADAPTER", "1"),
38
- # # NOTE:
39
- # # - omit vcpkg, need to test for presence
40
- # # - omit ccache, need to test for presence
41
- # # - omit coverage/gprof, not implemented
42
- # )
43
-
44
- # if sys.platform == "linux":
45
- # VCPKG_TRIPLET = "x64-linux"
46
- # elif sys.platform == "win32":
47
- # VCPKG_TRIPLET = "x64-windows-static-md"
48
- # else:
49
- # VCPKG_TRIPLET = None
50
-
51
- # # This will be used for e.g. the sdist
52
- # if CSP_USE_VCPKG:
53
- # if not os.path.exists("vcpkg"):
54
- # subprocess.call(["git", "clone", "https://github.com/Microsoft/vcpkg.git"])
55
- # if not os.path.exists("vcpkg/ports"):
56
- # subprocess.call(["git", "submodule", "update", "--init", "--recursive"])
57
- # if not os.path.exists("vcpkg/buildtrees"):
58
- # subprocess.call(["git", "pull"], cwd="vcpkg")
59
- # args = ["install"]
60
- # if VCPKG_TRIPLET is not None:
61
- # args.append(f"--triplet={VCPKG_TRIPLET}")
62
-
63
- # if os.name == "nt":
64
- # subprocess.call(["bootstrap-vcpkg.bat"], cwd="vcpkg", shell=True)
65
- # subprocess.call(["vcpkg.bat"] + args, cwd="vcpkg", shell=True)
66
- # else:
67
- # subprocess.call(["./bootstrap-vcpkg.sh"], cwd="vcpkg")
68
- # subprocess.call(["./vcpkg"] + args, cwd="vcpkg")
69
-
70
-
71
- # python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
72
- # cmake_args = [f"-DCSP_PYTHON_VERSION={python_version}"]
73
- # vcpkg_toolchain_file = os.path.abspath(
74
- # os.environ.get(
75
- # "CSP_VCPKG_PATH",
76
- # os.path.join("vcpkg/scripts/buildsystems/vcpkg.cmake"),
77
- # )
78
- # )
79
-
80
- # if CSP_USE_VCPKG and os.path.exists(vcpkg_toolchain_file):
81
- # cmake_args.extend(
82
- # [
83
- # "-DCMAKE_TOOLCHAIN_FILE={}".format(vcpkg_toolchain_file),
84
- # "-DCSP_USE_VCPKG=ON",
85
- # ]
86
- # )
87
-
88
- # if VCPKG_TRIPLET is not None:
89
- # cmake_args.append(f"-DVCPKG_TARGET_TRIPLET={VCPKG_TRIPLET}")
90
- # else:
91
- # cmake_args.append("-DCSP_USE_VCPKG=OFF")
92
-
93
- # if "CXX" in os.environ:
94
- # cmake_args.append(f"-DCMAKE_CXX_COMPILER={os.environ['CXX']}")
95
-
96
- # if "DEBUG" in os.environ:
97
- # cmake_args.append("-DCMAKE_BUILD_TYPE=Debug")
98
-
99
- # if platform.system() == "Windows":
100
- # import distutils.msvccompiler as dm
101
-
102
- # # https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_with_Visual_Studio_2015_.28x86.2C_x64.2C_ARM.29
103
- # msvc = {
104
- # "12": "Visual Studio 12 2013",
105
- # "14": "Visual Studio 14 2015",
106
- # "14.0": "Visual Studio 14 2015",
107
- # "14.1": "Visual Studio 15 2017",
108
- # "14.2": "Visual Studio 16 2019",
109
- # "14.3": "Visual Studio 17 2022",
110
- # }.get(str(dm.get_build_version()), "Visual Studio 15 2017")
111
- # cmake_args.extend(
112
- # [
113
- # "-G",
114
- # os.environ.get("CSP_GENERATOR", msvc),
115
- # ]
116
- # )
117
-
118
- # for cmake_option, default in CMAKE_OPTIONS:
119
- # if os.environ.get(cmake_option, default).lower() in ("1", "on"):
120
- # cmake_args.append(f"-D{cmake_option}=ON")
121
- # else:
122
- # cmake_args.append(f"-D{cmake_option}=OFF")
123
-
124
- # if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
125
- # os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = str(multiprocessing.cpu_count())
126
-
127
- # if platform.system() == "Darwin":
128
- # os.environ["MACOSX_DEPLOYMENT_TARGET"] = os.environ.get("OSX_DEPLOYMENT_TARGET", "10.15")
129
- # cmake_args.append(f'-DCMAKE_OSX_DEPLOYMENT_TARGET={os.environ.get("OSX_DEPLOYMENT_TARGET", "10.15")}')
130
-
131
- # if which("ccache") and os.environ.get("CSP_USE_CCACHE", "") != "0":
132
- # cmake_args.append("-DCSP_USE_CCACHE=On")
File without changes
File without changes
File without changes