Skip to content

Commit 80965e5

Browse files
authored
feat(setuptools): error for cmake_install_target (#976)
Close #318 with an error; not enough users of this and it's not the best way to do an install. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 86c859b commit 80965e5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
__all__ = [
2626
"BuildCMake",
2727
"cmake_args",
28+
"cmake_install_target",
2829
"cmake_source_dir",
2930
"finalize_distribution_options",
3031
]
@@ -60,6 +61,7 @@ def get_source_dir_from_pyproject_toml() -> str | None:
6061
class BuildCMake(setuptools.Command):
6162
source_dir: str | None = None
6263
cmake_args: list[str] | str | None = None
64+
cmake_install_target: str | None = None
6365

6466
build_lib: str | None
6567
build_temp: str | None
@@ -74,8 +76,9 @@ class BuildCMake(setuptools.Command):
7476
("plat-name=", "p", "platform name to cross-compile for, if supported "),
7577
("debug", "g", "compile/link with debugging information"),
7678
("parallel=", "j", "number of parallel build jobs"),
77-
("source-dir=", "j", "directory with CMakeLists.txt"),
79+
("source-dir=", "s", "directory with CMakeLists.txt"),
7880
("cmake-args=", "a", "extra arguments for CMake"),
81+
("cmake-install-target=", "", "CMake target to install"),
7982
]
8083

8184
def initialize_options(self) -> None:
@@ -87,6 +90,7 @@ def initialize_options(self) -> None:
8790
self.plat_name = None
8891
self.source_dir = get_source_dir_from_pyproject_toml()
8992
self.cmake_args = None
93+
self.cmake_install_target = None
9094

9195
def finalize_options(self) -> None:
9296
self.set_undefined_options(
@@ -180,7 +184,7 @@ def run(self) -> None:
180184
builder.build(build_args=build_args)
181185
builder.install(install_dir=install_dir)
182186

183-
# def "get_source_file+ys"(self) -> list[str]:
187+
# def "get_source_file"(self) -> list[str]:
184188
# return ["CMakeLists.txt"]
185189

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

0 commit comments

Comments
 (0)