File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
uv-distribution/src/metadata Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ impl SourcedDependencyGroups {
58
58
source_strategy : SourceStrategy ,
59
59
cache : & WorkspaceCache ,
60
60
) -> Result < Self , MetadataError > {
61
+ // If the `pyproject.toml` doesn't exist, fail early.
62
+ if !pyproject_path. is_file ( ) {
63
+ return Err ( MetadataError :: MissingPyprojectToml (
64
+ pyproject_path. to_path_buf ( ) ,
65
+ ) ) ;
66
+ }
67
+
61
68
let discovery = DiscoveryOptions {
62
69
stop_discovery_at : git_member. map ( |git_member| {
63
70
git_member
Original file line number Diff line number Diff line change 1
1
use std:: collections:: BTreeMap ;
2
- use std:: path:: Path ;
2
+ use std:: path:: { Path , PathBuf } ;
3
3
4
4
use thiserror:: Error ;
5
5
@@ -28,6 +28,8 @@ pub enum MetadataError {
28
28
Workspace ( #[ from] WorkspaceError ) ,
29
29
#[ error( transparent) ]
30
30
DependencyGroup ( #[ from] DependencyGroupError ) ,
31
+ #[ error( "No pyproject.toml found at: {0}" ) ]
32
+ MissingPyprojectToml ( PathBuf ) ,
31
33
#[ error( "Failed to parse entry: `{0}`" ) ]
32
34
LoweringError ( PackageName , #[ source] Box < LoweringError > ) ,
33
35
#[ error( "Failed to parse entry in group `{0}`: `{1}`" ) ]
Original file line number Diff line number Diff line change @@ -16179,6 +16179,34 @@ fn directory_and_group() -> Result<()> {
16179
16179
Ok(())
16180
16180
}
16181
16181
16182
+ #[test]
16183
+ fn group_target_does_not_exist() -> Result<()> {
16184
+ let context = TestContext::new("3.12");
16185
+
16186
+ let pyproject_toml = context.temp_dir.child("pyproject.toml");
16187
+ pyproject_toml.write_str(
16188
+ r#"
16189
+ [project]
16190
+ name = "uv%%%"
16191
+ version = "0.1.0"
16192
+ requires-python = ">=3.12"
16193
+ "#,
16194
+ )?;
16195
+
16196
+ uv_snapshot!(context.filters(), context.pip_compile()
16197
+ .arg("--group").arg("does/not/exist/pyproject.toml:foo"), @r"
16198
+ success: false
16199
+ exit_code: 2
16200
+ ----- stdout -----
16201
+
16202
+ ----- stderr -----
16203
+ error: Failed to read dependency groups from: does/not/exist/pyproject.toml
16204
+ Caused by: No pyproject.toml found at: does/not/exist/pyproject.toml
16205
+ ");
16206
+
16207
+ Ok(())
16208
+ }
16209
+
16182
16210
/// See: <https://github.com/astral-sh/uv/issues/10957>
16183
16211
#[cfg(feature = "python-eol")]
16184
16212
#[test]
You can’t perform that action at this time.
0 commit comments