Skip to content

Python sanity check improvements#424

Open
alirana01 wants to merge 7 commits intomasterfrom
python_sanity_check_improvements
Open

Python sanity check improvements#424
alirana01 wants to merge 7 commits intomasterfrom
python_sanity_check_improvements

Conversation

@alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Feb 11, 2026

⚠️ IMPORTANT: Intentional test failure added

The file try_https.py contains an exit(1) line that causes the SSL/HTTPS check to intentionally fail for testing purposes. This MUST be reverted before merging to master.


Description

This PR overhauls the Python sanity check system to provide better user feedback with structured results, translated display names, and OS-aware resolution hints.

Key Changes

Backend (Rust Library)

  • Introduced SanityCheck enum to identify each check type (PythonVersion, Pip, Venv, StdLib, Ctypes, Ssl)
  • Created a generic GenericCheckResult<T> struct for structured check results with check, passed, and message fields
  • Refactored python_sanity_check() to return Vec<GenericCheckResult<SanityCheck>> instead of Vec<Result<String, String>>
  • Library remains i18n-free — translation responsibility moved to consumers (CLI/GUI)

CLI Improvements

  • Added check_display_name() and check_hint() helper functions for translated output
  • Now displays [PASS] / [FAIL] status for each individual check
  • Shows OS-specific resolution hints when a check fails

GUI Improvements

  • New reusable CheckResultsList.vue component for displaying structured check results
  • Updated python_sanity_check Tauri command to return Vec<CheckResultItem> with display_name, passed, and hint fields
  • Integrated the new component into SimpleSetup.vue and PythonSanitycheck.vue
  • Failed checks now show actionable hints instead of raw error output

Localization

  • Added locale keys for all check display names (python.sanitycheck.check.*)
  • Added OS-aware hint keys for each check type (python.sanitycheck.hint.*)
  • Platform-specific hints for Linux, macOS, and Windows where applicable

Checks Performed

Check Description
Python Version Validates version is within supported range (3.10-3.13 on Windows, 3.10-3.14 elsewhere)
pip Ensures pip module is available
venv Ensures venv module is available
Standard Library Verifies core modules (json, os, platform)
ctypes Verifies ctypes module availability
SSL/HTTPS Verifies SSL support for secure connections

Related


Testing

  • Verify CLI output shows [PASS] / [FAIL] for each check
  • Verify GUI displays structured results in CheckResultsList component
  • Test on Windows: check Windows-specific hints appear correctly
  • Test on macOS: check macOS-specific hints appear correctly
  • Test on Linux: check Linux-specific hints appear correctly
  • Verify Chinese translations display correctly
  • Remove exit(1) from try_https.py before final merge

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@alirana01 alirana01 self-assigned this Feb 11, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @alirana01, 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 refines the Python sanity check process to offer a more informative and user-friendly experience. By restructuring the backend logic to provide detailed, per-check results and integrating these into both the CLI and GUI with localized messages and actionable hints, users can more easily diagnose and resolve Python environment issues. This enhancement aims to reduce friction during setup and improve overall usability.

Highlights

  • Enhanced Python Sanity Check Reporting: The Python sanity check mechanism has been significantly improved to provide detailed, per-check pass/fail status and OS-aware resolution hints in both the command-line interface (CLI) and graphical user interface (GUI).
  • Structured Sanity Check Results: The core Python utility library (idf-im-lib) was refactored to return structured results for each sanity check (Python version, pip, venv, standard library, ctypes, SSL/HTTPS), allowing for more granular reporting.
  • Localized Messages and Hints: New localization keys were added to support translated display names for each Python check and provide specific, OS-dependent hints for resolving failures.
  • GUI Integration for Detailed Feedback: The Python sanity check step in the GUI wizard now displays an enumerated list of individual checks, indicating pass/fail status with icons and showing resolution hints for failed items.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src-tauri/locales/app.yml
    • Updated the generic Python sanity check failure message to direct users to detailed entries.
    • Added new localization keys for Python sanity check names (e.g., 'Python Version', 'pip', 'venv', 'SSL/HTTPS').
    • Introduced numerous OS-specific localization keys for resolution hints for each Python sanity check.
  • src-tauri/python_scripts/sanity_check/try_https.py
    • Added a temporary exit(1) on successful HTTPS request for testing purposes, with a comment indicating it will be reverted.
  • src-tauri/src/cli/prompts.rs
    • Added check_display_name and check_hint functions to retrieve localized names and OS-aware hints for sanity checks.
    • Modified python_sanity_check to process structured results, printing detailed pass/fail status and hints to the console.
    • Adjusted error handling to return a simplified failure message after printing per-check details.
  • src-tauri/src/gui/commands/installation.rs
    • Imported check_display_name and check_hint functions for use in GUI-related Python checks.
    • Updated python_sanity_check calls to handle the new structured return type, iterating over results to determine overall Python status.
    • Modified warning message emission to use detailed check names and hints for better user feedback.
  • src-tauri/src/gui/commands/prequisites.rs
    • Imported SanityCheck enum from idf-im-lib.
    • Introduced check_display_name and check_hint functions to provide localized names and OS-specific hints for GUI display.
    • Defined PythonSanityCheckItem struct to encapsulate display name, pass status, and hint for GUI presentation.
    • Refactored python_sanity_check to return a vector of PythonSanityCheckItem objects, providing structured results for the GUI.
  • src-tauri/src/lib/python_utils.rs
    • Introduced SanityCheck enum to categorize different Python checks (e.g., PythonVersion, Pip, Venv, Ssl).
    • Defined SanityCheckResult struct to hold the check type, pass status, and raw message for each individual check.
    • Refactored python_sanity_check function to perform six distinct checks (version, pip, venv, standard library, ctypes, SSL/HTTPS).
    • Updated python_sanity_check to return a Vec<SanityCheckResult>, providing a structured and comprehensive report of all checks.
  • src/components/wizard_steps/PythonSanitycheck.vue
    • Added checkResults data property to store the detailed Python sanity check outcomes.
    • Updated check_python_sanity method to invoke the new structured python_sanity_check command and process its results.
    • Implemented a new UI section to display individual check results with pass/fail icons, check names, and hints.
    • Added a 'Recheck Installation' button to allow users to re-run the sanity checks.
    • Adjusted the visibility of manual installation instructions based on whether detailed check results are available.
    • Applied new CSS styles for the .check-list, .check-row, .check-icon, .check-text, .check-name, and .check-hint elements to visually present the detailed check results.
