Skip to content

Commit 2a7bf07

Browse files
committed
feat(setuptools): error for cmake_install_target
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 86c859b commit 2a7bf07

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Issues = "https://github.com/scikit-build/scikit-build-core/issues"
116116
"distutils.commands".build_cmake = "scikit_build_core.setuptools.build_cmake:BuildCMake"
117117
"distutils.setup_keywords".cmake_source_dir = "scikit_build_core.setuptools.build_cmake:cmake_source_dir"
118118
"distutils.setup_keywords".cmake_args = "scikit_build_core.setuptools.build_cmake:cmake_args"
119+
"distutils.setup_keywords".cmake_install_target = "scikit_build_core.setuptools.build_cmake:cmake_install_target"
119120
"setuptools.finalize_distribution_options".scikit_build_entry = "scikit_build_core.setuptools.build_cmake:finalize_distribution_options"
120121
"validate_pyproject.tool_schema".scikit-build = "scikit_build_core.settings.skbuild_schema:get_skbuild_schema"
121122
hatch.scikit-build = "scikit_build_core.hatch.hooks"

src/scikit_build_core/setuptools/build_cmake.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ def get_source_dir_from_pyproject_toml() -> str | None:
5858

5959

6060
class BuildCMake(setuptools.Command):
61-
source_dir: str | None = None
61+
cmake_source_dir: str | None = None
6262
cmake_args: list[str] | str | None = None
63+
cmake_install_target: str | None = None
6364

6465
build_lib: str | None
6566
build_temp: str | None
@@ -74,8 +75,9 @@ class BuildCMake(setuptools.Command):
7475
("plat-name=", "p", "platform name to cross-compile for, if supported "),
7576
("debug", "g", "compile/link with debugging information"),
7677
("parallel=", "j", "number of parallel build jobs"),
77-
("source-dir=", "j", "directory with CMakeLists.txt"),
78+
("cmake-source-dir=", "", "directory with CMakeLists.txt"),
7879
("cmake-args=", "a", "extra arguments for CMake"),
80+
("cmake-install-target=", "", "CMake target to install"),
7981
]
8082

8183
def initialize_options(self) -> None:
@@ -85,8 +87,9 @@ def initialize_options(self) -> None:
8587
self.editable_mode = False
8688
self.parallel = None
8789
self.plat_name = None
88-
self.source_dir = get_source_dir_from_pyproject_toml()
90+
self.cmake_source_dir = get_source_dir_from_pyproject_toml()
8991
self.cmake_args = None
92+
self.cmake_install_target = None
9093

9194
def finalize_options(self) -> None:
9295
self.set_undefined_options(
@@ -116,7 +119,9 @@ def run(self) -> None:
116119

117120
dist = self.distribution
118121
dist_source_dir = getattr(self.distribution, "cmake_source_dir", None)
119-
source_dir = self.source_dir if dist_source_dir is None else dist_source_dir
122+
source_dir = (
123+
self.cmake_source_dir if dist_source_dir is None else dist_source_dir
124+
)
120125
assert source_dir is not None, "This should not be reachable"
121126

122127
configure_args = self.cmake_args or []
@@ -180,7 +185,7 @@ def run(self) -> None:
180185
builder.build(build_args=build_args)
181186
builder.install(install_dir=install_dir)
182187

183-
# def "get_source_file+ys"(self) -> list[str]:
188+
# def "get_source_file"(self) -> list[str]:
184189
# return ["CMakeLists.txt"]
185190

186191
# def get_outputs(self) -> list[str]:
@@ -194,7 +199,7 @@ def _has_cmake(dist: Distribution) -> bool:
194199
build_cmake = dist.get_command_obj("build_cmake")
195200
assert isinstance(build_cmake, BuildCMake)
196201
return (
197-
build_cmake.source_dir is not None
202+
build_cmake.cmake_source_dir is not None
198203
or getattr(dist, "cmake_source_dir", None) is not None
199204
)
200205

@@ -260,3 +265,13 @@ def cmake_source_dir(
260265
if not Path(value).is_dir():
261266
msg = "cmake_source_dir must be an existing directory"
262267
raise setuptools.errors.SetupError(msg)
268+
269+
270+
def cmake_install_target(
271+
dist: Distribution, attr: Literal["cmake_install_target"], value: str
272+
) -> None:
273+
assert attr == "cmake_install_target"
274+
assert value is not None
275+
_cmake_extension(dist)
276+
msg = "cmake_install_target is not supported - please use components and build targets instead"
277+
raise setuptools.errors.SetupError(msg)

0 commit comments

Comments
 (0)