Skip to content

Strip toolchain bin paths from sysconfig AR variable#1127

Open
kimjune01 wants to merge 2 commits into
astral-sh:mainfrom
kimjune01:fix-ar-sysconfig-path
Open

Strip toolchain bin paths from sysconfig AR variable#1127
kimjune01 wants to merge 2 commits into
astral-sh:mainfrom
kimjune01:fix-ar-sysconfig-path

Conversation

@kimjune01
Copy link
Copy Markdown

Summary

  • Strip the toolchain bin directory prefix from sysconfig values so AR (and similar tools like RANLIB) contain just the binary name instead of build-time absolute paths
  • Handles resolved symlinks (e.g. macOS /var vs /private/var) as a second pass
  • Adds test covering 8 edge cases including trailing slashes and double-slash paths

Test plan

  • python3 test_ar_normalization.py: all 8 test cases passed

kimjune01 added 2 commits May 10, 2026 08:42
Fixes astral-sh#1073

The AR sysconfig variable contains an absolute build-time path
(e.g., /tools/llvm/bin/llvm-ar) instead of just the tool name
(llvm-ar). CC and CXX are already normalized by CPython, but
AR and RANLIB are not.

This change adds path normalization in hack_sysconfig.py to strip
the toolchain bin directory prefix from all occurrences in
sysconfig artifacts (PYTHON_CONFIG, Makefile, SYSCONFIGDATA).

The fix:
- Uses os.path.normpath to handle edge cases like trailing slashes
- Also catches resolved symlinks (e.g., macOS /var vs /private/var)
- Preserves LLVM tool names (llvm-ar, not ar) for consistency with
  CC=clang and CXX=clang++

Reviewed by: codex (GPT-5.5), gemini-3.1-pro-preview
- Added test case: 'AR = /tools/llvm/bin/' -> 'AR = '
- Documents expected behavior when path ends with trailing slash
- Validates replacement doesn't crash on degenerate inputs
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