mirror of https://github.com/astral-sh/uv
Sync env vars with uv-static crate 🧹 (#10016)
## Summary Updates some env vars references to use `EnvVars` accordingly.
This commit is contained in:
parent
1d8dac17fd
commit
e65a273f1b
|
|
@ -4300,7 +4300,7 @@ pub struct PythonInstallArgs {
|
||||||
///
|
///
|
||||||
/// See `uv python dir` to view the current Python installation directory. Defaults to
|
/// See `uv python dir` to view the current Python installation directory. Defaults to
|
||||||
/// `~/.local/share/uv/python`.
|
/// `~/.local/share/uv/python`.
|
||||||
#[arg(long, short, env = "UV_PYTHON_INSTALL_DIR")]
|
#[arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR)]
|
||||||
pub install_dir: Option<PathBuf>,
|
pub install_dir: Option<PathBuf>,
|
||||||
|
|
||||||
/// The Python version(s) to install.
|
/// The Python version(s) to install.
|
||||||
|
|
@ -4363,7 +4363,7 @@ pub struct PythonInstallArgs {
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
pub struct PythonUninstallArgs {
|
pub struct PythonUninstallArgs {
|
||||||
/// The directory where the Python was installed.
|
/// The directory where the Python was installed.
|
||||||
#[arg(long, short, env = "UV_PYTHON_INSTALL_DIR")]
|
#[arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR)]
|
||||||
pub install_dir: Option<PathBuf>,
|
pub install_dir: Option<PathBuf>,
|
||||||
|
|
||||||
/// The Python version(s) to uninstall.
|
/// The Python version(s) to uninstall.
|
||||||
|
|
|
||||||
|
|
@ -539,6 +539,14 @@ impl EnvVars {
|
||||||
#[attr_hidden]
|
#[attr_hidden]
|
||||||
pub const KEYRING_TEST_CREDENTIALS: &'static str = "KEYRING_TEST_CREDENTIALS";
|
pub const KEYRING_TEST_CREDENTIALS: &'static str = "KEYRING_TEST_CREDENTIALS";
|
||||||
|
|
||||||
|
/// Used to set the vendor links url for tests.
|
||||||
|
#[attr_hidden]
|
||||||
|
pub const UV_TEST_VENDOR_LINKS_URL: &'static str = "UV_TEST_VENDOR_LINKS_URL";
|
||||||
|
|
||||||
|
/// Used to set an index url for tests.
|
||||||
|
#[attr_hidden]
|
||||||
|
pub const UV_TEST_INDEX_URL: &'static str = "UV_TEST_INDEX_URL";
|
||||||
|
|
||||||
/// `.env` files from which to load environment variables when executing `uv run` commands.
|
/// `.env` files from which to load environment variables when executing `uv run` commands.
|
||||||
pub const UV_ENV_FILE: &'static str = "UV_ENV_FILE";
|
pub const UV_ENV_FILE: &'static str = "UV_ENV_FILE";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,15 @@ pub const PACKSE_VERSION: &str = "0.3.42";
|
||||||
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
|
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
|
||||||
/// to prevent dependency confusion attacks against our test suite.
|
/// to prevent dependency confusion attacks against our test suite.
|
||||||
pub fn build_vendor_links_url() -> String {
|
pub fn build_vendor_links_url() -> String {
|
||||||
env::var("UV_TEST_VENDOR_LINKS_URL").ok().unwrap_or(format!(
|
env::var(EnvVars::UV_TEST_VENDOR_LINKS_URL)
|
||||||
"https://raw.githubusercontent.com/astral-sh/packse/{PACKSE_VERSION}/vendor/links.html"
|
.ok()
|
||||||
))
|
.unwrap_or(format!(
|
||||||
|
"https://raw.githubusercontent.com/astral-sh/packse/{PACKSE_VERSION}/vendor/links.html"
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn packse_index_url() -> String {
|
pub fn packse_index_url() -> String {
|
||||||
env::var("UV_TEST_INDEX_URL").ok().unwrap_or(format!(
|
env::var(EnvVars::UV_TEST_INDEX_URL).ok().unwrap_or(format!(
|
||||||
"https://astral-sh.github.io/packse/{PACKSE_VERSION}/simple-html/"
|
"https://astral-sh.github.io/packse/{PACKSE_VERSION}/simple-html/"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -593,7 +593,7 @@ fn python_find_venv_invalid() {
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
// Unless the virtual environment is not active
|
// Unless the virtual environment is not active
|
||||||
uv_snapshot!(context.filters(), context.python_find().env_remove("VIRTUAL_ENV"), @r###"
|
uv_snapshot!(context.filters(), context.python_find().env_remove(EnvVars::VIRTUAL_ENV), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
|
||||||
|
|
@ -3173,7 +3173,7 @@ fn run_with_multiple_env_files() -> Result<()> {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.run().arg("test.py").env("UV_ENV_FILE", ".env1 .env2"), @r###"
|
uv_snapshot!(context.filters(), context.run().arg("test.py").env(EnvVars::UV_ENV_FILE, ".env1 .env2"), @r###"
|
||||||
success: false
|
success: false
|
||||||
exit_code: 2
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
|
||||||
|
|
@ -5556,7 +5556,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||||
uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path())
|
uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path())
|
||||||
.arg("-r")
|
.arg("-r")
|
||||||
.arg("requirements.in")
|
.arg("requirements.in")
|
||||||
.env("UV_NO_VERIFY_HASHES", "1")
|
.env(EnvVars::UV_NO_VERIFY_HASHES, "1")
|
||||||
.arg("--show-settings"), @r###"
|
.arg("--show-settings"), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
|
|
|
||||||
|
|
@ -1117,7 +1117,7 @@ fn create_venv_apostrophe() {
|
||||||
|
|
||||||
// One of them should be commonly available on a linux developer machine, if not, we have to
|
// One of them should be commonly available on a linux developer machine, if not, we have to
|
||||||
// extend the fallbacks.
|
// extend the fallbacks.
|
||||||
let shell = env::var_os("SHELL").unwrap_or(OsString::from("bash"));
|
let shell = env::var_os(EnvVars::SHELL).unwrap_or(OsString::from("bash"));
|
||||||
let mut child = Command::new(shell)
|
let mut child = Command::new(shell)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue