Skip to content

Commit 6fa302b

Browse files
itamaroclaude
andcommitted
Take the C extension's include directories from sysconfig
`developer.c-extension` split `python-config --includes` into arguments, which can't work when the installation path contains spaces, as the relocated tree's does. That made the check fail on Linux, and on macOS it repeated `developer.python-config`'s stale shebang failure without compiling anything. Use the moved interpreter's `sysconfig.get_paths()` instead, as build tools do; `developer.python-config` still checks python-config itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 13c54f4 commit 6fa302b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎relocatability.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,14 @@ def _check_venv(self) -> str:
769769
def _check_c_extension(self) -> str:
770770
if self.snapshot is None:
771771
raise CheckSkipped("the startup probe did not complete")
772-
config = self._python_config()
773-
includes = self._run([config, "--includes"])
774-
self._require_success(includes, "python-config --includes failed")
772+
# Ask sysconfig, as build tools do. python-config's output can't
773+
# be split into arguments when the path contains spaces.
774+
paths = self.snapshot.get("config_paths") or {}
775+
includes = [
776+
f"-I{paths[name]}" for name in ("include", "platinclude") if paths.get(name)
777+
]
778+
if not includes:
779+
raise CheckFailed("sysconfig did not provide the include directories")
775780
ldshared = self.snapshot.get("ldshared")
776781
ext_suffix = self.snapshot.get("ext_suffix")
777782
if not isinstance(ldshared, str) or not ldshared:
@@ -824,7 +829,7 @@ def _check_c_extension(self) -> str:
824829
*shlex.split(ldshared),
825830
# e.g. -fPIC on Linux; LDSHARED doesn't include it.
826831
*shlex.split(self.snapshot.get("ccshared") or ""),
827-
*shlex.split(includes.stdout),
832+
*includes,
828833
os.fspath(source),
829834
"-o",
830835
os.fspath(extension),

0 commit comments

Comments
 (0)