mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Rename PUFFIN
environment variables to UV
(#1319)
A couple of these are actually user-facing although undocumented
This commit is contained in:
parent
0579a04014
commit
0780afff95
14 changed files with 52 additions and 56 deletions
2
.env
2
.env
|
@ -1,2 +1,2 @@
|
|||
PATH=$PWD/bin:$PATH
|
||||
PUFFIN_TEST_PYTHON_PATH=$PWD/bin
|
||||
UV_TEST_PYTHON_PATH=$PWD/bin
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct CacheArgs {
|
|||
no_cache: bool,
|
||||
|
||||
/// Path to the cache directory.
|
||||
#[arg(global = true, long, env = "PUFFIN_CACHE_DIR")]
|
||||
#[arg(global = true, long, env = "UV_CACHE_DIR")]
|
||||
cache_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl TryFrom<CacheArgs> for Cache {
|
|||
|
||||
/// Prefer, in order:
|
||||
/// 1. A temporary cache directory, if the user requested `--no-cache`.
|
||||
/// 2. The specific cache directory specified by the user via `--cache-dir` or `PUFFIN_CACHE_DIR`.
|
||||
/// 2. The specific cache directory specified by the user via `--cache-dir` or `UV_CACHE_DIR`.
|
||||
/// 3. The system-appropriate cache directory.
|
||||
/// 4. A `.uv_cache` directory in the current working directory.
|
||||
///
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(crate) struct ResolveCliArgs {
|
|||
cache_args: CacheArgs,
|
||||
#[arg(long)]
|
||||
exclude_newer: Option<DateTime<Utc>>,
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "PUFFIN_INDEX_URL")]
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "UV_INDEX_URL")]
|
||||
index_url: IndexUrl,
|
||||
#[clap(long)]
|
||||
extra_index_url: Vec<IndexUrl>,
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Interpreter {
|
|||
/// - If a python version is given: `pythonx.y`
|
||||
/// - `python3` (unix) or `python.exe` (windows)
|
||||
///
|
||||
/// If `PUFFIN_TEST_PYTHON_PATH` is set, we will not check for Python versions in the
|
||||
/// If `UV_TEST_PYTHON_PATH` is set, we will not check for Python versions in the
|
||||
/// global PATH, instead we will search using the provided path. Virtual environments
|
||||
/// will still be respected.
|
||||
///
|
||||
|
@ -204,13 +204,13 @@ impl Interpreter {
|
|||
Ok(None)
|
||||
}
|
||||
|
||||
/// Find the Python interpreter in `PATH`, respecting `PUFFIN_PYTHON_PATH`.
|
||||
/// Find the Python interpreter in `PATH`, respecting `UV_PYTHON_PATH`.
|
||||
///
|
||||
/// Returns `Ok(None)` if not found.
|
||||
pub fn find_executable<R: AsRef<OsStr> + Into<OsString> + Copy>(
|
||||
requested: R,
|
||||
) -> Result<Option<PathBuf>, Error> {
|
||||
let result = if let Some(isolated) = std::env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
let result = if let Some(isolated) = std::env::var_os("UV_TEST_PYTHON_PATH") {
|
||||
which::which_in(requested, Some(isolated), std::env::current_dir()?)
|
||||
} else {
|
||||
which::which(requested)
|
||||
|
|
|
@ -68,7 +68,7 @@ pub fn find_requested_python(
|
|||
Interpreter::query(&executable, platform, cache)?
|
||||
}
|
||||
} else if cfg!(windows) {
|
||||
if let Some(python_overwrite) = env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
if let Some(python_overwrite) = env::var_os("UV_TEST_PYTHON_PATH") {
|
||||
let executable_dir = env::split_paths(&python_overwrite).find(|path| {
|
||||
path.as_os_str()
|
||||
.to_str()
|
||||
|
@ -140,25 +140,21 @@ pub fn find_requested_python(
|
|||
|
||||
/// Pick a sensible default for the python a user wants when they didn't specify a version.
|
||||
///
|
||||
/// We prefer the test overwrite `PUFFIN_TEST_PYTHON_PATH` if it is set, otherwise `python3`/`python` or
|
||||
/// We prefer the test overwrite `UV_TEST_PYTHON_PATH` if it is set, otherwise `python3`/`python` or
|
||||
/// `python.exe` respectively.
|
||||
#[instrument]
|
||||
pub fn find_default_python(platform: &Platform, cache: &Cache) -> Result<Interpreter, Error> {
|
||||
let current_dir = env::current_dir()?;
|
||||
let python = if cfg!(unix) {
|
||||
which::which_in(
|
||||
"python3",
|
||||
env::var_os("PUFFIN_TEST_PYTHON_PATH"),
|
||||
current_dir,
|
||||
)
|
||||
.or_else(|_| which::which("python"))
|
||||
.map_err(|_| Error::NoPythonInstalledUnix)?
|
||||
which::which_in("python3", env::var_os("UV_TEST_PYTHON_PATH"), current_dir)
|
||||
.or_else(|_| which::which("python"))
|
||||
.map_err(|_| Error::NoPythonInstalledUnix)?
|
||||
} else if cfg!(windows) {
|
||||
// TODO(konstin): Is that the right order, or should we look for `py --list-paths` first? With the current way
|
||||
// it works even if the python launcher is not installed.
|
||||
if let Ok(python) = which::which_in(
|
||||
"python.exe",
|
||||
env::var_os("PUFFIN_TEST_PYTHON_PATH"),
|
||||
env::var_os("UV_TEST_PYTHON_PATH"),
|
||||
current_dir,
|
||||
) {
|
||||
python
|
||||
|
@ -182,7 +178,7 @@ pub fn find_default_python(platform: &Platform, cache: &Cache) -> Result<Interpr
|
|||
/// The command takes 8ms on my machine. TODO(konstin): Implement <https://peps.python.org/pep-0514/> to read python
|
||||
/// installations from the registry instead.
|
||||
fn installed_pythons_windows() -> Result<Vec<(u8, u8, PathBuf)>, Error> {
|
||||
// TODO(konstin): We're not checking PUFFIN_TEST_PYTHON_PATH here, no test currently depends on it.
|
||||
// TODO(konstin): We're not checking UV_TEST_PYTHON_PATH here, no test currently depends on it.
|
||||
|
||||
// TODO(konstin): Special case the not found error
|
||||
let output = info_span!("py_list_paths")
|
||||
|
@ -223,7 +219,7 @@ fn installed_pythons_windows() -> Result<Vec<(u8, u8, PathBuf)>, Error> {
|
|||
}
|
||||
|
||||
pub(crate) fn find_python_windows(major: u8, minor: u8) -> Result<Option<PathBuf>, Error> {
|
||||
if let Some(python_overwrite) = env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
if let Some(python_overwrite) = env::var_os("UV_TEST_PYTHON_PATH") {
|
||||
let executable_dir = env::split_paths(&python_overwrite).find(|path| {
|
||||
path.as_os_str()
|
||||
.to_str()
|
||||
|
|
|
@ -234,7 +234,7 @@ struct PipCompileArgs {
|
|||
refresh_package: Vec<PackageName>,
|
||||
|
||||
/// The URL of the Python Package Index.
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "PUFFIN_INDEX_URL")]
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "UV_INDEX_URL")]
|
||||
index_url: IndexUrl,
|
||||
|
||||
/// Extra URLs of package indexes to use, in addition to `--index-url`.
|
||||
|
@ -358,7 +358,7 @@ struct PipSyncArgs {
|
|||
link_mode: install_wheel_rs::linker::LinkMode,
|
||||
|
||||
/// The URL of the Python Package Index.
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "PUFFIN_INDEX_URL")]
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "UV_INDEX_URL")]
|
||||
index_url: IndexUrl,
|
||||
|
||||
/// Extra URLs of package indexes to use, in addition to `--index-url`.
|
||||
|
@ -515,7 +515,7 @@ struct PipInstallArgs {
|
|||
output_file: Option<PathBuf>,
|
||||
|
||||
/// The URL of the Python Package Index.
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "PUFFIN_INDEX_URL")]
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "UV_INDEX_URL")]
|
||||
index_url: IndexUrl,
|
||||
|
||||
/// Extra URLs of package indexes to use, in addition to `--index-url`.
|
||||
|
@ -644,7 +644,7 @@ struct VenvArgs {
|
|||
name: PathBuf,
|
||||
|
||||
/// The URL of the Python Package Index.
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "PUFFIN_INDEX_URL")]
|
||||
#[clap(long, short, default_value = IndexUrl::Pypi.as_str(), env = "UV_INDEX_URL")]
|
||||
index_url: IndexUrl,
|
||||
|
||||
/// Extra URLs of package indexes to use, in addition to `--index-url`.
|
||||
|
@ -770,7 +770,7 @@ async fn run() -> Result<ExitStatus> {
|
|||
.break_words(false)
|
||||
.word_separator(textwrap::WordSeparator::AsciiSpace)
|
||||
.word_splitter(textwrap::WordSplitter::NoHyphenation)
|
||||
.wrap_lines(env::var("PUFFIN_NO_WRAP").map(|_| false).unwrap_or(true))
|
||||
.wrap_lines(env::var("UV_NO_WRAP").map(|_| false).unwrap_or(true))
|
||||
.build(),
|
||||
)
|
||||
}))?;
|
||||
|
@ -1022,7 +1022,7 @@ async fn run() -> Result<ExitStatus> {
|
|||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let result = if let Ok(stack_size) = env::var("PUFFIN_STACK_SIZE") {
|
||||
let result = if let Ok(stack_size) = env::var("UV_STACK_SIZE") {
|
||||
// Artificially limit the stack size to test for stack overflows. Windows has a default stack size of 1MB,
|
||||
// which is lower than the linux and mac default.
|
||||
// https://learn.microsoft.com/en-us/cpp/build/reference/stack-stack-allocations?view=msvc-170
|
||||
|
|
|
@ -31,8 +31,8 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
|||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&context.temp_dir);
|
||||
command
|
||||
}
|
||||
|
|
|
@ -673,7 +673,7 @@ fn reinstall_no_binary() {
|
|||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
command.env("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
uv_snapshot!(command, @r###"
|
||||
success: true
|
||||
|
@ -703,7 +703,7 @@ fn reinstall_no_binary() {
|
|||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
command.env("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
uv_snapshot!(command, @r###"
|
||||
success: true
|
||||
|
@ -739,7 +739,7 @@ fn reinstall_no_binary() {
|
|||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
command.env("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
uv_snapshot!(filters, command, @r###"
|
||||
success: true
|
||||
|
|
|
@ -50,7 +50,7 @@ fn command(context: &TestContext) -> Command {
|
|||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.current_dir(&context.temp_dir);
|
||||
command
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ fn link() -> Result<()> {
|
|||
.arg(context.cache_dir.path())
|
||||
.arg("--python")
|
||||
.arg("3.12")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&context.temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
|
|
@ -36,7 +36,7 @@ fn create_venv() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin.clone())
|
||||
.env("UV_TEST_PYTHON_PATH", bin.clone())
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -68,8 +68,8 @@ fn create_venv() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -109,8 +109,8 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -152,8 +152,8 @@ fn seed() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -190,8 +190,8 @@ fn create_venv_unknown_python_minor() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir);
|
||||
if cfg!(windows) {
|
||||
uv_snapshot!(&mut command, @r###"
|
||||
|
@ -245,8 +245,8 @@ fn create_venv_unknown_python_patch() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: false
|
||||
exit_code: 1
|
||||
|
@ -286,8 +286,8 @@ fn create_venv_python_patch() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -331,8 +331,8 @@ fn file_exists() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: false
|
||||
exit_code: 1
|
||||
|
@ -378,8 +378,8 @@ fn empty_dir_exists() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -424,8 +424,8 @@ fn non_empty_dir_exists() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: false
|
||||
exit_code: 1
|
||||
|
@ -470,7 +470,7 @@ fn virtualenv_compatibility() -> Result<()> {
|
|||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin.clone())
|
||||
.env("UV_TEST_PYTHON_PATH", bin.clone())
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
|
@ -31,8 +31,8 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
|||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.env("UV_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&context.temp_dir);
|
||||
command
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ fn command(context: &TestContext) -> Command {
|
|||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("UV_NO_WRAP", "1")
|
||||
.current_dir(&context.temp_dir);
|
||||
command
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ Usage:
|
|||
|
||||
Override the default PyPI index for uv and update the scenarios
|
||||
|
||||
$ PUFFIN_INDEX_URL="http://localhost:3141/packages/all/+simple" ./scripts/scenarios/update.py
|
||||
$ UV_INDEX_URL="http://localhost:3141/packages/all/+simple" ./scripts/scenarios/update.py
|
||||
|
||||
Requirements:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue