Skip to content

gh-162308: Check native extension modules with the target interpreter - #162311

Merged
itamaro merged 1 commit into
python:mainfrom
superajun-wsj:fix/gh-162308-native-module-check
Nov 24, 2026
Merged

itamaro merged 1 commit into
python:mainfrom
superajun-wsj:fix/gh-162308-native-module-check

Conversation

@superajun-wsj

@superajun-wsj superajun-wsj commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #162308.

In native builds configured with --with-build-python, extension checks run in the external build Python and can reject modules that are built into the target Python. This change runs both extension checks and missing-stdlib information generation with the newly built target Python. Cross builds continue to use the external build Python without importing target modules or adding the target library path.

Validation: native strict checks and shared AArch64 and glibc-to-musl cross builds passed; both original failure modes were reproduced, and the three related test files passed (68 tests run, 8 skipped).

Prepared with assistance from TRAE CLI.

@python-cla-bot

python-cla-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA 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.

Thank you for the PR!

See a few inline comments before we can merge.

Also, could you shorten the PR description to a few sentences in your own words about what goes wrong, and how this fixes it? Now that #161530 has merged, we can drop the branch history and commit hashes.

Comment thread configure.ac Resolved
Comment thread Makefile.pre.in Resolved
Comment thread Makefile.pre.in Resolved
Comment thread Makefile.pre.in Resolved
Comment thread .github/workflows/build.yml Resolved
@bedevere-app

bedevere-app Bot commented Nov 23, 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.

Select the module checker from configure's cross-compiling state. Native
builds use the target Python with RUNSHARED; cross builds use the external
build Python without adding the target library path. Pass the check mode
explicitly for both extension checks and missing stdlib info generation.

Exercise differing builtin module configurations in the existing Linux
build-Python CI job, using a strict check without _PYTHON_HOST_PLATFORM.
Add a Build NEWS entry and regenerate configure with Autoconf 2.72.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
@superajun-wsj
superajun-wsj force-pushed the fix/gh-162308-native-module-check branch from 66e783a to 2ec415b Compare November 24, 2026 09:38
@superajun-wsj

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

Rebased on main and removed the already-merged prerequisite and old merge commits. Applied the RUNSHARED and CI suggestions, and shortened the PR description. The related tests passed (68 tests run, 8 skipped); shared AArch64 and glibc-to-musl cross builds also passed checks for all enabled modules.

@bedevere-app

bedevere-app Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@itamaro: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from itamaro November 24, 2026 09:40

@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.

thank you for the fix!

@itamaro itamaro added build The build process and cross-build needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 24, 2026
@itamaro
itamaro merged commit cc056ab into python:main Nov 24, 2026
69 of 72 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @superajun-wsj for the PR, and @itamaro for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @superajun-wsj and @itamaro, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker cc056abcd53ff54364aed29fd4c3b44b3f6b53a4 3.14

@bedevere-app

bedevere-app Bot commented Nov 24, 2026

Copy link
Copy Markdown

GH-162560 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 24, 2026
@bedevere-app

bedevere-app Bot commented Nov 24, 2026

Copy link
Copy Markdown

GH-162561 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 24, 2026
itamaro pushed a commit to miss-islington/cpython that referenced this pull request Nov 24, 2026
…preter (pythonGH-162311)

In native builds configured with `--with-build-python`, `checksharedmods`
uses the external build Python and can incorrectly report that a module
built into the target Python failed to import.

Use the newly built Python for extension checks and for generating
missing-stdlib information. Cross builds continue to use the external
build Python without importing target modules or adding the target
library path.
(cherry picked from commit cc056ab)

Co-authored-by: Jeffery <wangshaojun.jeffery@bytedance.com>
itamaro pushed a commit to itamaro/cpython that referenced this pull request Nov 24, 2026
…t interpreter (pythonGH-162311)

In native builds configured with `--with-build-python`, `checksharedmods`
uses the external build Python and can incorrectly report that a module
built into the target Python failed to import.

Use the newly built Python for extension checks. Cross builds continue to
use the external build Python without importing target modules.

(cherry picked from commit cc056ab)

Co-authored-by: Jeffery <wangshaojun.jeffery@bytedance.com>
itamaro pushed a commit that referenced this pull request Nov 24, 2026
…rpreter (GH-162311) (#162560)

In native builds configured with `--with-build-python`, `checksharedmods`
uses the external build Python and can incorrectly report that a module
built into the target Python failed to import.

Use the newly built Python for extension checks and for generating
missing-stdlib information. Cross builds continue to use the external
build Python without importing target modules or adding the target
library path.

(cherry picked from commit cc056ab)

Co-authored-by: Jeffery <wangshaojun.jeffery@bytedance.com>
itamaro added a commit that referenced this pull request Nov 24, 2026
…rpreter (GH-162311) (#162561)

In native builds configured with `--with-build-python`, `checksharedmods`
uses the external build Python and can incorrectly report that a module
built into the target Python failed to import.

Use the newly built Python for extension checks. Cross builds continue to
use the external build Python without importing target modules.

(cherry picked from commit cc056ab)

Co-authored-by: Jeffery <wangshaojun.jeffery@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build The build process and cross-build

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