mirror of https://github.com/astral-sh/uv
Bump to latest packse version with "extras" scenarios (#935)
Includes: - https://github.com/zanieb/packse/pull/83 (replaces some of the post-processing here) - https://github.com/zanieb/packse/pull/82 - https://github.com/zanieb/packse/pull/81
This commit is contained in:
parent
4feef006e9
commit
a4204d00c1
File diff suppressed because it is too large
Load Diff
|
|
@ -55,19 +55,21 @@ fn assert_not_installed(venv: &Path, package: &'static str, temp_dir: &Path) {
|
|||
/// {{.}}
|
||||
{{/description_lines}}
|
||||
///
|
||||
/// {{prefix}}
|
||||
/// ```text
|
||||
/// {{version}}
|
||||
{{#tree}}
|
||||
/// {{.}}
|
||||
{{/tree}}
|
||||
/// ```
|
||||
#[test]
|
||||
fn {{normalized_name}}() -> Result<()> {
|
||||
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, "python{{environment.python}}");
|
||||
|
||||
// In addition to the standard filters, remove the scenario prefix
|
||||
// In addition to the standard filters, remove the scenario version
|
||||
let mut filters = INSTA_FILTERS.to_vec();
|
||||
filters.push((r"{{prefix}}-", ""));
|
||||
filters.push((r"-{{version}}", ""));
|
||||
|
||||
insta::with_settings!({
|
||||
filters => filters
|
||||
|
|
@ -76,7 +78,7 @@ fn {{normalized_name}}() -> Result<()> {
|
|||
.arg("pip")
|
||||
.arg("install")
|
||||
{{#root.requires}}
|
||||
.arg("{{prefix}}-{{.}}")
|
||||
.arg("{{requirement}}")
|
||||
{{/root.requires}}
|
||||
{{#environment.prereleases}}
|
||||
.arg("--prerelease=allow")
|
||||
|
|
@ -95,19 +97,19 @@ fn {{normalized_name}}() -> Result<()> {
|
|||
// {{.}}
|
||||
{{/expected.explanation_lines}}
|
||||
{{#expected.satisfiable}}
|
||||
{{#expected.packages_list}}
|
||||
{{#expected.packages}}
|
||||
assert_installed(
|
||||
&venv,
|
||||
"{{prefix_module}}_{{package_module}}",
|
||||
"{{module_name}}",
|
||||
"{{version}}",
|
||||
&temp_dir
|
||||
);
|
||||
{{/expected.packages_list}}
|
||||
{{/expected.packages}}
|
||||
{{/expected.satisfiable}}
|
||||
{{^expected.satisfiable}}
|
||||
{{#root.requires_packages}}
|
||||
assert_not_installed(&venv, "{{prefix_module}}_{{package_module}}", &temp_dir);
|
||||
{{/root.requires_packages}}
|
||||
{{#root.requires}}
|
||||
assert_not_installed(&venv, "{{module_name}}", &temp_dir);
|
||||
{{/root.requires}}
|
||||
{{/expected.satisfiable}}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -42,11 +42,10 @@ import shutil
|
|||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import packaging.requirements
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PACKSE_COMMIT = "a9d2f659117693b89cba8a487200fd01444468af"
|
||||
PACKSE_COMMIT = "b6cb1f6310a40937dc68a59c82460fea58957b70"
|
||||
TOOL_ROOT = Path(__file__).parent
|
||||
TEMPLATE = TOOL_ROOT / "template.mustache"
|
||||
PACKSE = TOOL_ROOT / "packse-scenarios"
|
||||
|
|
@ -147,10 +146,6 @@ data["generated_from"] = f"https://github.com/zanieb/packse/tree/{commit}/scenar
|
|||
data["generated_with"] = " ".join(sys.argv)
|
||||
|
||||
|
||||
# Add normalized names for tests
|
||||
for scenario in data["scenarios"]:
|
||||
scenario["normalized_name"] = scenario["name"].replace("-", "_")
|
||||
|
||||
# Drop the example scenario
|
||||
for index, scenario in enumerate(data["scenarios"]):
|
||||
if scenario["name"] == "example":
|
||||
|
|
@ -170,39 +165,12 @@ for scenario in data["scenarios"]:
|
|||
else []
|
||||
)
|
||||
|
||||
# Convert the expected packages into a list for rendering
|
||||
for scenario in data["scenarios"]:
|
||||
expected = scenario["expected"]
|
||||
expected["packages_list"] = []
|
||||
for key, value in expected["packages"].items():
|
||||
expected["packages_list"].append(
|
||||
{
|
||||
"package": key,
|
||||
"version": value,
|
||||
# Include a converted version of the package name to its Python module
|
||||
"package_module": key.replace("-", "_"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Convert the required packages into a list without versions
|
||||
for scenario in data["scenarios"]:
|
||||
requires_packages = scenario["root"]["requires_packages"] = []
|
||||
for requirement in scenario["root"]["requires"]:
|
||||
package = packaging.requirements.Requirement(requirement).name
|
||||
requires_packages.append(
|
||||
{"package": package, "package_module": package.replace("-", "_")}
|
||||
)
|
||||
|
||||
|
||||
# Include the Python module name of the prefix
|
||||
for scenario in data["scenarios"]:
|
||||
scenario["prefix_module"] = scenario["prefix"].replace("-", "_")
|
||||
|
||||
|
||||
# Render the template
|
||||
print("Rendering template...", file=sys.stderr)
|
||||
output = chevron_blue.render(template=TEMPLATE.read_text(), data=data, no_escape=True)
|
||||
output = chevron_blue.render(
|
||||
template=TEMPLATE.read_text(), data=data, no_escape=True, warn=True
|
||||
)
|
||||
|
||||
# Update the test file
|
||||
print(f"Updating test file at `{TARGET.relative_to(PROJECT_ROOT)}`...", file=sys.stderr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue