diff --git a/crates/uv/tests/it/python_module.rs b/crates/uv/tests/it/python_module.rs index c026fd404..a76fd81cd 100644 --- a/crates/uv/tests/it/python_module.rs +++ b/crates/uv/tests/it/python_module.rs @@ -382,3 +382,295 @@ fn find_uv_bin_user_bin() { " ); } + +#[test] +fn find_uv_bin_py38() { + let context = TestContext::new("3.8") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r#" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + Traceback (most recent call last): + File "", line 1, in + File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin + _matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin" + File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents + for part, match_part in zip( + TypeError: zip() takes no keyword arguments + "# + ); +} + +#[test] +fn find_uv_bin_py39() { + let context = TestContext::new("3.9") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r#" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + Traceback (most recent call last): + File "", line 1, in + File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin + _matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin" + File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents + for part, match_part in zip( + TypeError: zip() takes no keyword arguments + "# + ); +} + +#[test] +fn find_uv_bin_py310() { + let context = TestContext::new("3.10") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r" + success: true + exit_code: 0 + ----- stdout ----- + [VENV]/[BIN]/uv + + ----- stderr ----- + " + ); +} + +#[test] +fn find_uv_bin_py311() { + let context = TestContext::new("3.11") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r" + success: true + exit_code: 0 + ----- stdout ----- + [VENV]/[BIN]/uv + + ----- stderr ----- + " + ); +} + +#[test] +fn find_uv_bin_py312() { + let context = TestContext::new("3.12") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r" + success: true + exit_code: 0 + ----- stdout ----- + [VENV]/[BIN]/uv + + ----- stderr ----- + " + ); +} + +#[test] +fn find_uv_bin_py313() { + let context = TestContext::new("3.13") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r" + success: true + exit_code: 0 + ----- stdout ----- + [VENV]/[BIN]/uv + + ----- stderr ----- + " + ); +} + +#[test] +fn find_uv_bin_py314() { + let context = TestContext::new("3.14") + .with_filtered_python_names() + .with_filtered_virtualenv_bin() + .with_filtered_exe_suffix() + .with_filter(user_scheme_bin_filter()) + // Target installs always use "bin" on all platforms. On Windows, + // `with_filtered_virtualenv_bin` only filters "Scripts", not "bin" + .with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string())); + + // Install in a virtual environment + uv_snapshot!(context.filters(), context.pip_install() + .arg(context.workspace_root.join("scripts/packages/fake-uv")), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 1 package in [TIME] + Prepared 1 package in [TIME] + Installed 1 package in [TIME] + + uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv) + " + ); + + // We should find the binary in the virtual environment + uv_snapshot!(context.filters(), context.python_command() + .arg("-c") + .arg("import uv; print(uv.find_uv_bin())"), @r" + success: true + exit_code: 0 + ----- stdout ----- + [VENV]/[BIN]/uv + + ----- stderr ----- + " + ); +}