Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/scikit_build_core/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..resources import find_python
from .generator import set_environment_for_gen
from .sysconfig import (
get_numpy_include_dir,
get_platform,
get_python_include_dir,
get_python_library,
Expand Down Expand Up @@ -148,6 +149,7 @@ def configure(
get_python_library(self.config.env, abi3=True) if limited_abi else None
)
python_include_dir = get_python_include_dir()
numpy_include_dir = get_numpy_include_dir()

# Classic Find Python
cache_config["PYTHON_EXECUTABLE"] = sys.executable
Expand All @@ -166,6 +168,8 @@ def configure(
cache_config[f"{prefix}_LIBRARY"] = python_library
if python_sabi_library and sysconfig.get_platform().startswith("win"):
cache_config[f"{prefix}_SABI_LIBRARY"] = python_sabi_library
if numpy_include_dir:
cache_config[f"{prefix}_NumPy_INCLUDE_DIR"] = numpy_include_dir

cache_config["SKBUILD_SOABI"] = get_soabi(self.config.env, abi3=limited_abi)

Expand Down
17 changes: 16 additions & 1 deletion src/scikit_build_core/builder/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
if TYPE_CHECKING:
from collections.abc import Mapping

__all__ = ["get_python_include_dir", "get_python_library", "get_cmake_platform"]
__all__ = [
"get_python_include_dir",
"get_python_library",
"get_cmake_platform",
"get_soabi",
"get_numpy_include_dir",
]


TARGET_TO_PLAT = {
Expand Down Expand Up @@ -154,3 +160,12 @@ def get_soabi(env: Mapping[str, str], *, abi3: bool = False) -> str:

assert isinstance(ext_suffix, str)
return ext_suffix.rsplit(".", 1)[0].lstrip(".")


def get_numpy_include_dir() -> Path | None:
try:
import numpy as np
except ImportError:
return None

return Path(np.get_include())