From 908c85700e5287a4a30186657e875ed44bce9f22 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 15 Nov 2023 09:30:30 +0100 Subject: [PATCH 1/2] Simpler and more resilient pip compile tests --- crates/puffin-cli/src/commands/venv.rs | 12 +- crates/puffin-cli/tests/pip_compile.rs | 691 ++++++------------------- crates/puffin-resolver/src/resolver.rs | 2 +- 3 files changed, 161 insertions(+), 544 deletions(-) diff --git a/crates/puffin-cli/src/commands/venv.rs b/crates/puffin-cli/src/commands/venv.rs index 080db903390b..027372ca4412 100644 --- a/crates/puffin-cli/src/commands/venv.rs +++ b/crates/puffin-cli/src/commands/venv.rs @@ -1,5 +1,5 @@ use std::fmt::Write; -use std::path::Path; +use std::path::{Path, PathBuf}; use anyhow::Result; use colored::Colorize; @@ -37,6 +37,10 @@ enum VenvError { #[diagnostic(code(puffin::venv::python_not_found))] PythonNotFound, + #[error("Unable to find a Python interpreter {0}")] + #[diagnostic(code(puffin::venv::python_not_found))] + UserPythonNotFound(PathBuf), + #[error("Failed to extract Python interpreter info")] #[diagnostic(code(puffin::venv::interpreter))] InterpreterError(#[source] anyhow::Error), @@ -54,7 +58,11 @@ fn venv_impl( ) -> miette::Result { // Locate the Python interpreter. let base_python = if let Some(base_python) = base_python { - fs::canonicalize(base_python).into_diagnostic()? + fs::canonicalize( + which::which_global(base_python) + .map_err(|_| VenvError::UserPythonNotFound(base_python.to_path_buf()))?, + ) + .into_diagnostic()? } else { fs::canonicalize( which::which_global("python3") diff --git a/crates/puffin-cli/tests/pip_compile.rs b/crates/puffin-cli/tests/pip_compile.rs index 77ddf57c9c98..51a728aa9616 100644 --- a/crates/puffin-cli/tests/pip_compile.rs +++ b/crates/puffin-cli/tests/pip_compile.rs @@ -1,10 +1,12 @@ #![cfg(all(feature = "python", feature = "pypi"))] +use std::path::PathBuf; use std::process::Command; use anyhow::Result; use assert_cmd::prelude::*; use assert_fs::prelude::*; +use assert_fs::TempDir; use insta_cmd::_macro_support::insta; use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; @@ -12,10 +14,27 @@ use common::{BIN_NAME, INSTA_FILTERS}; mod common; +fn make_venv_py312(temp_dir: &TempDir, cache_dir: &TempDir) -> Result { + let venv = temp_dir.child(".venv"); + + Command::new(get_cargo_bin(BIN_NAME)) + .arg("venv") + .arg(venv.as_os_str()) + .arg("--cache-dir") + .arg(cache_dir.path()) + .arg("--python") + .arg("python3.12") + .current_dir(&temp_dir) + .assert() + .success(); + venv.assert(predicates::path::is_dir()); + Ok(venv.to_path_buf()) +} + #[test] fn missing_requirements_in() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; let requirements_in = temp_dir.child("requirements.in"); assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) @@ -32,8 +51,8 @@ fn missing_requirements_in() -> Result<()> { #[test] fn missing_venv() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; let venv = temp_dir.child(".venv"); assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) @@ -52,22 +71,11 @@ fn missing_venv() -> Result<()> { /// Resolve a specific version of Django from a `requirements.in` file. #[test] fn compile_requirements_in() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("django==5.0b1")?; insta::with_settings!({ @@ -88,22 +96,11 @@ fn compile_requirements_in() -> Result<()> { /// Resolve a specific version of Django from a `pyproject.toml` file. #[test] fn compile_pyproject_toml() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -134,26 +131,14 @@ dependencies = [ /// Resolve a package from a `requirements.in` file, with a `constraints.txt` file. #[test] fn compile_constraints_txt() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("django==5.0b1")?; let constraints_txt = temp_dir.child("constraints.txt"); - constraints_txt.touch()?; constraints_txt.write_str("sqlparse<0.4.4")?; insta::with_settings!({ @@ -176,27 +161,15 @@ fn compile_constraints_txt() -> Result<()> { /// Resolve a package from a `requirements.in` file, with an inline constraint. #[test] fn compile_constraints_inline() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("django==5.0b1")?; requirements_in.write_str("-c constraints.txt")?; let constraints_txt = temp_dir.child("constraints.txt"); - constraints_txt.touch()?; constraints_txt.write_str("sqlparse<0.4.4")?; insta::with_settings!({ @@ -218,27 +191,15 @@ fn compile_constraints_inline() -> Result<()> { /// uses markers. #[test] fn compile_constraints_markers() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("anyio")?; // Constrain a transitive dependency based on the Python version let constraints_txt = temp_dir.child("constraints.txt"); - constraints_txt.touch()?; // If constraints are ignored, these will conflict constraints_txt.write_str("sniffio==1.2.0;python_version<='3.7'")?; constraints_txt.write_str("sniffio==1.3.0;python_version>'3.7'")?; @@ -263,22 +224,11 @@ fn compile_constraints_markers() -> Result<()> { /// Resolve a package from an optional dependency group in a `pyproject.toml` file. #[test] fn compile_pyproject_toml_extra() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -312,22 +262,11 @@ optional-dependencies.foo = [ /// Resolve a package from an extra with unnormalized names in a `pyproject.toml` file. #[test] fn compile_pyproject_toml_extra_name_normalization() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -361,22 +300,11 @@ optional-dependencies."FrIeNdLy-._.-bArD" = [ /// Request an extra that does not exist as a dependency group in a `pyproject.toml` file. #[test] fn compile_pyproject_toml_extra_missing() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -410,22 +338,11 @@ optional-dependencies.foo = [ /// Request multiple extras that do not exist as a dependency group in a `pyproject.toml` file. #[test] fn compile_pyproject_toml_extras_missing() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -463,22 +380,11 @@ optional-dependencies.foo = [ /// Request extras when using a `requirements.in` file which does not support extras. #[test] fn compile_requirements_file_extra() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("django==5.0b1")?; insta::with_settings!({ @@ -508,22 +414,11 @@ fn compile_requirements_file_extra() -> Result<()> { /// Request an extra with a name that does not conform to the specification. #[test] fn invalid_extra_name() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -557,22 +452,11 @@ optional-dependencies.foo = [ /// Resolve a specific version of Black at Python 3.12. #[test] fn compile_python_312() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("black==23.10.1")?; insta::with_settings!({ @@ -595,22 +479,11 @@ fn compile_python_312() -> Result<()> { /// Resolve a specific version of Black at Python 3.7. #[test] fn compile_python_37() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("black==23.10.1")?; insta::with_settings!({ @@ -634,8 +507,8 @@ fn compile_python_37() -> Result<()> { /// incompatible sdist #[test] fn compile_numpy_py38() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; let venv = temp_dir.child(".venv"); Command::new(get_cargo_bin(BIN_NAME)) @@ -643,13 +516,15 @@ fn compile_numpy_py38() -> Result<()> { .arg(venv.as_os_str()) .arg("--cache-dir") .arg(cache_dir.path()) - .current_dir(&temp_dir) + .arg("--python") + .arg("python3.8") + .current_dir(&&temp_dir) .assert() .success(); venv.assert(predicates::path::is_dir()); + let venv = venv.to_path_buf(); let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("numpy")?; insta::with_settings!({ @@ -658,22 +533,22 @@ fn compile_numpy_py38() -> Result<()> { assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) .arg("pip-compile") .arg("requirements.in") - .arg("--python-version") - .arg("py38") .arg("--cache-dir") .arg(cache_dir.path()) // Check that we select the wheel and not the sdist .arg("--no-build") .env("VIRTUAL_ENV", venv.as_os_str()) .current_dir(&temp_dir), @r###" - success: false - exit_code: 2 - ----- stdout ----- - - ----- stderr ----- - error: Failed to build distribution: numpy-1.24.4.tar.gz - Caused by: Building source distributions is disabled - "###); + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by Puffin v0.0.1 via the following command: + # [BIN_PATH] pip-compile requirements.in --cache-dir [CACHE_DIR] + numpy==1.24.4 + + ----- stderr ----- + Resolved 1 package in [TIME] + "###); }); Ok(()) @@ -682,22 +557,11 @@ fn compile_numpy_py38() -> Result<()> { /// Resolve a specific Flask wheel via a URL dependency. #[test] fn compile_wheel_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ https://files.pythonhosted.org/packages/36/42/015c23096649b908c809c69388a805a571a3bea44362fe87e33fc3afa01f/flask-3.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -718,22 +582,11 @@ fn compile_wheel_url_dependency() -> Result<()> { /// Resolve a specific Flask source distribution via a URL dependency. #[test] fn compile_sdist_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ https://files.pythonhosted.org/packages/d8/09/c1a7354d3925a3c6c8cfdebf4245bae67d633ffda1ba415add06ffc839c5/flask-3.0.0.tar.gz")?; insta::with_settings!({ @@ -755,22 +608,11 @@ fn compile_sdist_url_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git")?; // In addition to the standard filters, remove the `main` commit, which will change frequently. @@ -796,22 +638,11 @@ fn compile_git_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_branch_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@1.0.x")?; insta::with_settings!({ @@ -833,22 +664,11 @@ fn compile_git_branch_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_tag_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@3.0.0")?; insta::with_settings!({ @@ -870,22 +690,11 @@ fn compile_git_tag_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_long_commit_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str( "flask @ git+https://github.com/pallets/flask.git@d92b64aa275841b0c9aea3903aba72fbc4275d91", )?; @@ -909,22 +718,11 @@ fn compile_git_long_commit_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_short_commit_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@d92b64a")?; insta::with_settings!({ @@ -946,22 +744,11 @@ fn compile_git_short_commit_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_refs_https_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in .write_str("flask @ git+https://github.com/pallets/flask.git@refs/pull/5313/head")?; @@ -984,22 +771,11 @@ fn compile_git_refs_https_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_subdirectory_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("example-pkg-a @ git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_a")?; insta::with_settings!({ @@ -1021,22 +797,11 @@ fn compile_git_subdirectory_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_concurrent_access() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in .write_str("example-pkg-a @ git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_a\nexample-pkg-b @ git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_b")?; @@ -1059,22 +824,11 @@ fn compile_git_concurrent_access() -> Result<()> { #[test] #[cfg(feature = "git")] fn compile_git_mismatched_name() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in .write_str("flask @ git+https://github.com/pallets/flask.git@2.0.0\ndask @ git+https://github.com/pallets/flask.git@3.0.0")?; @@ -1097,22 +851,11 @@ fn compile_git_mismatched_name() -> Result<()> { /// duplicate dependency from `PyPI`. #[test] fn mixed_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/c3/fc/254c3e9b5feb89ff5b9076a23218dafbc99c96ac5941e900b71206e6313b/werkzeug-3.0.1-py3-none-any.whl")?; insta::with_settings!({ @@ -1134,22 +877,11 @@ fn mixed_url_dependency() -> Result<()> { /// should result in a conflict. #[test] fn conflicting_direct_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("werkzeug==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -1171,22 +903,11 @@ fn conflicting_direct_url_dependency() -> Result<()> { /// should prefer the direct URL dependency. #[test] fn compatible_direct_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("werkzeug==2.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -1207,22 +928,11 @@ fn compatible_direct_url_dependency() -> Result<()> { /// Request Werkzeug via two different URLs at different versions, which should result in a conflict. #[test] fn conflicting_repeated_url_dependency_version_mismatch() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("werkzeug @ https://files.pythonhosted.org/packages/bd/24/11c3ea5a7e866bf2d97f0501d0b4b1c9bbeade102bb4b588f0d2919a5212/Werkzeug-2.0.1-py3-none-any.whl\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -1245,22 +955,11 @@ fn conflicting_repeated_url_dependency_version_mismatch() -> Result<()> { #[test] #[cfg(feature = "git")] fn conflicting_repeated_url_dependency_version_match() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("werkzeug @ git+https://github.com/pallets/werkzeug.git@2.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -1281,22 +980,11 @@ fn conflicting_repeated_url_dependency_version_match() -> Result<()> { /// Request Flask, but include a URL dependency for a conflicting version of Werkzeug. #[test] fn conflicting_transitive_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("flask==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; insta::with_settings!({ @@ -1319,22 +1007,11 @@ fn conflicting_transitive_url_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn disallowed_transitive_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; insta::with_settings!({ @@ -1357,26 +1034,14 @@ fn disallowed_transitive_url_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn allowed_transitive_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; let constraints_txt = temp_dir.child("constraints.txt"); - constraints_txt.touch()?; constraints_txt.write_str("werkzeug @ git+https://github.com/pallets/werkzeug@2.0.0")?; insta::with_settings!({ @@ -1402,26 +1067,14 @@ fn allowed_transitive_url_dependency() -> Result<()> { #[test] #[cfg(feature = "git")] fn allowed_transitive_canonical_url_dependency() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let requirements_in = temp_dir.child("requirements.in"); - requirements_in.touch()?; requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; let constraints_txt = temp_dir.child("constraints.txt"); - constraints_txt.touch()?; constraints_txt.write_str("werkzeug @ git+https://github.com/pallets/werkzeug.git@2.0.0")?; insta::with_settings!({ @@ -1444,22 +1097,11 @@ fn allowed_transitive_canonical_url_dependency() -> Result<()> { /// Resolve packages from all optional dependency groups in a `pyproject.toml` file. #[test] fn compile_pyproject_toml_all_extras() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -1495,22 +1137,11 @@ optional-dependencies.bar = [ /// Resolve packages from all optional dependency groups in a `pyproject.toml` file. #[test] fn compile_does_not_allow_both_extra_and_all_extras() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -1560,22 +1191,11 @@ optional-dependencies.bar = [ /// Compile requirements that cannot be solved due to conflict in a `pyproject.toml` fil;e. #[test] fn compile_unsolvable_requirements() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] @@ -1609,22 +1229,11 @@ dependencies = ["django==5.0b1", "django==5.0a1"] /// a requirement with a version that is not available online. #[test] fn compile_unsolvable_requirements_version_not_available() -> Result<()> { - let temp_dir = assert_fs::TempDir::new()?; - let cache_dir = assert_fs::TempDir::new()?; - let venv = temp_dir.child(".venv"); - - Command::new(get_cargo_bin(BIN_NAME)) - .arg("venv") - .arg(venv.as_os_str()) - .arg("--cache-dir") - .arg(cache_dir.path()) - .current_dir(&temp_dir) - .assert() - .success(); - venv.assert(predicates::path::is_dir()); + let temp_dir = TempDir::new()?; + let cache_dir = TempDir::new()?; + let venv = make_venv_py312(&temp_dir, &cache_dir)?; let pyproject_toml = temp_dir.child("pyproject.toml"); - pyproject_toml.touch()?; pyproject_toml.write_str( r#"[build-system] requires = ["setuptools", "wheel"] diff --git a/crates/puffin-resolver/src/resolver.rs b/crates/puffin-resolver/src/resolver.rs index 544777bc8c92..b1467cda5a6d 100644 --- a/crates/puffin-resolver/src/resolver.rs +++ b/crates/puffin-resolver/src/resolver.rs @@ -535,7 +535,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> { // Group the distributions by version and kind, discarding any incompatible // distributions. - let mut version_map: VersionMap = BTreeMap::new(); + let mut version_map = VersionMap::new(); for file in metadata.files { // Only add dists compatible with the python version. // This is relevant for source dists which give no other indication of their From 052515991e763a27656e1067afd6e4fdfed12b20 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 15 Nov 2023 09:41:45 +0100 Subject: [PATCH 2/2] clippy --- crates/puffin-cli/tests/pip_compile.rs | 82 +++++++++++++------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/crates/puffin-cli/tests/pip_compile.rs b/crates/puffin-cli/tests/pip_compile.rs index 51a728aa9616..6e756c8cd1ec 100644 --- a/crates/puffin-cli/tests/pip_compile.rs +++ b/crates/puffin-cli/tests/pip_compile.rs @@ -14,7 +14,7 @@ use common::{BIN_NAME, INSTA_FILTERS}; mod common; -fn make_venv_py312(temp_dir: &TempDir, cache_dir: &TempDir) -> Result { +fn make_venv_py312(temp_dir: &TempDir, cache_dir: &TempDir) -> PathBuf { let venv = temp_dir.child(".venv"); Command::new(get_cargo_bin(BIN_NAME)) @@ -24,11 +24,11 @@ fn make_venv_py312(temp_dir: &TempDir, cache_dir: &TempDir) -> Result { .arg(cache_dir.path()) .arg("--python") .arg("python3.12") - .current_dir(&temp_dir) + .current_dir(temp_dir) .assert() .success(); venv.assert(predicates::path::is_dir()); - Ok(venv.to_path_buf()) + venv.to_path_buf() } #[test] @@ -73,7 +73,7 @@ fn missing_venv() -> Result<()> { fn compile_requirements_in() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("django==5.0b1")?; @@ -98,7 +98,7 @@ fn compile_requirements_in() -> Result<()> { fn compile_pyproject_toml() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -133,7 +133,7 @@ dependencies = [ fn compile_constraints_txt() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("django==5.0b1")?; @@ -163,7 +163,7 @@ fn compile_constraints_txt() -> Result<()> { fn compile_constraints_inline() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("django==5.0b1")?; @@ -193,7 +193,7 @@ fn compile_constraints_inline() -> Result<()> { fn compile_constraints_markers() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("anyio")?; @@ -226,7 +226,7 @@ fn compile_constraints_markers() -> Result<()> { fn compile_pyproject_toml_extra() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -264,7 +264,7 @@ optional-dependencies.foo = [ fn compile_pyproject_toml_extra_name_normalization() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -302,7 +302,7 @@ optional-dependencies."FrIeNdLy-._.-bArD" = [ fn compile_pyproject_toml_extra_missing() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -340,7 +340,7 @@ optional-dependencies.foo = [ fn compile_pyproject_toml_extras_missing() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -382,7 +382,7 @@ optional-dependencies.foo = [ fn compile_requirements_file_extra() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("django==5.0b1")?; @@ -416,7 +416,7 @@ fn compile_requirements_file_extra() -> Result<()> { fn invalid_extra_name() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -454,7 +454,7 @@ optional-dependencies.foo = [ fn compile_python_312() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("black==23.10.1")?; @@ -481,7 +481,7 @@ fn compile_python_312() -> Result<()> { fn compile_python_37() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("black==23.10.1")?; @@ -518,7 +518,7 @@ fn compile_numpy_py38() -> Result<()> { .arg(cache_dir.path()) .arg("--python") .arg("python3.8") - .current_dir(&&temp_dir) + .current_dir(&temp_dir) .assert() .success(); venv.assert(predicates::path::is_dir()); @@ -559,7 +559,7 @@ fn compile_numpy_py38() -> Result<()> { fn compile_wheel_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ https://files.pythonhosted.org/packages/36/42/015c23096649b908c809c69388a805a571a3bea44362fe87e33fc3afa01f/flask-3.0.0-py3-none-any.whl")?; @@ -584,7 +584,7 @@ fn compile_wheel_url_dependency() -> Result<()> { fn compile_sdist_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ https://files.pythonhosted.org/packages/d8/09/c1a7354d3925a3c6c8cfdebf4245bae67d633ffda1ba415add06ffc839c5/flask-3.0.0.tar.gz")?; @@ -610,7 +610,7 @@ fn compile_sdist_url_dependency() -> Result<()> { fn compile_git_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git")?; @@ -640,7 +640,7 @@ fn compile_git_https_dependency() -> Result<()> { fn compile_git_branch_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@1.0.x")?; @@ -666,7 +666,7 @@ fn compile_git_branch_https_dependency() -> Result<()> { fn compile_git_tag_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@3.0.0")?; @@ -692,7 +692,7 @@ fn compile_git_tag_https_dependency() -> Result<()> { fn compile_git_long_commit_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str( @@ -720,7 +720,7 @@ fn compile_git_long_commit_https_dependency() -> Result<()> { fn compile_git_short_commit_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask @ git+https://github.com/pallets/flask.git@d92b64a")?; @@ -746,7 +746,7 @@ fn compile_git_short_commit_https_dependency() -> Result<()> { fn compile_git_refs_https_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in @@ -773,7 +773,7 @@ fn compile_git_refs_https_dependency() -> Result<()> { fn compile_git_subdirectory_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("example-pkg-a @ git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_a")?; @@ -799,7 +799,7 @@ fn compile_git_subdirectory_dependency() -> Result<()> { fn compile_git_concurrent_access() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in @@ -826,7 +826,7 @@ fn compile_git_concurrent_access() -> Result<()> { fn compile_git_mismatched_name() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in @@ -853,7 +853,7 @@ fn compile_git_mismatched_name() -> Result<()> { fn mixed_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/c3/fc/254c3e9b5feb89ff5b9076a23218dafbc99c96ac5941e900b71206e6313b/werkzeug-3.0.1-py3-none-any.whl")?; @@ -879,7 +879,7 @@ fn mixed_url_dependency() -> Result<()> { fn conflicting_direct_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("werkzeug==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; @@ -905,7 +905,7 @@ fn conflicting_direct_url_dependency() -> Result<()> { fn compatible_direct_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("werkzeug==2.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; @@ -930,7 +930,7 @@ fn compatible_direct_url_dependency() -> Result<()> { fn conflicting_repeated_url_dependency_version_mismatch() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("werkzeug @ https://files.pythonhosted.org/packages/bd/24/11c3ea5a7e866bf2d97f0501d0b4b1c9bbeade102bb4b588f0d2919a5212/Werkzeug-2.0.1-py3-none-any.whl\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; @@ -957,7 +957,7 @@ fn conflicting_repeated_url_dependency_version_mismatch() -> Result<()> { fn conflicting_repeated_url_dependency_version_match() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("werkzeug @ git+https://github.com/pallets/werkzeug.git@2.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; @@ -982,7 +982,7 @@ fn conflicting_repeated_url_dependency_version_match() -> Result<()> { fn conflicting_transitive_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("flask==3.0.0\nwerkzeug @ https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl")?; @@ -1009,7 +1009,7 @@ fn conflicting_transitive_url_dependency() -> Result<()> { fn disallowed_transitive_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; @@ -1036,7 +1036,7 @@ fn disallowed_transitive_url_dependency() -> Result<()> { fn allowed_transitive_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; @@ -1069,7 +1069,7 @@ fn allowed_transitive_url_dependency() -> Result<()> { fn allowed_transitive_canonical_url_dependency() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let requirements_in = temp_dir.child("requirements.in"); requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/13257454/transitive_url_dependency.zip")?; @@ -1099,7 +1099,7 @@ fn allowed_transitive_canonical_url_dependency() -> Result<()> { fn compile_pyproject_toml_all_extras() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -1139,7 +1139,7 @@ optional-dependencies.bar = [ fn compile_does_not_allow_both_extra_and_all_extras() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -1193,7 +1193,7 @@ optional-dependencies.bar = [ fn compile_unsolvable_requirements() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str( @@ -1231,7 +1231,7 @@ dependencies = ["django==5.0b1", "django==5.0a1"] fn compile_unsolvable_requirements_version_not_available() -> Result<()> { let temp_dir = TempDir::new()?; let cache_dir = TempDir::new()?; - let venv = make_venv_py312(&temp_dir, &cache_dir)?; + let venv = make_venv_py312(&temp_dir, &cache_dir); let pyproject_toml = temp_dir.child("pyproject.toml"); pyproject_toml.write_str(