diff --git a/bundle/libraries/local_path.go b/bundle/libraries/local_path.go index 6b07c70bb8..7148ae36a7 100644 --- a/bundle/libraries/local_path.go +++ b/bundle/libraries/local_path.go @@ -81,10 +81,10 @@ var PipFlagsWithLocalPaths = []string{ func IsLocalPathInPipFlag(dep string) (string, string, bool) { for _, flag := range PipFlagsWithLocalPaths { - dep, ok := strings.CutPrefix(dep, flag+" ") + depWithoutFlag, ok := strings.CutPrefix(dep, flag+" ") if ok { - dep = strings.TrimSpace(dep) - return dep, flag, IsLocalPath(dep) + depWithoutFlag = strings.TrimSpace(depWithoutFlag) + return depWithoutFlag, flag, IsLocalPath(depWithoutFlag) } } @@ -95,7 +95,7 @@ func containsPipFlag(input string) bool { // Trailing space means the the flag takes an argument or there's multiple arguments in input // Alternatively it could be a flag with no argument and no space after it // For example: -r myfile.txt or --index-url http://myindexurl.com or -i - re := regexp.MustCompile(`--?[a-zA-Z0-9-]+(\s|$)`) + re := regexp.MustCompile(`(^|\s+)--?[a-zA-Z0-9-]+(\s+|$)`) return re.MatchString(input) } diff --git a/bundle/libraries/local_path_test.go b/bundle/libraries/local_path_test.go index f97e911fc4..014841a06a 100644 --- a/bundle/libraries/local_path_test.go +++ b/bundle/libraries/local_path_test.go @@ -48,8 +48,11 @@ func TestIsLibraryLocal(t *testing.T) { {path: "../../local/*.whl", expected: true}, {path: "..\\..\\local\\*.whl", expected: true}, {path: "file://path/to/package/whl.whl", expected: true}, + {path: "local/foo-bar.whl", expected: true}, + {path: "", expected: false}, {path: "pypipackage", expected: false}, + {path: "foo-bar", expected: false}, {path: "/Volumes/catalog/schema/volume/path.whl", expected: false}, {path: "/Workspace/my_project/dist.whl", expected: false}, {path: "-r ../requirements.txt", expected: false},