Skip to content

Commit

Permalink
Gate site_packages CMake prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Aug 29, 2024
1 parent 1124da7 commit 8b0f2c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scikit_build_core/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def configure(

# Add site-packages to the prefix path for CMake
site_packages = Path(sysconfig.get_path("purelib"))
self.config.prefix_dirs.append(site_packages)
if self.settings.search.use_install_prefix:
self.config.prefix_dirs.append(site_packages)
logger.debug("SITE_PACKAGES: {}", site_packages)
if site_packages != DIR.parent.parent:
self.config.prefix_dirs.append(DIR.parent.parent)
if self.settings.search.use_build_prefix:
self.config.prefix_dirs.append(DIR.parent.parent)
logger.debug("Extra SITE_PACKAGES: {}", site_packages)

# Add the FindPython backport if needed
Expand Down
14 changes: 14 additions & 0 deletions src/scikit_build_core/settings/skbuild_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ class CMakeSettings:
"""


@dataclasses.dataclass
class SearchSettings:
use_install_prefix: bool = True
"""
Add the wheel install path to the CMake prefix paths.
"""

use_build_prefix: bool = True
"""
Add the wheel build path to the CMake prefix paths.
"""


@dataclasses.dataclass
class NinjaSettings:
minimum_version: Optional[Version] = None
Expand Down Expand Up @@ -325,6 +338,7 @@ class ScikitBuildSettings:
install: InstallSettings = dataclasses.field(default_factory=InstallSettings)
generate: List[GenerateSettings] = dataclasses.field(default_factory=list)
messages: MessagesSettings = dataclasses.field(default_factory=MessagesSettings)
search: SearchSettings = dataclasses.field(default_factory=SearchSettings)

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

0 comments on commit 8b0f2c9

Please sign in to comment.