mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-29 08:03:50 +00:00
chore(uv): update env vars map to include newly added ones (#8233)
## Summary Add some new env var mappings ## Test Plan Existing tests
This commit is contained in:
parent
98d049407f
commit
b4dca669b4
7 changed files with 38 additions and 7 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -4206,6 +4206,7 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
"uv-once-map",
|
"uv-once-map",
|
||||||
|
"uv-static",
|
||||||
"wiremock",
|
"wiremock",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ tracing = { workspace = true }
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
urlencoding = { workspace = true }
|
urlencoding = { workspace = true }
|
||||||
|
|
||||||
|
uv-static = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
|
|
@ -9,6 +9,8 @@ use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use uv_static::EnvVars;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Credentials {
|
pub struct Credentials {
|
||||||
/// The name of the user for authentication.
|
/// The name of the user for authentication.
|
||||||
|
@ -145,8 +147,8 @@ impl Credentials {
|
||||||
/// `UV_HTTP_BASIC_PYTORCH_PASSWORD`.
|
/// `UV_HTTP_BASIC_PYTORCH_PASSWORD`.
|
||||||
pub fn from_env(name: &str) -> Option<Self> {
|
pub fn from_env(name: &str) -> Option<Self> {
|
||||||
let name = name.to_uppercase();
|
let name = name.to_uppercase();
|
||||||
let username = std::env::var(format!("UV_HTTP_BASIC_{name}_USERNAME")).ok();
|
let username = std::env::var(EnvVars::http_basic_username(&name)).ok();
|
||||||
let password = std::env::var(format!("UV_HTTP_BASIC_{name}_PASSWORD")).ok();
|
let password = std::env::var(EnvVars::http_basic_password(&name)).ok();
|
||||||
if username.is_none() && password.is_none() {
|
if username.is_none() && password.is_none() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3880,7 +3880,7 @@ pub struct IndexArgs {
|
||||||
/// All indexes provided via this flag take priority over the index specified by
|
/// All indexes provided via this flag take priority over the index specified by
|
||||||
/// `--default-index` (which defaults to PyPI). When multiple `--index` flags are
|
/// `--default-index` (which defaults to PyPI). When multiple `--index` flags are
|
||||||
/// provided, earlier values take priority.
|
/// provided, earlier values take priority.
|
||||||
#[arg(long, env = "UV_INDEX", value_delimiter = ' ', value_parser = parse_index, help_heading = "Index options")]
|
#[arg(long, env = EnvVars::UV_INDEX, value_delimiter = ' ', value_parser = parse_index, help_heading = "Index options")]
|
||||||
pub index: Option<Vec<Maybe<Index>>>,
|
pub index: Option<Vec<Maybe<Index>>>,
|
||||||
|
|
||||||
/// The URL of the default package index (by default: <https://pypi.org/simple>).
|
/// The URL of the default package index (by default: <https://pypi.org/simple>).
|
||||||
|
@ -3890,7 +3890,7 @@ pub struct IndexArgs {
|
||||||
///
|
///
|
||||||
/// The index given by this flag is given lower priority than all other indexes specified via
|
/// The index given by this flag is given lower priority than all other indexes specified via
|
||||||
/// the `--index` flag.
|
/// the `--index` flag.
|
||||||
#[arg(long, env = "UV_DEFAULT_INDEX", value_parser = parse_default_index, help_heading = "Index options")]
|
#[arg(long, env = EnvVars::UV_DEFAULT_INDEX, value_parser = parse_default_index, help_heading = "Index options")]
|
||||||
pub default_index: Option<Maybe<Index>>,
|
pub default_index: Option<Maybe<Index>>,
|
||||||
|
|
||||||
/// (Deprecated: use `--default-index` instead) The URL of the Python package index (by default: <https://pypi.org/simple>).
|
/// (Deprecated: use `--default-index` instead) The URL of the Python package index (by default: <https://pypi.org/simple>).
|
||||||
|
|
|
@ -2,10 +2,20 @@
|
||||||
pub struct EnvVars;
|
pub struct EnvVars;
|
||||||
|
|
||||||
impl EnvVars {
|
impl EnvVars {
|
||||||
|
/// Equivalent to the `--default-index` argument. Base index URL for searching packages.
|
||||||
|
pub const UV_DEFAULT_INDEX: &'static str = "UV_DEFAULT_INDEX";
|
||||||
|
|
||||||
|
/// Equivalent to the `--index` argument. Additional indexes for searching packages.
|
||||||
|
pub const UV_INDEX: &'static str = "UV_INDEX";
|
||||||
|
|
||||||
/// Equivalent to the `--index-url` argument. Base index URL for searching packages.
|
/// Equivalent to the `--index-url` argument. Base index URL for searching packages.
|
||||||
|
///
|
||||||
|
/// Deprecated: use `UV_DEFAULT_INDEX` instead.
|
||||||
pub const UV_INDEX_URL: &'static str = "UV_INDEX_URL";
|
pub const UV_INDEX_URL: &'static str = "UV_INDEX_URL";
|
||||||
|
|
||||||
/// Equivalent to the `--extra-index-url` argument. Additional indexes for searching packages.
|
/// Equivalent to the `--extra-index-url` argument. Additional indexes for searching packages.
|
||||||
|
///
|
||||||
|
/// Deprecated: use `UV_INDEX` instead.
|
||||||
pub const UV_EXTRA_INDEX_URL: &'static str = "UV_EXTRA_INDEX_URL";
|
pub const UV_EXTRA_INDEX_URL: &'static str = "UV_EXTRA_INDEX_URL";
|
||||||
|
|
||||||
/// Equivalent to the `--find-links` argument. Additional package search locations.
|
/// Equivalent to the `--find-links` argument. Additional package search locations.
|
||||||
|
@ -149,6 +159,16 @@ impl EnvVars {
|
||||||
/// Use to control the stack size used by uv. Typically more relevant for Windows in debug mode.
|
/// Use to control the stack size used by uv. Typically more relevant for Windows in debug mode.
|
||||||
pub const UV_STACK_SIZE: &'static str = "UV_STACK_SIZE";
|
pub const UV_STACK_SIZE: &'static str = "UV_STACK_SIZE";
|
||||||
|
|
||||||
|
/// Generates the environment variable key for the HTTP Basic authentication username.
|
||||||
|
pub fn http_basic_username(name: &str) -> String {
|
||||||
|
format!("UV_HTTP_BASIC_{name}_USERNAME")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generates the environment variable key for the HTTP Basic authentication password.
|
||||||
|
pub fn http_basic_password(name: &str) -> String {
|
||||||
|
format!("UV_HTTP_BASIC_{name}_PASSWORD")
|
||||||
|
}
|
||||||
|
|
||||||
/// Used to set the uv commit hash at build time via `build.rs`.
|
/// Used to set the uv commit hash at build time via `build.rs`.
|
||||||
pub const UV_COMMIT_HASH: &'static str = "UV_COMMIT_HASH";
|
pub const UV_COMMIT_HASH: &'static str = "UV_COMMIT_HASH";
|
||||||
|
|
||||||
|
@ -164,6 +184,12 @@ impl EnvVars {
|
||||||
/// Used to set the uv tag distance from head at build time via `build.rs`.
|
/// Used to set the uv tag distance from head at build time via `build.rs`.
|
||||||
pub const UV_LAST_TAG_DISTANCE: &'static str = "UV_LAST_TAG_DISTANCE";
|
pub const UV_LAST_TAG_DISTANCE: &'static str = "UV_LAST_TAG_DISTANCE";
|
||||||
|
|
||||||
|
/// Used in tests for testing providing credentials via environment variables.
|
||||||
|
pub const UV_HTTP_BASIC_PROXY_USERNAME: &'static str = "UV_HTTP_BASIC_PROXY_USERNAME";
|
||||||
|
|
||||||
|
/// Used in tests for testing providing credentials via environment variables.
|
||||||
|
pub const UV_HTTP_BASIC_PROXY_PASSWORD: &'static str = "UV_HTTP_BASIC_PROXY_PASSWORD";
|
||||||
|
|
||||||
/// Used to set the spawning/parent interpreter when using --system in the test suite.
|
/// Used to set the spawning/parent interpreter when using --system in the test suite.
|
||||||
pub const UV_INTERNAL__PARENT_INTERPRETER: &'static str = "UV_INTERNAL__PARENT_INTERPRETER";
|
pub const UV_INTERNAL__PARENT_INTERPRETER: &'static str = "UV_INTERNAL__PARENT_INTERPRETER";
|
||||||
|
|
||||||
|
|
|
@ -6475,8 +6475,8 @@ fn lock_env_credentials() -> Result<()> {
|
||||||
|
|
||||||
// Provide credentials via environment variables.
|
// Provide credentials via environment variables.
|
||||||
uv_snapshot!(context.filters(), context.lock()
|
uv_snapshot!(context.filters(), context.lock()
|
||||||
.env("UV_HTTP_BASIC_PROXY_USERNAME", "public")
|
.env(EnvVars::UV_HTTP_BASIC_PROXY_USERNAME, "public")
|
||||||
.env("UV_HTTP_BASIC_PROXY_PASSWORD", "heron"), @r###"
|
.env(EnvVars::UV_HTTP_BASIC_PROXY_PASSWORD, "heron"), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
|
@ -2327,7 +2327,7 @@ fn no_prerelease_hint_source_builds() -> Result<()> {
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
"#})?;
|
"#})?;
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.pip_install().arg(".").env("UV_EXCLUDE_NEWER", "2018-10-08"), @r###"
|
uv_snapshot!(context.filters(), context.pip_install().arg(".").env(EnvVars::UV_EXCLUDE_NEWER, "2018-10-08"), @r###"
|
||||||
success: false
|
success: false
|
||||||
exit_code: 2
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue