Skip to content

Commit a09eb91

Browse files
committed
Gate site_packages CMake prefix
Signed-off-by: Cristian Le <[email protected]>
1 parent f0ae319 commit a09eb91

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ messages.after-failure = ""
308308
# A message to print after a successful build.
309309
messages.after-success = ""
310310

311+
# Add the install (or build isolation) site_packages folder to the CMake prefix
312+
# paths.
313+
use-site-packages = true
314+
311315
# List dynamic metadata fields and hook locations in this table.
312316
metadata = {}
313317

src/scikit_build_core/builder/builder.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ def configure(
149149

150150
# Add site-packages to the prefix path for CMake
151151
site_packages = Path(sysconfig.get_path("purelib"))
152-
self.config.prefix_dirs.append(site_packages)
153-
logger.debug("SITE_PACKAGES: {}", site_packages)
154-
if site_packages != DIR.parent.parent:
155-
self.config.prefix_dirs.append(DIR.parent.parent)
156-
logger.debug("Extra SITE_PACKAGES: {}", DIR.parent.parent)
157-
logger.debug("PATH: {}", sys.path)
152+
if self.settings.search.use_site_packages:
153+
self.config.prefix_dirs.append(site_packages)
154+
logger.debug("SITE_PACKAGES: {}", site_packages)
155+
if site_packages != DIR.parent.parent:
156+
self.config.prefix_dirs.append(DIR.parent.parent)
157+
logger.debug("Extra SITE_PACKAGES: {}", DIR.parent.parent)
158+
logger.debug("PATH: {}", sys.path)
158159

159160
# Add the FindPython backport if needed
160161
if self.config.cmake.version < self.settings.backport.find_python:

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@
9393
}
9494
}
9595
},
96+
"search": {
97+
"additionalProperties": false,
98+
"properties": {
99+
"use-site-packages": {
100+
"default": true,
101+
"description": "Add the install (or build isolation) site_packages folder to the CMake prefix paths.",
102+
"type": "boolean"
103+
}
104+
},
105+
"type": "object"
106+
},
96107
"ninja": {
97108
"type": "object",
98109
"additionalProperties": false,
@@ -599,6 +610,9 @@
599610
"metadata": {
600611
"$ref": "#/properties/metadata"
601612
},
613+
"search": {
614+
"$ref": "#/properties/search"
615+
},
602616
"strict-config": {
603617
"$ref": "#/properties/strict-config"
604618
},

src/scikit_build_core/settings/skbuild_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"MessagesSettings",
1919
"NinjaSettings",
2020
"SDistSettings",
21+
"SearchSettings",
2122
"ScikitBuildSettings",
2223
"WheelSettings",
2324
]
@@ -80,6 +81,15 @@ class CMakeSettings:
8081
"""
8182

8283

84+
@dataclasses.dataclass
85+
class SearchSettings:
86+
use_site_packages: bool = True
87+
"""
88+
Add the install (or build isolation) site_packages folder to the CMake prefix
89+
paths.
90+
"""
91+
92+
8393
@dataclasses.dataclass
8494
class NinjaSettings:
8595
minimum_version: Optional[Version] = None
@@ -326,6 +336,7 @@ class ScikitBuildSettings:
326336
install: InstallSettings = dataclasses.field(default_factory=InstallSettings)
327337
generate: List[GenerateSettings] = dataclasses.field(default_factory=list)
328338
messages: MessagesSettings = dataclasses.field(default_factory=MessagesSettings)
339+
search: SearchSettings = dataclasses.field(default_factory=SearchSettings)
329340

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

tests/test_skbuild_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def test_skbuild_settings_pyproject_toml_broken(
400400
== """\
401401
ERROR: Unrecognized options in pyproject.toml:
402402
tool.scikit-build.cmake.verison -> Did you mean: tool.scikit-build.cmake.version, tool.scikit-build.cmake.verbose, tool.scikit-build.cmake.define?
403-
tool.scikit-build.logger -> Did you mean: tool.scikit-build.logging, tool.scikit-build.generate, tool.scikit-build.fail?
403+
tool.scikit-build.logger -> Did you mean: tool.scikit-build.logging, tool.scikit-build.generate, tool.scikit-build.search?
404404
""".split()
405405
)
406406

0 commit comments

Comments
 (0)