Files
uv/scripts/scenarios/templates/install.mustache
T
konsti 2e0ce70d13 Initial windows support (#940)
## Summary

First batch of changes for windows support. Notable changes:

* Fixes all compile errors and added windows specific paths.
* Working venv creation on windows, both from a base interpreter and
from a venv. This requires querying `stdlib` from the sysconfig paths to
find the launcher.
* Basic url/path conversion handling for windows.
* `if cfg!(...)` instead of `#[cfg()]`. This should make it easier to
keep everything compiling across platforms.

## Outlook

Test summary: 402 tests run: 299 passed (15 slow), 103 failed, 1 skipped

There are various reason for the remaining test failure:
* Windows-specific colorama and tzdata dependencies that change the
snapshot slightly. This is by far the biggest batch.
* Some url-path handling issues. I fixed some in the PR, some remain.
* Lack of the latest python patch versions for older pythons on my
machine, since there are no builds for windows and we need to register
them in the registry for them to be picked up for `py --list-paths` (CC
@zanieb RE #1070).
* Lack of entrypoint launchers.
* ... likely more
2024-01-24 18:27:49 +01:00

113 lines
2.9 KiB
Plaintext

//! DO NOT EDIT
//!
//! Generated with {{generated_with}}
//! Scenarios from <{{generated_from}}>
//!
#![cfg(all(feature = "python", feature = "pypi"))]
use std::path::Path;
use std::process::Command;
use anyhow::Result;
use assert_cmd::assert::Assert;
use assert_cmd::prelude::*;
use insta_cmd::_macro_support::insta;
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
use common::{create_venv, BIN_NAME, INSTA_FILTERS, venv_to_interpreter};
mod common;
fn assert_command(venv: &Path, command: &str, temp_dir: &Path) -> Assert {
Command::new(venv_to_interpreter(venv))
.arg("-c")
.arg(command)
.current_dir(temp_dir)
.assert()
}
fn assert_installed(venv: &Path, package: &'static str, version: &'static str, temp_dir: &Path) {
assert_command(
venv,
format!("import {package} as package; print(package.__version__, end='')").as_str(),
temp_dir,
)
.success()
.stdout(version);
}
fn assert_not_installed(venv: &Path, package: &'static str, temp_dir: &Path) {
assert_command(venv, format!("import {package}").as_str(), temp_dir).failure();
}
{{#scenarios}}
/// {{name}}
///
{{#description_lines}}
/// {{.}}
{{/description_lines}}
///
/// ```text
/// {{version}}
{{#tree}}
/// {{.}}
{{/tree}}
/// ```
#[test]
fn {{module_name}}() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
let cache_dir = assert_fs::TempDir::new()?;
let venv = create_venv(&temp_dir, &cache_dir, "{{environment.python}}");
// In addition to the standard filters, swap out package names for more realistic messages
let mut filters = INSTA_FILTERS.to_vec();
{{#packages}}
filters.push((r"{{name}}", "{{cute_name}}"));
{{/packages}}
filters.push((r"-{{version}}", ""));
insta::with_settings!({
filters => filters
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip")
.arg("install")
{{#root.requires}}
.arg("{{requirement}}")
{{/root.requires}}
{{#environment.prereleases}}
.arg("--prerelease=allow")
{{/environment.prereleases}}
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
.arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###"<snapshot>
"###);
});
{{#expected.explanation_lines}}
// {{.}}
{{/expected.explanation_lines}}
{{#expected.satisfiable}}
{{#expected.packages}}
assert_installed(
&venv,
"{{module_name}}",
"{{version}}",
&temp_dir
);
{{/expected.packages}}
{{/expected.satisfiable}}
{{^expected.satisfiable}}
{{#root.requires}}
assert_not_installed(&venv, "{{module_name}}", &temp_dir);
{{/root.requires}}
{{/expected.satisfiable}}
Ok(())
}
{{/scenarios}}