mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00

## Summary This PR declares and documents all environment variables that are used in one way or another in `uv`, either internally, or externally, or transitively under a common struct. I think over time as uv has grown there's been many environment variables introduced. Its harder to know which ones exists, which ones are missing, what they're used for, or where are they used across the code. The docs only documents a handful of them, for others you'd have to dive into the code and inspect across crates to know which crates they're used on or where they're relevant. This PR is a starting attempt to unify them, make it easier to discover which ones we have, and maybe unlock future posibilities in automating generating documentation for them. I think we can split out into multiple structs later to better organize, but given the high influx of PR's and possibly new environment variables introduced/re-used, it would be hard to try to organize them all now into their proper namespaced struct while this is all happening given merge conflicts and/or keeping up to date. I don't think this has any impact on performance as they all should still be inlined, although it may affect local build times on changes to the environment vars as more crates would likely need a rebuild. Lastly, some of them are declared but not used in the code, for example those in `build.rs`. I left them declared because I still think it's useful to at least have a reference. Did I miss any? Are their initial docs cohesive? Note, `uv-static` is a terrible name for a new crate, thoughts? Others considered `uv-vars`, `uv-consts`. ## Test Plan Existing tests
106 lines
3 KiB
Text
106 lines
3 KiB
Text
//! DO NOT EDIT
|
|
//!
|
|
//! Generated with `{{generated_with}}`
|
|
//! Scenarios from <{{generated_from}}>
|
|
//!
|
|
#![cfg(all(feature = "python", feature = "pypi", unix))]
|
|
|
|
use std::env;
|
|
use std::process::Command;
|
|
|
|
use anyhow::Result;
|
|
use assert_cmd::assert::OutputAssertExt;
|
|
use assert_fs::fixture::{FileWriteStr, PathChild};
|
|
use predicates::prelude::predicate;
|
|
|
|
use uv_static::EnvVars;
|
|
|
|
use crate::common::{
|
|
build_vendor_links_url, get_bin, packse_index_url, python_path_with_versions, uv_snapshot,
|
|
TestContext,
|
|
};
|
|
|
|
/// Provision python binaries and return a `pip compile` command with options shared across all scenarios.
|
|
fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
|
let python_path = python_path_with_versions(&context.temp_dir, python_versions)
|
|
.expect("Failed to create Python test path");
|
|
let mut command = Command::new(get_bin());
|
|
command
|
|
.arg("pip")
|
|
.arg("compile")
|
|
.arg("requirements.in")
|
|
.arg("--index-url")
|
|
.arg(packse_index_url())
|
|
.arg("--find-links")
|
|
.arg(build_vendor_links_url());
|
|
context.add_shared_args(&mut command, true);
|
|
command.env_remove(EnvVars::UV_EXCLUDE_NEWER);
|
|
command.env(EnvVars::UV_TEST_PYTHON_PATH, python_path);
|
|
|
|
command
|
|
}
|
|
|
|
{{#scenarios}}
|
|
|
|
/// {{description}}
|
|
///
|
|
/// ```text
|
|
/// {{name}}
|
|
{{#tree}}
|
|
/// {{.}}
|
|
{{/tree}}
|
|
/// ```
|
|
{{#python_patch}}
|
|
#[cfg(feature = "python-patch")]
|
|
{{/python_patch}}
|
|
#[test]
|
|
fn {{module_name}}() -> Result<()> {
|
|
let context = TestContext::new("{{environment.python}}");
|
|
let python_versions = &[{{#environment.additional_python}}"{{.}}", {{/environment.additional_python}}];
|
|
|
|
// In addition to the standard filters, swap out package names for shorter messages
|
|
let mut filters = context.filters();
|
|
filters.push((r"{{name}}-", "package-"));
|
|
|
|
let requirements_in = context.temp_dir.child("requirements.in");
|
|
{{#root.requires}}
|
|
requirements_in.write_str("{{requirement}}")?;
|
|
{{/root.requires}}
|
|
|
|
{{#expected.explanation}}
|
|
// {{expected.explanation}}
|
|
{{/expected.explanation}}
|
|
let output = uv_snapshot!(filters, command(&context, python_versions)
|
|
{{#resolver_options.prereleases}}
|
|
.arg("--prerelease=allow")
|
|
{{/resolver_options.prereleases}}
|
|
{{#resolver_options.no_build}}
|
|
.arg("--only-binary")
|
|
.arg("{{.}}")
|
|
{{/resolver_options.no_build}}
|
|
{{#resolver_options.no_binary}}
|
|
.arg("--no-binary")
|
|
.arg("{{.}}")
|
|
{{/resolver_options.no_binary}}
|
|
{{#resolver_options.python}}
|
|
.arg("--python-version={{.}}")
|
|
{{/resolver_options.python}}, @r###"<snapshot>
|
|
"###
|
|
);
|
|
|
|
output
|
|
.assert()
|
|
{{#expected.satisfiable}}
|
|
.success()
|
|
{{#expected.packages}}
|
|
.stdout(predicate::str::contains("{{name}}=={{version}}"))
|
|
{{/expected.packages}}
|
|
{{/expected.satisfiable}}
|
|
{{^expected.satisfiable}}
|
|
.failure()
|
|
{{/expected.satisfiable}}
|
|
;
|
|
|
|
Ok(())
|
|
}
|
|
{{/scenarios}}
|