Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bundle/libraries/local_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}

Expand Down
3 changes: 3 additions & 0 deletions bundle/libraries/local_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this true before the regexp fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was still false anyway but for a wrong reason :) this is just for a completness of test that we don't break anything later.

{path: "/Volumes/catalog/schema/volume/path.whl", expected: false},
{path: "/Workspace/my_project/dist.whl", expected: false},
{path: "-r ../requirements.txt", expected: false},
Expand Down
Loading