Skip to content

Commit 6b44e12

Browse files
committed
Gate site_packages CMake prefix
Signed-off-by: Cristian Le <[email protected]>
1 parent 1124da7 commit 6b44e12

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ messages.after-failure = ""
307307
# A message to print after a successful build.
308308
messages.after-success = ""
309309

310+
# Add the wheel install path to the CMake prefix paths.
311+
search.use-install-prefix = true
312+
313+
# Add the wheel build path to the CMake prefix paths.
314+
search.use-build-prefix = true
315+
310316
# List dynamic metadata fields and hook locations in this table.
311317
metadata = {}
312318

src/scikit_build_core/builder/builder.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ def configure(
132132

133133
# Add site-packages to the prefix path for CMake
134134
site_packages = Path(sysconfig.get_path("purelib"))
135-
self.config.prefix_dirs.append(site_packages)
135+
if self.settings.search.use_install_prefix:
136+
self.config.prefix_dirs.append(site_packages)
136137
logger.debug("SITE_PACKAGES: {}", site_packages)
137138
if site_packages != DIR.parent.parent:
138-
self.config.prefix_dirs.append(DIR.parent.parent)
139+
if self.settings.search.use_build_prefix:
140+
self.config.prefix_dirs.append(DIR.parent.parent)
139141
logger.debug("Extra SITE_PACKAGES: {}", site_packages)
140142

141143
# Add the FindPython backport if needed

src/scikit_build_core/resources/scikit-build.schema.json

+19
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@
9393
}
9494
}
9595
},
96+
"search": {
97+
"additionalProperties": false,
98+
"properties": {
99+
"use-build-prefix": {
100+
"default": true,
101+
"description": "Add the wheel build path to the CMake prefix paths.",
102+
"type": "boolean"
103+
},
104+
"use-install-prefix": {
105+
"default": true,
106+
"description": "Add the wheel install path to the CMake prefix paths.",
107+
"type": "boolean"
108+
}
109+
},
110+
"type": "object"
111+
},
96112
"ninja": {
97113
"type": "object",
98114
"additionalProperties": false,
@@ -599,6 +615,9 @@
599615
"metadata": {
600616
"$ref": "#/properties/metadata"
601617
},
618+
"search": {
619+
"$ref": "#/properties/search"
620+
},
602621
"strict-config": {
603622
"$ref": "#/properties/strict-config"
604623
},

src/scikit_build_core/settings/skbuild_model.py

+14
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ class CMakeSettings:
8080
"""
8181

8282

83+
@dataclasses.dataclass
84+
class SearchSettings:
85+
use_install_prefix: bool = True
86+
"""
87+
Add the wheel install path to the CMake prefix paths.
88+
"""
89+
90+
use_build_prefix: bool = True
91+
"""
92+
Add the wheel build path to the CMake prefix paths.
93+
"""
94+
95+
8396
@dataclasses.dataclass
8497
class NinjaSettings:
8598
minimum_version: Optional[Version] = None
@@ -325,6 +338,7 @@ class ScikitBuildSettings:
325338
install: InstallSettings = dataclasses.field(default_factory=InstallSettings)
326339
generate: List[GenerateSettings] = dataclasses.field(default_factory=list)
327340
messages: MessagesSettings = dataclasses.field(default_factory=MessagesSettings)
341+
search: SearchSettings = dataclasses.field(default_factory=SearchSettings)
328342

329343
metadata: Dict[str, Dict[str, Any]] = dataclasses.field(default_factory=dict)
330344
"""

0 commit comments

Comments
 (0)