Skip to content

fix(python): respect precompiled flavor when excluding freethreaded builds#8745

Merged
jdx merged 4 commits intojdx:mainfrom
risu729:fix-python-precompiled-flavor
Mar 24, 2026
Merged

fix(python): respect precompiled flavor when excluding freethreaded builds#8745
jdx merged 4 commits intojdx:mainfrom
risu729:fix-python-precompiled-flavor

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented Mar 24, 2026

Previously, if any flavor was specified (e.g., 'install_only_stripped'), the freethreaded exclusion was skipped, causing 'mise lock' to sometimes pick the freethreaded build incorrectly. Now it only allows freethreaded builds if the requested flavor specifically includes 'freethreaded'.

Fixes #8739

This PR was generated by an AI.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where Python's freethreaded builds were sometimes incorrectly selected due to a flaw in the flavor-based exclusion logic. The core change ensures that freethreaded builds are only included when explicitly requested by a flavor. Additionally, it enhances the reliability of internal test command execution by standardizing output capture and cleaning, and streamlines test command definitions across various registry entries.

Highlights

  • Python Freethreaded Build Logic: The logic for excluding freethreaded Python builds has been refined. Previously, specifying any flavor would bypass the freethreaded exclusion, potentially leading to incorrect build selections. Now, freethreaded builds are only considered if the requested flavor explicitly includes 'freethreaded'.
  • Test Command Output Handling: The internal test command execution now redirects standard error to standard output and strips ANSI escape codes from the output before comparison. This improves the robustness of test command validation.
  • Registry Test Command Simplification: Numerous registry files (registry/*.toml) have been updated to remove the 2>&1 redirection from their test.cmd entries, simplifying the command definitions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR fixes a bug in Python precompiled build selection where specifying any precompiled_flavor (e.g., install_only_stripped) would inadvertently allow freethreaded builds to slip through into the candidate set, causing mise lock to sometimes resolve a freethreaded URL when a non-freethreaded flavor was requested.

Changes:

  • Replaces the inline .filter(|v| flavor.is_some() || !v.contains("freethreaded")) predicate — which erroneously treated any non-None flavor as opt-in to freethreaded builds — with a dedicated filter_freethreaded helper that only allows freethreaded entries when the flavor string itself contains "freethreaded".
  • The fix is applied consistently to both call sites: the version-listing path (~line 206) and the URL-resolution path (~line 507).
  • Adds a focused e2e regression test (test_lockfile_python_flavor) that asserts the generated lockfile contains install_only_stripped and does not contain freethreaded when that flavor is configured.

Confidence Score: 5/5

  • Safe to merge — targeted, correct bug fix with a matching regression test and no side-effects on other code paths.
  • The logic change is minimal and provably correct across all four flavor combinations (None, non-freethreaded flavor, "freethreaded", flavor containing "freethreaded"). Both affected call sites are updated identically. The new e2e test directly reproduces the reported issue. No existing behavior is altered for users who don't set precompiled_flavor.
  • No files require special attention.

Important Files Changed

Filename Overview
src/plugins/core/python.rs Extracts freethreaded filtering into a helper function filter_freethreaded that correctly gates freethreaded builds on the flavor explicitly containing "freethreaded", fixing both the version-listing and URL-resolution call sites.
e2e/lockfile/test_lockfile_python_flavor New e2e regression test that verifies a lockfile generated with precompiled_flavor = "install_only_stripped" does not contain freethreaded URLs and does contain the expected flavor string.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Filter Python build candidates] --> B{Does entry contain 'freethreaded'?}
    B -- No --> C[Include entry ✓]
    B -- Yes --> D{Is flavor set?}
    D -- No --> E[Exclude entry ✗]
    D -- Yes --> F{Does flavor contain 'freethreaded'?}
    F -- No --> G[Exclude entry ✗\ne.g. install_only_stripped]
    F -- Yes --> H[Include entry ✓\ne.g. freethreaded flavor]
Loading

Reviews (6): Last reviewed commit: "Merge branch 'main' into fix-python-prec..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refines test command execution and output processing, and improves Python version filtering logic. Specifically, it updates numerous registry/*.toml files by removing 2>&1 from test commands. In src/cli/test_tool.rs, stderr is now redirected to stdout before output capture, and ANSI escape codes are stripped from test output for more robust matching. Additionally, src/plugins/core/python.rs includes a more precise filtering condition for freethreaded Python builds. The review comments suggest reordering conditions in the Python plugin for improved readability.

@risu729 risu729 force-pushed the fix-python-precompiled-flavor branch from 3e3ca72 to b61b4ea Compare March 24, 2026 18:44
…uilds

Previously, if any flavor was specified (e.g., 'install_only_stripped'), the freethreaded exclusion was skipped, causing 'mise lock' to sometimes pick the freethreaded build incorrectly. Now it only allows freethreaded builds if the requested flavor specifically includes 'freethreaded'.

Fixes jdx#8739
@risu729 risu729 force-pushed the fix-python-precompiled-flavor branch from b61b4ea to 5dd3600 Compare March 24, 2026 18:46
@risu729
Copy link
Copy Markdown
Contributor Author

risu729 commented Mar 24, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refines the filtering logic for Python versions, specifically how 'freethreaded' versions are handled based on the flavor parameter, in both fetch_precompiled_remote_versions and fetch_precompiled_for_target functions within src/plugins/core/python.rs. The review feedback highlights that this updated filtering logic is duplicated across these two functions and suggests extracting it into a private helper function to improve maintainability and prevent future inconsistencies.

Address review feedback by pulling the duplicated logic for matching freethreaded python versions against the requested flavor into a reusable helper.
@risu729 risu729 closed this Mar 24, 2026
@risu729 risu729 deleted the fix-python-precompiled-flavor branch March 24, 2026 19:28
@risu729 risu729 restored the fix-python-precompiled-flavor branch March 24, 2026 19:43
@risu729 risu729 reopened this Mar 24, 2026
@jdx jdx merged commit 73eaf2e into jdx:main Mar 24, 2026
33 checks passed
jdx pushed a commit that referenced this pull request Mar 24, 2026
### 🚀 Features

- **(github)** add github_tokens.toml, git credential fill, and `mise
github token` command by @jdx in
[#8742](#8742)
- **(registry)** add tart by @mnm364 in
[#8727](#8727)

### 🐛 Bug Fixes

- **(python)** respect precompiled flavor when excluding freethreaded
builds by @risu729 in [#8745](#8745)
- **(shim)** revert shims directory check that caused hangs on macOS by
@jdx in
[e1b8ca4](e1b8ca4)

### 📚 Documentation

- **(python)** swap docs for python.precompiled_arch and
python.precompiled_os by @risu729 in
[#8744](#8744)

### 🧪 Testing

- **(test_tool)** redirect stderr to stdout and strip ansi codes by
@risu729 in [#8738](#8738)

### New Contributors

- @rtharston made their first contribution in
[#8731](#8731)
@risu729 risu729 deleted the fix-python-precompiled-flavor branch March 25, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants