mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 04:48:18 +00:00
Add support for Hatch's {root:uri} paths in editable installs (#2492)
## Summary
If a package uses Hatch's `root.uri` feature, we currently error:
```toml
dependencies = [
"black @ {root:uri}/../black_editable"
]
```
Even though we're using PEP 517 hooks to get the metadata, which
_should_ support this. The problem is that we load the full
`PyProjectToml`, which means we parse the requirements, which means we
reject what looks like a relative URL in dependencies.
Instead, we should only enforce a limited subset of `pyproject.toml`
(arguably none).
Closes https://github.com/astral-sh/uv/issues/2475.
This commit is contained in:
parent
5a95f50619
commit
db5898bd67
7 changed files with 76 additions and 2 deletions
|
|
@ -5150,3 +5150,39 @@ requires-python = "<=3.8"
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Build an editable package with Hatchling's {root:uri} feature.
|
||||
#[test]
|
||||
fn compile_root_uri() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("-e ${ROOT_PATH}")?;
|
||||
|
||||
// In addition to the standard filters, remove the temporary directory from the snapshot.
|
||||
let filters: Vec<_> = [(r"file://.*/", "file://[TEMP_DIR]/")]
|
||||
.into_iter()
|
||||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
let root_path = current_dir()?.join("../../scripts/editable-installs/root_editable");
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg("requirements.in")
|
||||
.env("ROOT_PATH", root_path.as_os_str()), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in
|
||||
-e ${ROOT_PATH}
|
||||
black @ file://[TEMP_DIR]/black_editable
|
||||
# via root-editable
|
||||
|
||||
----- stderr -----
|
||||
Built 1 editable in [TIME]
|
||||
Resolved 2 packages in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue