mirror of https://github.com/astral-sh/uv
Avoid writing invalid PEP 723 scripts on `tool.uv.sources` (#6706)
## Summary We were writing empty lines between the dependencies and the `tool.uv.sources` table, which led to the `/// script` tag being unclosed and thus not recognized. Closes https://github.com/astral-sh/uv/issues/6700.
This commit is contained in:
parent
a8f4e08d5b
commit
8d466db080
|
|
@ -350,13 +350,12 @@ fn serialize_metadata(metadata: &str) -> String {
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
|
|
||||||
for line in metadata.lines() {
|
for line in metadata.lines() {
|
||||||
if line.is_empty() {
|
output.push('#');
|
||||||
output.push('\n');
|
if !line.is_empty() {
|
||||||
} else {
|
output.push(' ');
|
||||||
output.push_str("# ");
|
|
||||||
output.push_str(line);
|
output.push_str(line);
|
||||||
output.push('\n');
|
|
||||||
}
|
}
|
||||||
|
output.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
output.push_str("# ///");
|
output.push_str("# ///");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#![cfg(all(feature = "python", feature = "pypi"))]
|
#![cfg(all(feature = "python", feature = "pypi"))]
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assert_cmd::assert::OutputAssertExt;
|
||||||
use assert_fs::prelude::*;
|
use assert_fs::prelude::*;
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use insta::assert_snapshot;
|
use insta::assert_snapshot;
|
||||||
|
|
@ -4188,16 +4189,12 @@ fn add_git_to_script() -> Result<()> {
|
||||||
# /// script
|
# /// script
|
||||||
# requires-python = ">=3.11"
|
# requires-python = ">=3.11"
|
||||||
# dependencies = [
|
# dependencies = [
|
||||||
# "rich",
|
# "anyio",
|
||||||
# ]
|
# ]
|
||||||
# ///
|
# ///
|
||||||
|
|
||||||
import requests
|
import anyio
|
||||||
from rich.pretty import pprint
|
import uv_public_pypackage
|
||||||
|
|
||||||
resp = requests.get("https://peps.python.org/api/peps.json")
|
|
||||||
data = resp.json()
|
|
||||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
|
||||||
"#})?;
|
"#})?;
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context
|
uv_snapshot!(context.filters(), context
|
||||||
|
|
@ -4223,23 +4220,23 @@ fn add_git_to_script() -> Result<()> {
|
||||||
# /// script
|
# /// script
|
||||||
# requires-python = ">=3.11"
|
# requires-python = ">=3.11"
|
||||||
# dependencies = [
|
# dependencies = [
|
||||||
# "rich",
|
# "anyio",
|
||||||
# "uv-public-pypackage",
|
# "uv-public-pypackage",
|
||||||
# ]
|
# ]
|
||||||
|
#
|
||||||
# [tool.uv.sources]
|
# [tool.uv.sources]
|
||||||
# uv-public-pypackage = { git = "https://github.com/astral-test/uv-public-pypackage", tag = "0.0.1" }
|
# uv-public-pypackage = { git = "https://github.com/astral-test/uv-public-pypackage", tag = "0.0.1" }
|
||||||
# ///
|
# ///
|
||||||
|
|
||||||
import requests
|
import anyio
|
||||||
from rich.pretty import pprint
|
import uv_public_pypackage
|
||||||
|
|
||||||
resp = requests.get("https://peps.python.org/api/peps.json")
|
|
||||||
data = resp.json()
|
|
||||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure that the script runs without error.
|
||||||
|
context.run().arg("script.py").assert().success();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue