Add `UV_BREAK_SYSTEM_PACKAGES` environment variable (#2995)

## Summary

Requested here: https://github.com/astral-sh/uv/issues/2988. Seems
reasonable to me given that pip supports it and we already have
`UV_SYSTEM_PYTHON`.

Closes https://github.com/astral-sh/uv/issues/2988
This commit is contained in:
Charlie Marsh 2024-04-11 11:58:00 -04:00 committed by GitHub
parent 8e5a40e33c
commit d03e9f2b8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 6 deletions

View File

@ -453,10 +453,17 @@ uv accepts the following command-line arguments as environment variables:
`lowest-direct`, uv will install the lowest compatible versions of all direct dependencies.
- `UV_PRERELEASE`: Equivalent to the `--prerelease` command-line argument. For example, if set to
`allow`, uv will allow pre-release versions for all dependencies.
- `UV_SYSTEM_PYTHON`: Equivalent to the `--system` command-line argument. If set to `true`, uv
- `UV_SYSTEM_PYTHON`: Equivalent to the `--system` command-line argument. If set to `true`, uv
will use the first Python interpreter found in the system `PATH`.
WARNING: `UV_SYSTEM_PYTHON=true` is intended for use in continuous integration (CI) environments and
should be used with caution, as it can modify the system Python installation.
WARNING: `UV_SYSTEM_PYTHON=true` is intended for use in continuous integration (CI) or
containerized environments and should be used with caution, as modifying the system Python
can lead to unexpected behavior.
- `UV_BREAK_SYSTEM_PACKAGES`: Equivalent to the `--break-system-packages` command-line argument. If
set to `true`, uv will allow the installation of packages that conflict with system-installed
packages.
WARNING: `UV_BREAK_SYSTEM_PACKAGES=true` is intended for use in continuous integration (CI) or
containerized environments and should be used with caution, as modifying the system Python
can lead to unexpected behavior.
- `UV_NATIVE_TLS`: Equivalent to the `--native-tls` command-line argument. If set to `true`, uv
will use the system's trust store instead of the bundled `webpki-roots` crate.
- `UV_INDEX_STRATEGY`: Equivalent to the `--index-strategy` command-line argument. For example, if

View File

@ -657,7 +657,7 @@ struct PipSyncArgs {
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
/// explicitly recommend against modifications by other package managers (like `uv` or `pip`).
#[clap(long, requires = "discovery")]
#[clap(long, env = "UV_BREAK_SYSTEM_PACKAGES", requires = "discovery")]
break_system_packages: bool,
/// Use legacy `setuptools` behavior when building source distributions without a
@ -941,7 +941,7 @@ struct PipInstallArgs {
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
/// explicitly recommend against modifications by other package managers (like `uv` or `pip`).
#[clap(long, requires = "discovery")]
#[clap(long, env = "UV_BREAK_SYSTEM_PACKAGES", requires = "discovery")]
break_system_packages: bool,
/// Use legacy `setuptools` behavior when building source distributions without a
@ -1086,7 +1086,7 @@ struct PipUninstallArgs {
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
/// explicitly recommend against modifications by other package managers (like `uv` or `pip`).
#[clap(long, requires = "discovery")]
#[clap(long, env = "UV_BREAK_SYSTEM_PACKAGES", requires = "discovery")]
break_system_packages: bool,
/// Run offline, i.e., without accessing the network.