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

@ -455,8 +455,15 @@ uv accepts the following command-line arguments as environment variables:
`allow`, uv will allow pre-release versions for all dependencies. `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`. 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 WARNING: `UV_SYSTEM_PYTHON=true` is intended for use in continuous integration (CI) or
should be used with caution, as it can modify the system Python installation. 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 - `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. 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 - `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 /// 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 /// 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`). /// 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, break_system_packages: bool,
/// Use legacy `setuptools` behavior when building source distributions without a /// 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 /// 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 /// 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`). /// 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, break_system_packages: bool,
/// Use legacy `setuptools` behavior when building source distributions without a /// 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 /// 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 /// 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`). /// 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, break_system_packages: bool,
/// Run offline, i.e., without accessing the network. /// Run offline, i.e., without accessing the network.