Skip to content

Allow setting virtual environment options in pyproject.toml #5737

@chrisrodrigue

Description

@chrisrodrigue

When running uv venv, the user may specify the options --system-site-packages and --relocatable. These values persist in .venv/pyenv.cfg as shown:

home = C:\WinPython\python-3.12.4.amd64
implementation = CPython
uv = 0.2.33
version_info = 3.12.4
include-system-site-packages = true
relocatable = true

The uv sync command implicitly creates a virtual environment in .venv, which is awesome. However, it is not possible to pass these options to uv sync or set them in the tool.uv section (or a tool.uv.venv section) of pyproject.toml. The virtual environment created with uv sync always defaults to setting include-system-site-package and relocatable to false.

I propose that uv be capable of reading these from pyproject.toml, and also when passed to uv sync.

Maybe a generalized approach to file-based configuration (both uv.toml and pyproject.toml) of uv behavior could be to support a section corresponding to each uv command for all available options:

Example pyproject.toml demonstrating command customization:

[tool.uv]
no-build-isolation = true
dev-dependencies = []

[uv.tool.venv]
relocatable = true
system-site-packages = true

[uv.tool.sync]
relocatable = true
system-site-packages = true
all-extras = true

# Generalization
[uv.tool.command]
option = value

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions