Skip to content

fix(runtime): isolate packaged Python from user site-packages#93

Merged
zouyonghe merged 1 commit intoAstrBotDevs:mainfrom
zouyonghe:fix/packaged-python-user-site-clean
Mar 14, 2026
Merged

fix(runtime): isolate packaged Python from user site-packages#93
zouyonghe merged 1 commit intoAstrBotDevs:mainfrom
zouyonghe:fix/packaged-python-user-site-clean

Conversation

@zouyonghe
Copy link
Member

@zouyonghe zouyonghe commented Mar 14, 2026

Summary

  • disable Python user site-packages when launching the packaged backend runtime so user-installed packages cannot shadow bundled dependencies
  • add a regression test for packaged backend environment sanitization to keep bundled pydantic-settings from importing an incompatible user-installed pydantic
  • supersedes fix(runtime): isolate packaged Python from user site-packages #92 with a clean branch based on the current upstream main

Test Plan

  • cargo test sanitize_packaged_python_environment
  • cargo test
  • cargo fmt --check

Summary by Sourcery

Ensure the packaged backend runtime launches with a sanitized Python environment that ignores user site-packages to prevent interference with bundled dependencies.

Bug Fixes:

  • Prevent user-installed Python packages from shadowing bundled dependencies in the packaged backend runtime.

Tests:

  • Add a regression test verifying that the packaged Python environment disables user site-packages via PYTHONNOUSERSITE.

@gemini-code-assist
Copy link

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 a potential issue where user-installed Python packages could interfere with the stable operation of the application's packaged backend runtime. By isolating the packaged Python environment, it ensures that only the intended, bundled dependencies are used, thereby enhancing the reliability and predictability of the application's backend.

Highlights

  • Environment Sanitization: Disabled Python user site-packages when launching the packaged backend runtime to prevent user-installed packages from shadowing bundled dependencies.
  • Regression Test: Added a regression test to ensure the packaged backend environment sanitization correctly prevents incompatible user-installed packages (e.g., pydantic) from interfering with bundled dependencies (e.g., pydantic-settings).
  • PR Supersession: This pull request supersedes fix(runtime): isolate packaged Python from user site-packages #92, providing a clean branch based on the current upstream main.
Changelog
  • src-tauri/src/backend/launch.rs
    • Set the PYTHONNOUSERSITE environment variable to "1" for the backend command.
    • Added a new test case sanitize_packaged_python_environment_disables_user_site_packages to verify the PYTHONNOUSERSITE environment variable is correctly set.
Activity
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

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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 correctly isolates the packaged Python environment from user site-packages by setting the PYTHONNOUSERSITE environment variable. This prevents potential conflicts with user-installed packages. The change is accompanied by a new regression test to ensure the environment is sanitized as expected. The implementation is sound and I found no issues to report.

@zouyonghe zouyonghe merged commit 10b226e into AstrBotDevs:main Mar 14, 2026
4 checks passed
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.

1 participant