-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add override namespace to pyproject.toml/uv.toml #3839
Conversation
…p compile and pip sync.
CodSpeed Performance ReportMerging #3839 will not alter performanceComparing Summary
|
I skimmed through the diff and it looks good. To get the tests passing you need to run |
… was overridden in the workspace configuration.
@konstin Over the next few days I added a feature to the output of the Here is an excerpt of the output from werkzeug==2.3.0
# via.
# --override (from workspace)
# flask. However, the implementation has become more complicated with the addition of this feature. |
crates/pep508-rs/src/origin.rs
Outdated
@@ -17,6 +19,7 @@ impl RequirementOrigin { | |||
match self { | |||
RequirementOrigin::File(path) => path.as_path(), | |||
RequirementOrigin::Project(path, _) => path.as_path(), | |||
_ => panic!("Unsupported RequirementOrigin variant"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead attach the file containing the override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that multiple toml files(pyproject.toml, uv.toml) are combined to obtain an override dependency.
It seems difficult to keep track of which files have which overriding dependencies.
I'll give it a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense! What i'd like to do is try to avoid explicit panics where possible. Sometimes they are unavoidable, sometimes so you restructure code so the codepath becomes unreachable, sometimes you add a dummy value, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to return dummy paths instead of panic.
766bf17#diff-a8cc5969fdef854f20c6a58c35e8727e9066c25b4625338501beda19b447ac2bR23
@@ -25,13 +25,22 @@ impl std::fmt::Display for SourceAnnotation { | |||
RequirementOrigin::Project(path, project_name) => { | |||
write!(f, "{project_name} ({})", path.portable_display()) | |||
} | |||
RequirementOrigin::Workspace => panic!("Unsupported RequirementOrigin variant"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you write a value here instead of panicking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed so as not to cause panic.
f480a65#diff-838c9ead31fb7f2602f55cb685ca61849dffa88781386be29b84027a83b7258eR28-R30
crates/uv-workspace/src/settings.rs
Outdated
@@ -37,6 +37,7 @@ pub struct Options { | |||
pub preview: Option<bool>, | |||
pub cache_dir: Option<PathBuf>, | |||
pub pip: Option<PipOptions>, | |||
pub override_dependencies: Option<Vec<String>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this Option<Vec<Requirement>>
? This should simplify the specification.rs
code too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the deserialization process and JsonSchema and changed the type to Vec<pypi_types::Reuqirement>.
JsonSchema
766bf17#diff-ef8d164011970bb55e80ae99198f0698f74e77faf77cfa76ed6ea650194cad3fR34
Deserialization
766bf17#diff-c615ba811c1d932585ca0c27d737c61469970854c4e527a9e49d73cba5bef35fR46
…ce loading process.
…r is output as a warning in addition to the file name.
…in APPDATA at test
crates/uv/src/main.rs
Outdated
// enable warning before workspace loading. | ||
if !cli.global_args.quiet { | ||
uv_warnings::enable(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the flag is not set here, warnings of workspace parsing failure will not be output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this bug when I was creating the test.
If it is better to separate them into separate PRs, I will remove the relevant process and some of the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, could you create a different PR for those please?
crates/uv/src/main.rs
Outdated
// Configure the `warn!` macros, which control user-facing warnings in the CLI. | ||
if !globals.quiet { | ||
if globals.quiet { | ||
uv_warnings::disable(); | ||
} else { | ||
uv_warnings::enable(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reflect workspace quiet flag after workspace loading.
Added new uv_warnings::disable() for this process.
These should become a separate PR.
I've removed the warnings changes in this PR to keep this to only adding |
@konstin - How does this intersect with the existing overrides feature? |
We chain them, so you can use both atm: uv/crates/uv/src/commands/pip/compile.rs Lines 406 to 415 in 5c77693
|
Resolves #4467. ## Summary This PR implements the following 1. Add `tool.uv.constraint-dependencies` to pyproject.toml 1. Support to refer `tool.uv.constraint-dependencies` in `uv lock` 1. Support to refer `tool.uv.constraint-dependencies` in `uv pip compile/install` These are analogues of the override features implemented in #3839 and #4369. ## Test Plan Add test.
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
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
.