Add override namespace to pyproject.toml/uv.toml (#3839)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

See #3834 .

This PR adds a new namespace, `override-dependencies`, to
pyproject.toml/uv.toml.
This namespace assumes that the dependencies you want to override are
written in the form of `requirements.txt`.


a example of pyproject.toml
```toml
[project]
name = "example"
version = "0.0.0"
dependencies = [
  "flask==3.0.0"
]

[tool.uv]
override-dependencies = [
  "werkzeug==2.3.0"
]
```

This will improve usability by allowing you to override dependencies
without having to specify the --override option when running `uv pip
compile/install`.

## Test Plan

added test to `crates/uv/tests/pip_compile.rs`.

---------

Co-authored-by: konstin <konstin@mailbox.org>
This commit is contained in:
Di-Is 2024-06-03 19:15:51 +09:00 committed by GitHub
parent 1b769b054c
commit 5c776939d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 293 additions and 8 deletions

View file

@ -9,6 +9,8 @@ pub enum RequirementOrigin {
File(PathBuf),
/// The requirement was provided via a local project (e.g., a `pyproject.toml` file).
Project(PathBuf, PackageName),
/// The requirement was provided via a workspace.
Workspace,
}
impl RequirementOrigin {
@ -17,6 +19,8 @@ impl RequirementOrigin {
match self {
RequirementOrigin::File(path) => path.as_path(),
RequirementOrigin::Project(path, _) => path.as_path(),
// Multiple toml are merged and difficult to track files where Requirement is defined. Returns a dummy path instead.
RequirementOrigin::Workspace => Path::new("(workspace)"),
}
}
}