generate-build-details.py --relative-paths --config-file-path writes wrong paths #160004
Description
Bug report
PEP 739 says a relative base_prefix is relative to the directory that contains build-details.json, and the other paths are relative to base_prefix. With --relative-paths --config-file-path, make_paths_relative() first replaces base_prefix with a path relative to the config file's directory, such as ../... It then computes the other paths relative to that relative base_prefix instead of the absolute one, so they're wrong.
For example, for an install whose prefix is /opt/python, running this from /tmp/build:
./python Tools/build/generate-build-details.py \
/opt/python/lib/python3.16/build-details.json \
--relative-paths \
--config-file-path /opt/python/lib/python3.16/build-details.json
writes "base_prefix": "../..", which is correct, but also "headers": "./opt/python/include/python3.16" instead of ./include/python3.16. base_interpreter and the libpython paths are wrong in the same way. Because the relative base_prefix ends up resolved against the current directory, the wrong values also change with the directory the script runs from: from /Users/me/src/cpython/build, headers becomes ./../../../opt/python/include/python3.16.
see astral-sh/python-build-standalone#885 for example of how PBS deals with this issue.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Activity
gh-160004: Fix build-details.json paths with `--config-file-path` (#1…
[3.15] gh-160004: Fix build-details.json paths with `--config-file-pa…
[3.14] gh-160004: Fix build-details.json paths with `--config-file-pa…