Activity
  • No specific activity (comments, reviews, progress updates) was provided in the pull request description.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link

@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 significantly improves the Python sanity check functionality. By introducing detailed, per-check results and OS-specific hints, it will provide a much better user experience when diagnosing Python environment issues. The refactoring in python_utils.rs to use structured SanityCheckResult is a great improvement for code clarity and robustness. The corresponding changes in the CLI and GUI layers to display this new information are well-implemented.

I have two main points of feedback:

  1. A temporary testing change in a Python script needs to be reverted before merging.
  2. There is some code duplication between the CLI and GUI command modules that could be refactored into a shared utility module.

Overall, this is a valuable set of improvements. Please see my detailed comments.

if response.getcode() == 200:
print("Request successful!")
print("Response content:", response.read())
exit(1) # this will be reverted back before merging to master

Choose a reason for hiding this comment

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

critical

This line causes the script to exit with an error code even on success, which will cause the SSL/HTTPS sanity check to always fail. The comment indicates this is for testing, but it's critical to remove this before merging.

Comment on lines 128 to 158
pub fn check_display_name(check: SanityCheck) -> String {
match check {
SanityCheck::PythonVersion => t!("python.sanitycheck.check.version"),
SanityCheck::Pip => t!("python.sanitycheck.check.pip"),
SanityCheck::Venv => t!("python.sanitycheck.check.venv"),
SanityCheck::StdLib => t!("python.sanitycheck.check.stdlib"),
SanityCheck::Ctypes => t!("python.sanitycheck.check.ctypes"),
SanityCheck::Ssl => t!("python.sanitycheck.check.ssl"),
}
.to_string()
}

/// OS-aware translated hint for a failed sanity check.
pub fn check_hint(check: SanityCheck) -> String {
let os = std::env::consts::OS;
match (check, os) {
(SanityCheck::PythonVersion, _) => t!("python.sanitycheck.hint.version"),
(SanityCheck::Pip, _) => t!("python.sanitycheck.hint.pip"),
(SanityCheck::StdLib, _) => t!("python.sanitycheck.hint.stdlib"),
(SanityCheck::Venv, "macos") => t!("python.sanitycheck.hint.venv.macos"),
(SanityCheck::Venv, "windows") => t!("python.sanitycheck.hint.venv.windows"),
(SanityCheck::Venv, _) => t!("python.sanitycheck.hint.venv.linux"),
(SanityCheck::Ctypes, "macos") => t!("python.sanitycheck.hint.ctypes.macos"),
(SanityCheck::Ctypes, "windows") => t!("python.sanitycheck.hint.ctypes.windows"),
(SanityCheck::Ctypes, _) => t!("python.sanitycheck.hint.ctypes.linux"),
(SanityCheck::Ssl, "macos") => t!("python.sanitycheck.hint.ssl.macos"),
(SanityCheck::Ssl, "windows") => t!("python.sanitycheck.hint.ssl.windows"),
(SanityCheck::Ssl, _) => t!("python.sanitycheck.hint.ssl.linux"),
}
.to_string()
}

This comment was marked as outdated.

@alirana01 alirana01 force-pushed the python_sanity_check_improvements branch from c5c7cf9 to dae2616 Compare February 12, 2026 13:00
@alirana01 alirana01 changed the title (WIP) Python sanity check improvements Python sanity check improvements Feb 12, 2026
@Fabricio-ESP
Copy link
Collaborator

Thanks for the improvement Ali.
I would like to request to include in this PR, since you are modifying the python detection function, the use of python.exe on windows rather than python3.exe.
For Windows users, if Python is installed from the binaries available on python.org, only python.exe application is installed on the machine, there is no python3.exe.
This would allow the detection of python already installed on the system coming from python.org installers.

Copy link
Collaborator

@Fabricio-ESP Fabricio-ESP left a comment

Choose a reason for hiding this comment

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

Thanks fro the change.
Please run sanity check after removing the hard failure, to make sure there is no other dependency.

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