File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,10 @@ var PipFlagsWithLocalPaths = []string{
8181
8282func IsLocalPathInPipFlag (dep string ) (string , string , bool ) {
8383 for _ , flag := range PipFlagsWithLocalPaths {
84- dep , ok := strings .CutPrefix (dep , flag + " " )
84+ depWithoutFlag , ok := strings .CutPrefix (dep , flag + " " )
8585 if ok {
86- dep = strings .TrimSpace (dep )
87- return dep , flag , IsLocalPath (dep )
86+ depWithoutFlag = strings .TrimSpace (depWithoutFlag )
87+ return depWithoutFlag , flag , IsLocalPath (depWithoutFlag )
8888 }
8989 }
9090
@@ -95,7 +95,7 @@ func containsPipFlag(input string) bool {
9595 // Trailing space means the the flag takes an argument or there's multiple arguments in input
9696 // Alternatively it could be a flag with no argument and no space after it
9797 // For example: -r myfile.txt or --index-url http://myindexurl.com or -i
98- re := regexp .MustCompile (`--?[a-zA-Z0-9-]+(\s|$)` )
98+ re := regexp .MustCompile (`(^|\s+) --?[a-zA-Z0-9-]+(\s+ |$)` )
9999 return re .MatchString (input )
100100}
101101
Original file line number Diff line number Diff line change @@ -48,8 +48,11 @@ func TestIsLibraryLocal(t *testing.T) {
4848 {path : "../../local/*.whl" , expected : true },
4949 {path : "..\\ ..\\ local\\ *.whl" , expected : true },
5050 {path : "file://path/to/package/whl.whl" , expected : true },
51+ {path : "local/foo-bar.whl" , expected : true },
52+
5153 {path : "" , expected : false },
5254 {path : "pypipackage" , expected : false },
55+ {path : "foo-bar" , expected : false },
5356 {path : "/Volumes/catalog/schema/volume/path.whl" , expected : false },
5457 {path : "/Workspace/my_project/dist.whl" , expected : false },
5558 {path : "-r ../requirements.txt" , expected : false },
You can’t perform that action at this time.
0 commit comments