Skip to content

Commit f4be9d4

Browse files
authored
fix: expand some variables when constructing paths (#844)
Trying a potential fix for #843. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 793b486 commit f4be9d4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/scikit_build_core/program_search.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import contextlib
44
import json
5+
import os.path
56
import shutil
67
import subprocess
78
from pathlib import Path
@@ -52,7 +53,7 @@ def _get_cmake_path(*, module: bool = True) -> Generator[Path, None, None]:
5253
for candidate in candidates:
5354
cmake_path = shutil.which(candidate)
5455
if cmake_path is not None:
55-
yield Path(cmake_path)
56+
yield Path(os.path.expandvars(cmake_path))
5657

5758

5859
def _get_ninja_path(*, module: bool = True) -> Generator[Path, None, None]:
@@ -71,7 +72,7 @@ def _get_ninja_path(*, module: bool = True) -> Generator[Path, None, None]:
7172
for candidate in candidates:
7273
ninja_path = shutil.which(candidate)
7374
if ninja_path is not None:
74-
yield Path(ninja_path)
75+
yield Path(os.path.expandvars(ninja_path))
7576

7677

7778
def get_cmake_program(cmake_path: Path) -> Program:
@@ -156,7 +157,7 @@ def get_make_programs() -> Generator[Path, None, None]:
156157
for candidate in candidates:
157158
make_path = shutil.which(candidate)
158159
if make_path is not None:
159-
yield Path(make_path)
160+
yield Path(os.path.expandvars(make_path))
160161

161162

162163
def best_program(

tests/test_cmake_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import os
4+
import os.path
45
import shutil
56
from pathlib import Path
67
from typing import TYPE_CHECKING
@@ -15,7 +16,7 @@
1516
if TYPE_CHECKING:
1617
from collections.abc import Generator
1718

18-
DIR = Path(__file__).parent.resolve()
19+
DIR = Path(os.path.expandvars(__file__)).parent.resolve()
1920

2021

2122
def configure_args(config: CMaker, *, init: bool = False) -> Generator[str, None, None]:

0 commit comments

Comments
 (0)