Skip to content

feat(python): rework python.uv_venv_auto setting#7905

Merged
jdx merged 3 commits into
jdx:mainfrom
halms:feat/uv-venv-auto-source
Feb 2, 2026
Merged

feat(python): rework python.uv_venv_auto setting#7905
jdx merged 3 commits into
jdx:mainfrom
halms:feat/uv-venv-auto-source

Conversation

@halms

@halms halms commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Context

With the current python.uv_venv_auto behavior, there are two annoying things:

  1. it always creates venvs if they not exist
    This is not needed for uv, since that usually creates/updates it's venvs transparently (when doing uv run or uv sync, ...).
    And it breaks mise prepare for uv since it creates the .venv folder but does not install any deps. So mise prepare thinks everything is up-to-date when it isn't. (the uv-native venv creation appears to not have been covered by fix(prepare): handle freshness check for auto-created venvs #7770)
  2. it exports the mise python version to the env var UV_PYTHON, which forces uv to use that version.

Changes

  • Upfront, some reworking of the schema of settings.toml, specifically the type and enum definitions.
    Added the BooleanOrString type needed for this and also made the enum definitions more flexible (e.g. with mixed types)
  • Introducing new values for python.uv_venv_auto
    • "source" only sources existing venvs
    • "create|source" creates if not exists and sources venvs (but does not set UV_PYTHON anymore)
    • false does nothing – like now
    • true (legacy, will be deprecated in 6 months) – like now, also sets UV_PYTHON
  • Unified the code creating/sourcing venvs between settings.python.uv_venv_auto and env._.python.venv, which should now also mark these as stale at creation.

I think with this changes, python.uv_venv_auto becomes much more useful.

Copilot AI review requested due to automatic review settings January 30, 2026 11:08
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @halms, 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 how mise integrates with uv virtual environments, addressing issues where the previous automatic venv creation was incomplete. It introduces a dedicated setting for sourcing existing uv venvs and clarifies that venv creation should be managed through mise prepare or uv sync. This change improves the robustness and predictability of Python environment management within mise when using uv.

Highlights

  • New Setting for UV Venv Sourcing: Introduced python.uv_venv_auto_source to automatically source existing uv virtual environments without creating them.
  • Deprecation of Old Setting: The python.uv_venv_auto setting has been deprecated, and a warning will be issued when it is used.
  • Clarified Venv Creation vs. Sourcing: Both the new and deprecated settings now only source existing virtual environments. Automatic creation of uv venvs is now explicitly handled by enabling [prepare.uv] and running mise prep.
  • Code Refactoring: The internal logic for uv virtual environment handling has been refactored to remove automatic creation, add checks for existing venvs, and provide guidance for creation via mise prepare.
  • Documentation and Test Updates: Documentation, schema, and end-to-end tests have been updated to reflect the new setting and behavior.
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.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request effectively introduces the python.uv_venv_auto_source setting to only source existing uv virtual environments, and correctly deprecates the old python.uv_venv_auto setting. The logic is sound, and the changes across documentation, tests, and schema are consistent. The move to guide users towards mise prep for venv creation is a good one. I have one suggestion to enhance the warning messages for a better user experience when a venv is missing.

Comment thread src/uv.rs

Copilot AI 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.

Pull request overview

Adds a new setting to auto-source existing uv virtual environments (without creating them) and deprecates the previous auto-create behavior, aligning with the new prepare workflow.

Changes:

  • Add python.uv_venv_auto_source and deprecate python.uv_venv_auto.
  • Update uv venv integration to only load an existing .venv (and emit guidance when missing).
  • Update schema/docs and adjust e2e tests to cover the new behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/uv.rs Switches from “create or load” to “load only”, adds deprecation + missing-venv guidance, and checks for [prepare.uv].
settings.toml Marks python.uv_venv_auto deprecated and introduces python.uv_venv_auto_source.
schema/mise.json Updates JSON schema for deprecation and new setting.
e2e/core/test_python_uv_venv_x_tiny Uses the new setting and ensures a .venv exists for the test via uv venv.
e2e/core/test_python_uv_venv Updates commented example to the new setting name.
e2e-win/uv.Tests.ps1 Switches Windows e2e to python.uv_venv_auto_source.
docs/mise-cookbook/python.md Updates docs to recommend the new setting and explain prepare.uv + mise prep flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/uv.rs Outdated
@halms halms force-pushed the feat/uv-venv-auto-source branch 3 times, most recently from cffb0a1 to d830ce1 Compare January 30, 2026 11:49
@halms halms requested a review from Copilot January 30, 2026 14:10

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/uv.rs Outdated
Comment thread src/uv.rs Outdated
@jdx jdx marked this pull request as draft January 30, 2026 14:51
@halms halms force-pushed the feat/uv-venv-auto-source branch from d830ce1 to f5928c2 Compare January 30, 2026 20:13
@halms halms changed the title feat(python): add uv venv auto-source setting feat(python): rework python.uv_venv_auto setting Jan 30, 2026
@halms halms force-pushed the feat/uv-venv-auto-source branch from f5928c2 to 8cb3936 Compare January 30, 2026 20:54
@halms halms requested a review from Copilot January 30, 2026 20:56
@halms

halms commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

Copilot AI 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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.rs Outdated
Comment thread xtasks/render/schema.ts Outdated

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request effectively reworks the python.uv_venv_auto setting, introducing more granular control over virtual environment handling with uv. The changes are well-structured, with significant refactoring to improve modularity, such as extracting venv creation logic. The updates to documentation, tests, and schemas are comprehensive and align with the new functionality.

I've identified a couple of areas for improvement. One is a potential discrepancy between the implemented behavior and the description for the legacy true value of python.uv_venv_auto. Another is a suggestion to further refactor a large function to improve maintainability. Overall, this is a great enhancement.

Comment thread src/uv.rs
Comment thread src/config/env_directive/venv.rs
@halms halms force-pushed the feat/uv-venv-auto-source branch 7 times, most recently from 7a4f6fb to 469bc42 Compare January 30, 2026 22:57
@halms halms requested a review from Copilot January 30, 2026 22:58
@halms

halms commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

Comment thread xtasks/render/schema.ts
ListPath: "string[]",
SetString: "string[]",
"IndexMap<String, String>": "object",
BoolOrString: ["boolean", "string"],

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

if this ends up being too much of a pain we could have a replacement env var maybe. That said, I've needed this before so it will come in handy in the future I'm sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It took a bit of back and forth, but I think I got it now.

Also tried allowing the type description in settings.toml already being an array, like

type = ["Boolean", "String"]

But that led to more complications, so I went with the predefined type instead.

@halms halms force-pushed the feat/uv-venv-auto-source branch 3 times, most recently from 7b6a3c8 to 34a4435 Compare February 2, 2026 10:21
@halms halms marked this pull request as ready for review February 2, 2026 10:21
@halms halms force-pushed the feat/uv-venv-auto-source branch from 34a4435 to eaad0de Compare February 2, 2026 10:37
@halms halms requested a review from Copilot February 2, 2026 10:57
@halms

halms commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

Copilot AI 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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/uv.rs

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request is a well-executed feature enhancement that reworks the python.uv_venv_auto setting for better flexibility and usability with uv. The introduction of new string-based options ("source", "create|source") and the deprecation of the legacy boolean true value are clear improvements. The refactoring of venv creation logic into a shared, centralized function in src/config/env_directive/venv.rs significantly improves code structure and maintainability. The changes are consistently applied across the codebase, including configuration, schemas, documentation, and tests. I've noted a couple of minor maintainability improvements in the build script to make it more robust for future changes. Overall, this is an excellent contribution.

Comment thread build.rs
Comment thread build.rs
@halms halms force-pushed the feat/uv-venv-auto-source branch 2 times, most recently from 0243954 to 8c386ff Compare February 2, 2026 11:25
@jdx

jdx commented Feb 2, 2026

Copy link
Copy Markdown
Owner

bugbot run

@jdx

