Skip to content

gh-162308: Check modules with target Python in native builds - #162337

Open
Udit-Agarwal20 wants to merge 1 commit into
python:mainfrom
Udit-Agarwal20:fix-162308-native-module-check
Open

Udit-Agarwal20 wants to merge 1 commit into
python:mainfrom
Udit-Agarwal20:fix-162308-native-module-check

Conversation

@Udit-Agarwal20

@Udit-Agarwal20 Udit-Agarwal20 commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #162308.

Native CPython builds configured with --with-build-python currently execute checksharedmods using the external build interpreter (PYTHON_FOR_BUILD) rather than the newly built target interpreter.

When the two interpreters have different built-in extension configurations, this can result in incorrect module validation. In addition, the inherited _PYTHON_HOST_PLATFORM variable can cause native builds to skip import checks by incorrectly selecting cross-compilation mode.

Changes

  • Introduce MODULE_CHECK_COMMAND in configure.ac to select the appropriate interpreter and checking mode.
  • Run native module checks using ./$(BUILDPYTHON) -E with --no-cross-compiling.
  • Retain $(PYTHON_FOR_BUILD) with --cross-compiling for cross builds.
  • Preserve $(RUNSHARED_FOR_BUILD) to avoid injecting target shared-library paths into the build interpreter during cross-compilation.
  • Apply the selected command to both module validation and missing-stdlib information generation.
  • Add Makefile regression tests and extend the Linux build workflow to exercise differing _bisect configurations.

Testing

The following local checks were reported successful:

  • test_tools.test_makefile in a native build.
  • test_sysconfig and test_build_details in a standard native build.
  • Makefile tests using a simulated cross-compilation configuration.
  • Tools/patchcheck/patchcheck.py.
  • git diff --check.
  • Native module validation with a target Python that builds _bisect as a built-in.

Full cross-architecture build execution and official containerized Autoconf regeneration were not completed locally. These require further CI verification.

Related work and attribution

Builds on the approach proposed in #162311 by @superajun-wsj, with additional regression coverage and preservation of RUNSHARED_FOR_BUILD for cross-build safety.

Related: #161530.

The original contributor is credited through the commit's Co-authored-by trailer. Any outstanding CLA requirements will need to be resolved.

AI assistance

This contribution was developed with assistance from Google Antigravity. The changes were reviewed and tested locally, with remaining validation limitations described above.

Run native extension checks with BUILDPYTHON and preserve cross-build behavior using PYTHON_FOR_BUILD and RUNSHARED_FOR_BUILD.

Builds on related prior work in python#162311.

Co-authored-by: superajun-wsj <wangshaojun.jeffery@bytedance.com>
@python-cla-bot

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@itamaro itamaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you sign the CLA please, and re-request review after you do?

@bedevere-app

bedevere-app Bot commented Nov 21, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checksharedmods uses the wrong Python interpreter in native builds with --with-build-python

2 participants