Skip to content

✨ feat(config): add default_base_python config key#3783

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:feature/default-base-python
Feb 20, 2026
Merged

✨ feat(config): add default_base_python config key#3783
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:feature/default-base-python

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

Environments without a Python factor in their name (e.g. lint, type, docs) currently fall back to sys.executable when base_python isn't explicitly set. This means the interpreter varies across machines — Ubuntu 22.04 defaults to 3.10, Fedora 37 to 3.11 — harming reproducibility and causing unexpected failures when dependencies don't support the host's Python version. 🔧 Setting base_python globally in [env_run_base] works around this but conflicts with pyXY factor-named environments.

The new default_base_python key sits at the environment config level and acts as a fallback only when no Python factor is detected and no explicit base_python is set. This gives it clear precedence semantics: Python factor > explicit base_python > default_base_python > sys.executable. Placing it in [env_run_base] rather than [tox] allows per-environment overrides when needed.

[env_run_base]
default_base_python = ["python3.10", "python3.9"]

✨ Existing configurations are unaffected since the default remains sys.executable. This closes #2846.

Environments without a Python factor or explicit base_python now
consult default_base_python before falling back to sys.executable.
This lets projects pin a fallback interpreter for reproducibility
without conflicting with pyXY factor-named environments.
@gaborbernat gaborbernat force-pushed the feature/default-base-python branch from c96f589 to e5101d1 Compare February 20, 2026 02:23
@gaborbernat gaborbernat enabled auto-merge (squash) February 20, 2026 02:25
@gaborbernat gaborbernat merged commit 294a995 into tox-dev:main Feb 20, 2026
28 checks passed
@gaborbernat gaborbernat deleted the feature/default-base-python branch February 20, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify default Python(s)

1 participant