jdx commented Feb 2, 2026

Copy link
Copy Markdown
Owner

I think you need to handle "true" so MISE_PYTHON_UV_VENV_AUTO=true works correctly too

halms added 2 commits February 2, 2026 16:54
- add new BooleanOrString type
- enable more flexible definition of enum values/descriptions
Introduce new options for python.uv_venv_auto: `"source"`, `"create|source"`
and deprecate (in the future) `true`.
`false` remains the same.

Factorize venv code between `uv.rs` and `venv.rs`.
@halms halms force-pushed the feat/uv-venv-auto-source branch from 8c386ff to 10daaaf Compare February 2, 2026 15:57
@halms

halms commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

I think you need to handle "true" so MISE_PYTHON_UV_VENV_AUTO=true works correctly too
Aaah, yes was only thinking about the toml file (which is typed) and not the env vars.

Should be fixed now.

I've copied what confique does (which is used for the purely boolean env vars) and treat "true" | "yes" | "1" as true and "false" | "no" | "0" as false (both case-insensitive).

@halms halms force-pushed the feat/uv-venv-auto-source branch from 10daaaf to 356916f Compare February 2, 2026 16:09
@jdx jdx merged commit 1c4ebb5 into jdx:main Feb 2, 2026
34 checks passed
@halms halms deleted the feat/uv-venv-auto-source branch February 2, 2026 20:03
mise-en-dev added a commit that referenced this pull request Feb 3, 2026
### 🚀 Features

- **(asset-matcher)** enable `mingw-w64` detection for windows packages
by @lchagnoleau in [#7981](#7981)
- **(crates/vfox)** add download_path to BackendInstall context by
@malept in [#7959](#7959)
- **(python)** rework `python.uv_venv_auto` setting by @halms in
[#7905](#7905)
- add "Did you mean?" suggestions and inactive tool warnings by @jdx in
[#7965](#7965)

### 🐛 Bug Fixes

- **(hook-env)** skip remote version fetching for uninstalled tools in
prefer-offline mode by @jdx in
[#7976](#7976)
- **(install.sh)** Corret `setup` to `set up` by @gogolok in
[#7980](#7980)
- retry spawn on ETXTBSY (Text file busy) by @jdx in
[#7964](#7964)
- improve ToolOptions parsing to support comma separated values by
@roele in [#7971](#7971)

### 📚 Documentation

- improve plugin documentation with comparisons and template links by
@jdx in [#7962](#7962)

### 📦️ Dependency Updates

- bump hyper-util, system-configuration, lru, aws-sdk, and others by
@jdx in [#7977](#7977)

### Chore

- **(vfox)** add LuaCATS type definitions for plugin IDE support by @jdx
in [#7961](#7961)
- **(vfox)** add `download_path` to `BackendInstallCtx` type defintion
by @malept in [#7973](#7973)
- add stylua linting for vfox plugin Lua files by @jdx in
[#7960](#7960)
- use system Rust for PPA builds on Ubuntu 26.04+ by @jdx in
[#7956](#7956)

### New Contributors

- @gogolok made their first contribution in
[#7980](#7980)

## 📦 Aqua Registry Updates

#### New Packages (4)

- [`autobrr/mkbrr`](https://github.com/autobrr/mkbrr)
- [`dodobrands/Peekie`](https://github.com/dodobrands/Peekie)
-
[`grpc/grpc-java/protoc-gen-grpc-java`](https://github.com/grpc/grpc-java/protoc-gen-grpc-java)
-
[`str4d/age-plugin-yubikey`](https://github.com/str4d/age-plugin-yubikey)

#### Updated Packages (3)

- [`biomejs/biome`](https://github.com/biomejs/biome)
-
[`rust-cross/cargo-zigbuild`](https://github.com/rust-cross/cargo-zigbuild)
- [`siderolabs/talos`](https://github.com/siderolabs/talos)
janlarres added a commit to janlarres/etc that referenced this pull request Feb 9, 2026
The value 'true' is deprecated, and setting it to 'source' prevents some
issues highlighted in jdx/mise#7905
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
## Context
With the current `python.uv_venv_auto` behavior, there are two annoying
things:
1. it always creates venvs if they not exist
This is not needed for `uv`, since that usually creates/updates it's
venvs transparently (when doing `uv run` or `uv sync`, ...).
And it breaks `mise prepare` for `uv` since it creates the `.venv`
folder but does not install any deps. So `mise prepare` thinks
everything is up-to-date when it isn't. (the uv-native venv creation
appears to not have been covered by jdx#7770)
2. it exports the mise python version to the env var `UV_PYTHON`, which
forces uv to use that _version_.

## Changes
- Upfront, some reworking of the schema of `settings.toml`, specifically
the `type` and `enum` definitions.
Added the `BooleanOrString` type needed for this and also made the
`enum` definitions more flexible (e.g. with mixed types)
- Introducing new values for `python.uv_venv_auto`
  - `"source"` only sources existing venvs
- `"create|source"` creates if not exists and sources venvs (but does
not set UV_PYTHON anymore)
  - `false` does nothing – like now
- `true` (legacy, will be deprecated in 6 months) – like now, also sets
UV_PYTHON
- Unified the code creating/sourcing venvs between
`settings.python.uv_venv_auto` and `env._.python.venv`, which should now
also mark these as stale at creation.

I think with this changes, `python.uv_venv_auto` becomes much more
useful.
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
### 🚀 Features

- **(asset-matcher)** enable `mingw-w64` detection for windows packages
by @lchagnoleau in [jdx#7981](jdx#7981)
- **(crates/vfox)** add download_path to BackendInstall context by
@malept in [jdx#7959](jdx#7959)
- **(python)** rework `python.uv_venv_auto` setting by @halms in
[jdx#7905](jdx#7905)
- add "Did you mean?" suggestions and inactive tool warnings by @jdx in
[jdx#7965](jdx#7965)

### 🐛 Bug Fixes

- **(hook-env)** skip remote version fetching for uninstalled tools in
prefer-offline mode by @jdx in
[jdx#7976](jdx#7976)
- **(install.sh)** Corret `setup` to `set up` by @gogolok in
[jdx#7980](jdx#7980)
- retry spawn on ETXTBSY (Text file busy) by @jdx in
[jdx#7964](jdx#7964)
- improve ToolOptions parsing to support comma separated values by
@roele in [jdx#7971](jdx#7971)

### 📚 Documentation

- improve plugin documentation with comparisons and template links by
@jdx in [jdx#7962](jdx#7962)

### 📦️ Dependency Updates

- bump hyper-util, system-configuration, lru, aws-sdk, and others by
@jdx in [jdx#7977](jdx#7977)

### Chore

- **(vfox)** add LuaCATS type definitions for plugin IDE support by @jdx
in [jdx#7961](jdx#7961)
- **(vfox)** add `download_path` to `BackendInstallCtx` type defintion
by @malept in [jdx#7973](jdx#7973)
- add stylua linting for vfox plugin Lua files by @jdx in
[jdx#7960](jdx#7960)
- use system Rust for PPA builds on Ubuntu 26.04+ by @jdx in
[jdx#7956](jdx#7956)

### New Contributors

- @gogolok made their first contribution in
[jdx#7980](jdx#7980)

## 📦 Aqua Registry Updates

#### New Packages (4)

- [`autobrr/mkbrr`](https://github.com/autobrr/mkbrr)
- [`dodobrands/Peekie`](https://github.com/dodobrands/Peekie)
-
[`grpc/grpc-java/protoc-gen-grpc-java`](https://github.com/grpc/grpc-java/protoc-gen-grpc-java)
-
[`str4d/age-plugin-yubikey`](https://github.com/str4d/age-plugin-yubikey)

#### Updated Packages (3)

- [`biomejs/biome`](https://github.com/biomejs/biome)
-
[`rust-cross/cargo-zigbuild`](https://github.com/rust-cross/cargo-zigbuild)
- [`siderolabs/talos`](https://github.com/siderolabs/talos)
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.

3 participants