Only textwrap json packse scenarios with packse 0.3.32 (#5810)

Companion change to https://github.com/astral-sh/packse/pull/205 to
correctly format lock scenario doc comments.

Updates packse to 0.3.32.
This commit is contained in:
konsti 2024-08-08 15:49:50 +02:00 committed by GitHub
parent 03797b0724
commit ae6b59365f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 1104 additions and 189 deletions

View File

@ -26,7 +26,7 @@ use uv_python::{
// Exclude any packages uploaded after this date. // Exclude any packages uploaded after this date.
static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z"; static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
pub const PACKSE_VERSION: &str = "0.3.31"; pub const PACKSE_VERSION: &str = "0.3.32";
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests /// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
/// to prevent dependency confusion attacks against our test suite. /// to prevent dependency confusion attacks against our test suite.

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
//! DO NOT EDIT //! DO NOT EDIT
//! //!
//! Generated with `./scripts/sync_scenarios.sh` //! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.31/scenarios> //! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.32/scenarios>
//! //!
#![cfg(all(feature = "python", feature = "pypi", unix))] #![cfg(all(feature = "python", feature = "pypi", unix))]

View File

@ -1,7 +1,7 @@
//! DO NOT EDIT //! DO NOT EDIT
//! //!
//! Generated with `./scripts/sync_scenarios.sh` //! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.31/scenarios> //! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.32/scenarios>
//! //!
#![cfg(all(feature = "python", feature = "pypi", unix))] #![cfg(all(feature = "python", feature = "pypi", unix))]

1
scripts/scenarios/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.downloads

View File

@ -124,18 +124,26 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
if not scenario["name"].startswith("example") if not scenario["name"].startswith("example")
] ]
# Wrap the description onto multiple lines # We have a mixture of long singe-line descriptions (json scenarios) we need to
# wrap and manually formatted markdown in toml and yaml scenarios we want to
# preserve.
for scenario in data["scenarios"]: for scenario in data["scenarios"]:
scenario["description_lines"] = textwrap.wrap(scenario["description"], width=80) if scenario["_textwrap"]:
scenario["description"] = textwrap.wrap(scenario["description"], width=80)
else:
scenario["description"] = scenario["description"].splitlines()
# Don't drop empty lines like chevron would.
scenario["description"] = "\n/// ".join(scenario["description"])
# Wrap the expected explanation onto multiple lines # Apply the same wrapping to the expected explanation
for scenario in data["scenarios"]: for scenario in data["scenarios"]:
expected = scenario["expected"] expected = scenario["expected"]
expected["explanation_lines"] = ( if explanation := expected["explanation"]:
textwrap.wrap(expected["explanation"], width=80) if scenario["_textwrap"]:
if expected["explanation"] expected["explanation"] = textwrap.wrap(explanation, width=80)
else [] else:
) expected["explanation"] = explanation.splitlines()
expected["explanation"] = "\n// ".join(expected["explanation"])
# Hack to track which scenarios require a specific Python patch version # Hack to track which scenarios require a specific Python patch version
for scenario in data["scenarios"]: for scenario in data["scenarios"]:
@ -155,9 +163,6 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
"local-used-without-sdist", "local-used-without-sdist",
): ):
expected["satisfiable"] = False expected["satisfiable"] = False
expected["explanation"] = (
"We do not have correct behavior for local version identifiers yet"
)
# Split scenarios into `install`, `compile` and `lock` cases # Split scenarios into `install`, `compile` and `lock` cases
install_scenarios = [] install_scenarios = []
@ -224,9 +229,7 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
if snapshot_update: if snapshot_update:
logging.info("Updating snapshots...") logging.info("Updating snapshots...")
env = os.environ.copy() env = os.environ.copy()
env["UV_TEST_PYTHON_PATH"] = str(PROJECT_ROOT / "bin") command = [
subprocess.call(
[
"cargo", "cargo",
"insta", "insta",
"test", "test",
@ -237,7 +240,10 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
"nextest", "nextest",
"--test", "--test",
tests.with_suffix("").name, tests.with_suffix("").name,
], ]
logging.debug(f"Running {" ".join(command)}")
subprocess.call(
command,
cwd=PROJECT_ROOT, cwd=PROJECT_ROOT,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdout=sys.stderr if debug else subprocess.DEVNULL, stdout=sys.stderr if debug else subprocess.DEVNULL,

View File

@ -1,2 +1,2 @@
chevron-blue chevron-blue
packse>=0.3.31 packse>=0.3.32

View File

@ -46,7 +46,7 @@ nh3==0.2.17
# via readme-renderer # via readme-renderer
packaging==24.0 packaging==24.0
# via hatchling # via hatchling
packse==0.3.31 packse==0.3.32
# via -r scripts/scenarios/requirements.in # via -r scripts/scenarios/requirements.in
pathspec==0.12.1 pathspec==0.12.1
# via hatchling # via hatchling

View File

@ -39,9 +39,7 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
{{#scenarios}} {{#scenarios}}
{{#description_lines}} /// {{description}}
/// {{.}}
{{/description_lines}}
/// ///
/// ```text /// ```text
/// {{name}} /// {{name}}
@ -66,9 +64,9 @@ fn {{module_name}}() -> Result<()> {
requirements_in.write_str("{{requirement}}")?; requirements_in.write_str("{{requirement}}")?;
{{/root.requires}} {{/root.requires}}
{{#expected.explanation_lines}} {{#expected.explanation}}
// {{.}} // {{expected.explanation}}
{{/expected.explanation_lines}} {{/expected.explanation}}
let output = uv_snapshot!(filters, command(&context, python_versions) let output = uv_snapshot!(filters, command(&context, python_versions)
{{#resolver_options.prereleases}} {{#resolver_options.prereleases}}
.arg("--prerelease=allow") .arg("--prerelease=allow")

View File

@ -57,9 +57,7 @@ fn command(context: &TestContext) -> Command {
{{#scenarios}} {{#scenarios}}
{{#description_lines}} /// {{description}}
/// {{.}}
{{/description_lines}}
/// ///
/// ```text /// ```text
/// {{name}} /// {{name}}
@ -95,9 +93,9 @@ fn {{module_name}}() {
{{/root.requires}}, @r###"<snapshot> {{/root.requires}}, @r###"<snapshot>
"###); "###);
{{#expected.explanation_lines}} {{#expected.explanation}}
// {{.}} // {{expected.explanation}}
{{/expected.explanation_lines}} {{/expected.explanation}}
{{#expected.satisfiable}} {{#expected.satisfiable}}
{{#expected.packages}} {{#expected.packages}}
assert_installed( assert_installed(

View File

@ -17,9 +17,7 @@ mod common;
{{#scenarios}} {{#scenarios}}
{{#description_lines}} /// {{description}}
/// {{.}}
{{/description_lines}}
/// ///
/// ```text /// ```text
/// {{name}} /// {{name}}
@ -55,9 +53,9 @@ fn {{module_name}}() -> Result<()> {
let mut cmd = context.lock(); let mut cmd = context.lock();
cmd.env_remove("UV_EXCLUDE_NEWER"); cmd.env_remove("UV_EXCLUDE_NEWER");
cmd.arg("--index-url").arg(packse_index_url()); cmd.arg("--index-url").arg(packse_index_url());
{{#expected.explanation_lines}} {{#expected.explanation}}
// {{.}} // {{expected.explanation}}
{{/expected.explanation_lines}} {{/expected.explanation}}
uv_snapshot!(filters, cmd, @r###"<snapshot> uv_snapshot!(filters, cmd, @r###"<snapshot>
"### "###
); );