From 6fa302bcca57f912c0773ca7bef2e1e188987692 Mon Sep 17 00:00:00 2001 From: Itamar Oren Date: Wed, 4 Nov 2026 20:58:52 -0800 Subject: [PATCH] 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 --- relocatability.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/relocatability.py b/relocatability.py index 8405c30..19020c3 100644 --- a/relocatability.py +++ b/relocatability.py @@ -769,9 +769,14 @@ def _check_venv(self) -> str: def _check_c_extension(self) -> str: if self.snapshot is None: raise CheckSkipped("the startup probe did not complete") - config = self._python_config() - includes = self._run([config, "--includes"]) - self._require_success(includes, "python-config --includes failed") + # Ask sysconfig, as build tools do. python-config's output can't + # be split into arguments when the path contains spaces. + paths = self.snapshot.get("config_paths") or {} + includes = [ + f"-I{paths[name]}" for name in ("include", "platinclude") if paths.get(name) + ] + if not includes: + raise CheckFailed("sysconfig did not provide the include directories") ldshared = self.snapshot.get("ldshared") ext_suffix = self.snapshot.get("ext_suffix") if not isinstance(ldshared, str) or not ldshared: @@ -824,7 +829,7 @@ def _check_c_extension(self) -> str: *shlex.split(ldshared), # e.g. -fPIC on Linux; LDSHARED doesn't include it. *shlex.split(self.snapshot.get("ccshared") or ""), - *shlex.split(includes.stdout), + *includes, os.fspath(source), "-o", os.fspath(extension),