Skip to content

relocatable.py test: take the C extension's include directories from sysconfig - #42

Merged
itamaro merged 1 commit into
python:mainfrom
itamaro:relocatability-c-extension-includes
Nov 6, 2026
Merged

itamaro merged 1 commit into
python:mainfrom
itamaro:relocatability-c-extension-includes

Conversation

@itamaro

@itamaro itamaro commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

developer.c-extension got its include flags by splitting the output of python-config --includes into arguments. That can't work when the installation path contains spaces, and the moved tree's path deliberately does. python-config prints the right path, but unquoted, and no output format works for every consumer, so this isn't a relocatability bug in CPython. As a result:

  • On Linux, the check failed with Python.h: No such file or directory.
  • On macOS, it failed with developer.python-config's stale-shebang error without compiling anything, so the same problem was counted twice.

This takes the include directories from the moved interpreter's sysconfig.get_paths(), the way build tools do, and passes each one as a single argument. developer.python-config still checks python-config itself. The stale INCLUDEPY and CONFINCLUDEPY config variables are still reported by runtime.paths.

Platform Before After
macOS 14 PASS, 5 FAIL 15 PASS, 4 FAIL
Linux 15 PASS, 4 FAIL 16 PASS, 3 FAIL

developer.c-extension now compiles and imports the extension on both platforms.

Written with assistance from Claude Opus 5.5

@itamaro
itamaro force-pushed the relocatability-c-extension-includes branch from 27e53c1 to d47a25a Compare November 5, 2026 18:06
`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>
@itamaro
itamaro force-pushed the relocatability-c-extension-includes branch from d47a25a to 6fa302b Compare November 6, 2026 02:09
@itamaro
itamaro requested a review from brettcannon November 6, 2026 16:42
@itamaro
itamaro marked this pull request as ready for review November 6, 2026 16:42
@itamaro
itamaro merged commit e91785e into python:main Nov 6, 2026
3 checks passed
@itamaro
itamaro deleted the relocatability-c-extension-includes branch November 6, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant