Skip to content

sysconfig.get_platform should match the build platform #162323

Description

@FFY00

Bug report

In GH-161870, we noticed that sysconfig.get_platform may not match the build platform when running on a compatible architecture — eg. 32 bit build running on a 64 bit machine.

From its documentation:

This is used mainly to distinguish platform-specific build directories and platform-specific built distributions.

To be able to use the function for this purpose, it must return the build platform. Otherwise, we may end up trying to use a 64 bit wheel on a 32 bit build.

Typically includes the OS name and version and the architecture (as supplied by os.uname()), although the exact information included depends on the OS; e.g., on Linux, the kernel version isn’t particularly important.

It does mention os.uname specifically as the source, though I think it's written some wiggle room.

IMO, the main issue with changing the behavior is existing code maybe relying on this edge case. If we decide to not change it, then we should provide another way to get the proper build platform.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    type-bug
    on Nov 20, 2026
  2. added
    stdlib
    on Nov 20, 2026
  3. rgommers commented on Nov 25, 2026

    @rgommers
    Contributor

    IMO, the main issue with changing the behavior is existing code maybe relying on this edge case. If we decide to not change it, then we should provide another way to get the proper build platform.

    Changing the semantics of sysconfig.get_platform from returning information about the runtime platform/OS/architecture to returning all the values observed at build time (the way it's done in gh-162336 at least) is like to cause regressions for multiple cases and tools - that seems unhealthy. Currently the behavior is already mixed, with some parts of the returned platform string containing build time and others runtime information.

    It may be an option to specifically fix the interpreter value returned by get_platform while leaving the OS and CPU architecture unchanged. That seems like a reasonable bug fix.

    A separate sysconfig.get_build_platform() or similar may be better if that limited bug fix isn't enough and there's really a need to know all the original build platform parameters - but it's unclear to me if there is a use case for that.

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

    stdlibtopic-sysconfigtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions