@@ -13,6 +13,8 @@ pub enum RequirementsSource {
1313Package ( RequirementsTxtRequirement ) , 
1414    /// An editable path was provided on the command line (e.g., `pip install -e ../flask`). 
1515Editable ( RequirementsTxtRequirement ) , 
16+     /// Dependencies were provided via a `pylock.toml` file. 
17+ PylockToml ( PathBuf ) , 
1618    /// Dependencies were provided via a `requirements.txt` file (e.g., `pip install -r requirements.txt`). 
1719RequirementsTxt ( PathBuf ) , 
1820    /// Dependencies were provided via a `pyproject.toml` file (e.g., `pip-compile pyproject.toml`). 
@@ -39,19 +41,32 @@ impl RequirementsSource {
3941            Self :: SetupCfg ( path) 
4042        }  else  if  path. ends_with ( "environment.yml" )  { 
4143            Self :: EnvironmentYml ( path) 
44+         }  else  if  path
45+             . file_name ( ) 
46+             . is_some_and ( |file_name| file_name. to_str ( ) . is_some_and ( is_pylock_toml) ) 
47+         { 
48+             Self :: PylockToml ( path) 
4249        }  else  { 
4350            Self :: RequirementsTxt ( path) 
4451        } 
4552    } 
4653
4754    /// Parse a [`RequirementsSource`] from a `requirements.txt` file. 
4855pub  fn  from_requirements_txt ( path :  PathBuf )  -> Self  { 
49-         for  filename  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
50-             if  path. ends_with ( filename )  { 
56+         for  file_name  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
57+             if  path. ends_with ( file_name )  { 
5158                warn_user ! ( 
5259                    "The file `{}` appears to be a `{}` file, but requirements must be specified in `requirements.txt` format." , 
5360                    path. user_display( ) , 
54-                     filename
61+                     file_name
62+                 ) ; 
63+             } 
64+         } 
65+         if  let  Some ( file_name)  = path. file_name ( )  { 
66+             if  file_name. to_str ( ) . is_some_and ( is_pylock_toml)  { 
67+                 warn_user ! ( 
68+                     "The file `{}` appears to be a `pylock.toml` file, but requirements must be specified in `requirements.txt` format." , 
69+                     path. user_display( ) , 
5570                ) ; 
5671            } 
5772        } 
@@ -60,12 +75,20 @@ impl RequirementsSource {
6075
6176    /// Parse a [`RequirementsSource`] from a `constraints.txt` file. 
6277pub  fn  from_constraints_txt ( path :  PathBuf )  -> Self  { 
63-         for  filename  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
64-             if  path. ends_with ( filename )  { 
78+         for  file_name  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
79+             if  path. ends_with ( file_name )  { 
6580                warn_user ! ( 
6681                    "The file `{}` appears to be a `{}` file, but constraints must be specified in `requirements.txt` format." , 
6782                    path. user_display( ) , 
68-                     filename
83+                     file_name
84+                 ) ; 
85+             } 
86+         } 
87+         if  let  Some ( file_name)  = path. file_name ( )  { 
88+             if  file_name. to_str ( ) . is_some_and ( is_pylock_toml)  { 
89+                 warn_user ! ( 
90+                     "The file `{}` appears to be a `pylock.toml` file, but constraints must be specified in `requirements.txt` format." , 
91+                     path. user_display( ) , 
6992                ) ; 
7093            } 
7194        } 
@@ -74,12 +97,20 @@ impl RequirementsSource {
7497
7598    /// Parse a [`RequirementsSource`] from an `overrides.txt` file. 
7699pub  fn  from_overrides_txt ( path :  PathBuf )  -> Self  { 
77-         for  filename  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
78-             if  path. ends_with ( filename )  { 
100+         for  file_name  in  [ "pyproject.toml" ,  "setup.py" ,  "setup.cfg" ]  { 
101+             if  path. ends_with ( file_name )  { 
79102                warn_user ! ( 
80103                    "The file `{}` appears to be a `{}` file, but overrides must be specified in `requirements.txt` format." , 
81104                    path. user_display( ) , 
82-                     filename
105+                     file_name
106+                 ) ; 
107+             } 
108+         } 
109+         if  let  Some ( file_name)  = path. file_name ( )  { 
110+             if  file_name. to_str ( ) . is_some_and ( is_pylock_toml)  { 
111+                 warn_user ! ( 
112+                     "The file `{}` appears to be a `pylock.toml` file, but overrides must be specified in `requirements.txt` format." , 
113+                     path. user_display( ) , 
83114                ) ; 
84115            } 
85116        } 
@@ -110,7 +141,10 @@ impl RequirementsSource {
110141
111142        // Similarly, if the user provided a `pyproject.toml` file without `-r` (as in 
112143        // `uv pip install pyproject.toml`), prompt them to correct it. 
113-         if  ( name == "pyproject.toml"  || name == "setup.py"  || name == "setup.cfg" ) 
144+         if  ( name == "pyproject.toml" 
145+             || name == "setup.py" 
146+             || name == "setup.cfg" 
147+             || is_pylock_toml ( name) ) 
114148            && Path :: new ( & name) . is_file ( ) 
115149        { 
116150            let  term = Term :: stderr ( ) ; 
@@ -155,7 +189,10 @@ impl RequirementsSource {
155189
156190        // Similarly, if the user provided a `pyproject.toml` file without `--with-requirements` (as in 
157191        // `uvx --with pyproject.toml ruff`), prompt them to correct it. 
158-         if  ( name == "pyproject.toml"  || name == "setup.py"  || name == "setup.cfg" ) 
192+         if  ( name == "pyproject.toml" 
193+             || name == "setup.py" 
194+             || name == "setup.cfg" 
195+             || is_pylock_toml ( name) ) 
159196            && Path :: new ( & name) . is_file ( ) 
160197        { 
161198            let  term = Term :: stderr ( ) ; 
@@ -217,7 +254,8 @@ impl std::fmt::Display for RequirementsSource {
217254        match  self  { 
218255            Self :: Package ( package)  => write ! ( f,  "{package:?}" ) , 
219256            Self :: Editable ( path)  => write ! ( f,  "-e {path:?}" ) , 
220-             Self :: RequirementsTxt ( path) 
257+             Self :: PylockToml ( path) 
258+             | Self :: RequirementsTxt ( path) 
221259            | Self :: PyprojectToml ( path) 
222260            | Self :: SetupPy ( path) 
223261            | Self :: SetupCfg ( path) 
0 commit comments