Skip to content

gh-119696: Install build-details.json with relative paths - #161907

Open
itamaro wants to merge 3 commits into
python:mainfrom
itamaro:build-details-relative-paths
Open

itamaro wants to merge 3 commits into
python:mainfrom
itamaro:build-details-relative-paths

Conversation

@itamaro

@itamaro itamaro commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

make install writes build-details.json (PEP 739) with absolute paths, so the file is wrong once the installation is moved. Fixing that is one of the steps towards relocatable CPython installations.

PEP 739 allows the paths to be relative to base_prefix, and base_prefix to be relative to the file's directory; generate-build-details.py already implements that behind --relative-paths --config-file-path. The Makefile now passes --relative-paths with a new --installed-location flag, which takes the file's installed path from sysconfig instead of from $(LIBDEST), so that make install prefix=... (which the Android build uses) doesn't change the result.

The installed-file tests now resolve the paths like a consumer would, instead of skipping on a relocated installation.

`make install` writes `build-details.json` (PEP 739) with absolute
paths, so the file is wrong once the installation is moved. Fixing
that is one of the steps towards relocatable CPython installations.

PEP 739 allows the paths to be relative to `base_prefix`, and
`base_prefix` to be relative to the file's directory;
`generate-build-details.py` already implements that behind
`--relative-paths --config-file-path`. Pass those flags from the
Makefile.

The installed-file tests now resolve the paths like a consumer would,
instead of skipping on a relocated installation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@itamaro
itamaro force-pushed the build-details-relative-paths branch from ff84334 to 22c061e Compare November 16, 2026 01:32
@read-the-docs-community

read-the-docs-community Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #36047793 | 📁 Comparing 20de602 against main (2e14c83)

  🔍 Preview build  

16 files changed · + 1 added · ± 15 modified

+ Added

± Modified

@itamaro
itamaro marked this pull request as ready for review November 16, 2026 01:57
`make install prefix=...` (which the Android build uses) changes
`$(LIBDEST)` but not the prefix that `sysconfig` reports, so
`base_prefix` was computed between two unrelated paths. Add an
`--installed-location` flag that uses `sysconfig.get_path('stdlib')`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@brettcannon brettcannon reopened this Nov 18, 2026

@FFY00 FFY00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me 👍

Though, I think it would be best if we kept the default behavior, and instead add a configure flag for relocatable install. What do you think?

@itamaro

itamaro commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

thanks for the review @FFY00 !

I think it would be best if we kept the default behavior, and instead add a configure flag for relocatable install. What do you think?

We can do that (assuming I merge gh-162185 first, so we have the flag), but my preference would be to make the default behavior relocatable-friendly whenever we can.

This PR is actually a good example of why that's beneficial - by making the change in the default build, I could get good CI signal (without adding a new CI dimension), which flagged a gap in my initial approach (i.e., this Android failure). If the change was behind a flag, I wouldn't have known about that case, and wouldn't adjust the approach with the second commit in this PR.

Having said that, if making build-details paths relative in the default build would cause issues for users in practice, that would be a good reason to keep the default behavior and use the flag. Can you think of any?

Conflict in Lib/test/test_build_details.py: both sides added tests after
test_location; keep both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants