Skip to content

Failure when UV_PYTHON is not consistent with build's Python version #977

@leodevian

Description

@leodevian

Hello!

Setting UV_PYTHON to a different Python version than the one that was used to install build raises an error.

$ uv init --python 3.13 --lib
$ UV_PYTHON=3.13 uvx --python 3.14 --from build pyproject-build --installer uv
error: No virtual environment found for Python 3.13; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment

This error is caused by the uv pip install command that prioritizes UV_PYTHON over the Python version of the virtual environment that is created by build.

https://github.com/pypa/build/blob/cc2d64238403d40a079accff2176a5f6ea80b453/src/build/env.py#L322C1-L322C108

Should UV_PYTHON be dropped from the environment variables that are passed to the subprocess, set to an empty string, to the Python version of the current interpreter, or to the path to the current interpreter?

This might be an edge case but it happened to me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions