Skip to content

PEP 739 / build-details.json: c_api.headers does not include the pythonX.Y directory #134632

Closed

Description

@mgorny

Bug report

Bug description:

Sorry I didn't notice this while fixing #134455 but c_api.headers key contains the path to top-level system include directory, i.e.:

{
  "c_api": {
    "headers": "/usr/local/include",
    "pkgconfig_path": "/usr/local/lib/pkgconfig"
  }
}

while according to the examples in PEP 739, it should contain the path to the pythonX.Y directory:

Examples

/usr/include/python3.14
include/python3.14
etc.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on May 24, 2025
  2. added a commit that references this issue on May 24, 2025
  3. added
    buildThe build process and cross-build
    on May 24, 2025
  4. added a commit that references this issue on Jun 17, 2025
  5. added 2 commits that reference this issue on Jun 17, 2025
  6. added a commit that references this issue on Jun 17, 2025
  7. encukou commented on Jun 17, 2025

    @encukou
    Member

    This broke Android & iOS, see e.g. here:

    
    ======================================================================
    FAIL: test_c_api (test.test_build_details.CPythonBuildDetailsTests.test_c_api)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/buildbot/Library/Developer/XCTestDevices/0FEBFE27-CF48-433B-AF78-485F97B08C80/data/Containers/Bundle/Application/BC1C3834-4B74-4BFC-8F77-9D59306D4B53/iOSTestbed.app/python/lib/python3.15/test/test_build_details.py", line 129, in test_c_api
        self.assertTrue(os.path.exists(os.path.join(value['headers'], 'Python.h')))
        ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError: False is not true
    
  8. mgorny commented on Jun 17, 2025

    @mgorny
    ContributorAuthor

    FWIU this means that build-details.json was broken on these platforms in the first place. Could you give me more details, i.e. what build-details.json contains, where Python.h is installed, and how to get that path?

  9. encukou commented on Jun 17, 2025

    @encukou
    Member

    @freakboy3742, do you have that info?

  10. encukou commented on Jun 17, 2025

    @encukou
    Member

    I doubt the headers get installed after cross-compilation, but, let's wait for the experts :)

  11. freakboy3742 commented on Jun 17, 2025

    @freakboy3742
    Contributor

    @encukou The headers aren't installed into a running app on iOS or Android, so I think this test may need to be a skip (at least in the short term).

    The headers will exist for a development environment though. However, as I flagged during the recent Core Team summit, the location isn't fixed - it essentially can't be "baked in" at time of compilation, because the install location could be wherever the user has downloaded/installed the distribution.

    So - the short term fix will be a test skip; longer term, we need to determine what build-details.json should contain in a relocatable environment. I guess what we need here is the equivalent of $RPATH handling, but for the location of a relocatable Python install.

  12. itamaro commented on Jun 18, 2025

    @itamaro
    Contributor

    we need to determine what build-details.json should contain in a relocatable environment

    iiuc, PEP-739 already allows relative paths to base_prefix, and base_prefix itself can be relative to the location of the file, so supposedly this should already be relocatable-friendly, no?

  13. freakboy3742 commented on Jun 18, 2025

    @freakboy3742
    Contributor

    If that's the case, then it sounds like an update is required for build-details.json on iOS and Android; but at runtime, the test will always fail, so a skip is called for. Patch incoming shortly.

  14. added a commit that references this issue on Jun 18, 2025
  15. added a commit that references this issue on Jun 18, 2025
  16. added a commit that references this issue on Jun 18, 2025
  17. mhsmith commented on Jun 18, 2025

    @mhsmith
    Member

    Actually the Android testbed does include the header files at runtime, for the benefit of the tests:

    // Include files such as pyconfig.h are used by some of the tests.
    into("include/$pyPlusVer") {
    for (prefix in prefixes) {
    from("$prefix/include/$pyPlusVer")
    }

    But the runtime path will still be different to the build environment, so this will only work if relative paths are used.

  18. added 2 commits that reference this issue on Jun 19, 2025
  19. itamaro commented on Jun 21, 2025

    @itamaro
    Contributor

    Anything left to do here?

  20. added 2 commits that reference this issue on Jul 12, 2025
  21. added 2 commits that reference this issue on Aug 4, 2025
  22. hugovk commented on Aug 8, 2025

    @hugovk
    Member

    Assuming not, thanks all!

  23. added 2 commits that reference this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions