Skip to content

Commit 4e95462

Browse files
authored
fix: editable installs with multiconfig generators (#353)
Fixes #351. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 13009b9 commit 4e95462

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/scikit_build_core/build/wheel.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,22 @@ def _build_wheel_impl(
257257
reload_dir = (
258258
os.fspath(build_dir.resolve()) if settings.build_dir else None
259259
)
260-
editable_txt += f"\n\ninstall({modules!r}, {installed!r}, {reload_dir!r}, {settings.editable.rebuild!r}, {settings.editable.verbose!r})\n"
260+
options = []
261+
if not builder.config.single_config and builder.config.build_type:
262+
options += ["--config", builder.config.build_type]
263+
ext_build_opts = ["-v"] if builder.settings.cmake.verbose else []
264+
265+
arguments = (
266+
modules,
267+
installed,
268+
reload_dir,
269+
settings.editable.rebuild,
270+
settings.editable.verbose,
271+
options + ext_build_opts,
272+
options,
273+
)
274+
arguments_str = ", ".join(repr(x) for x in arguments)
275+
editable_txt += f"\n\ninstall({arguments_str})\n"
261276

262277
wheel.writestr(
263278
f"_{normalized_name}_editable.py",

src/scikit_build_core/resources/_editable_redirect.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ def __init__(
2626
path: str | None,
2727
rebuild: bool,
2828
verbose: bool,
29+
build_options: list[str],
30+
install_options: list[str],
2931
):
3032
self.known_source_files = known_source_files
3133
self.known_wheel_files = known_wheel_files
3234
self.path = path
3335
self.rebuild_flag = rebuild
3436
self.verbose = verbose
37+
self.build_options = build_options
38+
self.install_options = install_options
3539

3640
def find_spec(
3741
self,
@@ -71,7 +75,7 @@ def rebuild(self) -> None:
7175
print(f"Running cmake --build & --install in {self.path}") # noqa: T201
7276

7377
result = subprocess.run(
74-
["cmake", "--build", "."],
78+
["cmake", "--build", ".", *self.build_options],
7579
cwd=self.path,
7680
stdout=sys.stderr if verbose else subprocess.PIPE,
7781
env=env,
@@ -86,7 +90,7 @@ def rebuild(self) -> None:
8690
result.check_returncode()
8791

8892
result = subprocess.run(
89-
["cmake", "--install", ".", "--prefix", DIR],
93+
["cmake", "--install", ".", "--prefix", DIR, *self.install_options],
9094
cwd=self.path,
9195
stdout=sys.stderr if verbose else subprocess.PIPE,
9296
env=env,
@@ -107,6 +111,8 @@ def install(
107111
path: str | None,
108112
rebuild: bool = False,
109113
verbose: bool = False,
114+
build_options: list[str] | None = None,
115+
install_options: list[str] | None = None,
110116
) -> None:
111117
"""
112118
Install a meta path finder that redirects imports to the source files, and
@@ -121,6 +127,12 @@ def install(
121127
sys.meta_path.insert(
122128
0,
123129
ScikitBuildRedirectingFinder(
124-
known_source_files, known_wheel_files, path, rebuild, verbose
130+
known_source_files,
131+
known_wheel_files,
132+
path,
133+
rebuild,
134+
verbose,
135+
build_options or [],
136+
install_options or [],
125137
),
126138
)

0 commit comments

Comments
 (0)