Skip to content

GH-107956: add sysconfig._build_details - #162124

Open
FFY00 wants to merge 36 commits into
python:mainfrom
FFY00:move-build-details-generation-to-sysconfig-updated
Open

FFY00 wants to merge 36 commits into
python:mainfrom
FFY00:move-build-details-generation-to-sysconfig-updated

Conversation

@FFY00

@FFY00 FFY00 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

This introduces a new sysconfig._build_details module to generate and
manipulate build-details.json data.

It contains abstractions to work with build-details.json data.
We hope that these APIs will evolve and reach the point it would make
sense to make them public.

In the future, we'd also like to abstract the data sources, so that the
code would be able to generate build-details.json for external
interpreters.

Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
This better mirrors the bahevior of os.path.relpath.

Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
…ve path"

This reverts commit 95fc7f5.

Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00
FFY00 force-pushed the move-build-details-generation-to-sysconfig-updated branch from e73eaf4 to 3a730ab Compare November 16, 2026 18:11
FFY00 added 17 commits November 30, 2026 17:57
…neration-to-sysconfig-updated

Signed-off-by: Filipe Laíns <lains@riseup.net>
…ails-generation-to-sysconfig-updated

Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added 4 commits December 2, 2026 19:34
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
…ported

Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00

FFY00 commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

I believe I finally managed to catch up with all of the new changes that got into generate-build-details.py after I started working on this.

@itamaro, could you have a look?

FFY00 added 6 commits December 2, 2026 20:02
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00

FFY00 commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Okay, the iOS CI is failing because it finds a relative path in libpython.dynamic without the --relative-paths option.

  ======================================================================
  FAIL: test_round_trip (test.test_build_details.BuildDetailsRelativePathsTests.test_round_trip)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/runner/Library/Developer/CoreSimulator/Devices/53822F8D-E57D-4DE3-9681-FB3FD93CAC6A/data/Containers/Bundle/Application/F271F41C-9446-4A2E-9BE4-32B96A4E58D1/iOSTestbed.app/python/lib/python3.16/test/test_build_details.py", line 239, in test_round_trip
      self.check_relative_paths(data_abs_path, data_rel_path)
      ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/runner/Library/Developer/CoreSimulator/Devices/53822F8D-E57D-4DE3-9681-FB3FD93CAC6A/data/Containers/Bundle/Application/F271F41C-9446-4A2E-9BE4-32B96A4E58D1/iOSTestbed.app/python/lib/python3.16/test/test_build_details.py", line 294, in check_relative_paths
      self.assertEqual(data_abs_path[part][key], abs_rel_path)
      ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AssertionError: './Platforms/Apple/iOS/Frameworks/arm64-ip[33 chars]thon' != '/Users/runner/Library/Developer/CoreSimul[222 chars]thon'
  - ./Platforms/Apple/iOS/Frameworks/arm64-iphonesimulator/Python.framework/Python
  + /Users/runner/Library/Developer/CoreSimulator/Devices/53822F8D-E57D-4DE3-9681-FB3FD93CAC6A/data/Containers/Data/Application/5657A39D-9639-445F-932A-9CDB6168F92C/tmp/test_python_worker_36437æ/Platforms/Apple/iOS/Frameworks/arm64-iphonesimulator/Python.framework/Python

This happens because the installation directories (eg. LIBDIR, etc.) are relative in iOS builds.

I don't understand why we are not seeing this failure in main, because the current code doesn't do anything to deal with this.

Signed-off-by: Filipe Laíns <lains@riseup.net>
@itamaro

itamaro commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

hey @FFY00 , thanks for carrying the recent cross-build fixes over in this PR!

before jumping into detailed review, I feel that I'm missing higher level context and motivation.
what is the concrete use for this, and who is it for?
I'm asking because I can't immediately see what we gain today, but I can see some costs.

  • the only caller is the Makefile, and it has to describe the target of the build, not the interpreter running it. from_interpreter() now does both jobs, which feels more awkward than a standalone build script under Tools/. specifically, to do this correctly, from_interpreter() requires a bunch of "workarounds for cross compilation" - I'd rather we treat cross builds (as well as use of --with-build-python) as first-class citizens, and bake this into the API design from the get go.
  • moving the build script from Tools/ is going to churn downstream redistributors that call the script in their build (e.g. conda-forge calls the script, MSYS2 and emscripten-forge patch it). not a blocker since build tools are not something we provide guarantees for, but we should be clear on why we're doing it if it's going to churn users.
  • for some reason (maybe it's just me?), it feels more natural to me that a standalone script can be used to generate build-details for a target interpreter that's different from the one running it, vs a private stdlib module that runs inside the build interpreter and has a method called from_interpreter().

I don't understand why we are not seeing this failure in main, because the current code doesn't do anything to deal with this.

this is because these tests don't run on iOS on main - iOS tests run under installed python, where the script isn't importable (no Tools/ in installed python). with this PR, the module becomes importable, so the iOS tests start running. I think this is a good example of how making it part of the stdlib gets confusing once it also runs on the installed interpreter.
note that using Path.resolve() to fix it introduces a new issue when it follows symlinks on the build machine (for example, building with a prefix under /tmp on macOS produces paths like "./../../…/private/tmp/…/include/python3.16", which breaks once the installed tree is moved).

if the goal is a public API for reading and writing build-details.json, I think we need a more deliberate and intentional design (and discussion), where cross-build and --with-build-python use-cases are considered and addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants