From 5a60b73ad83f5aa3b5c0f364e264e64b94f2293b Mon Sep 17 00:00:00 2001 From: "Denis Bilenko (aider)" Date: Tue, 4 Mar 2025 17:45:02 +0100 Subject: [PATCH] fix: Correctly parse wheel filename with build tags --- libs/patchwheel/parse.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/patchwheel/parse.go b/libs/patchwheel/parse.go index 22f0f6125..140b6bdfa 100644 --- a/libs/patchwheel/parse.go +++ b/libs/patchwheel/parse.go @@ -33,7 +33,7 @@ func CalculateNewVersion(info *WheelInfo, mtime time.Time) (newVersion, newFilen } // ParseWheelFilename parses a wheel filename and extracts its components. -// Wheel filenames follow the pattern: {distribution}-{version}-{python_tag}-{abi_tag}-{platform_tag}.whl +// Wheel filenames follow the pattern: {distribution}-{version}(-{build tag})?-{python_tag}-{abi_tag}-{platform_tag}.whl func ParseWheelFilename(filename string) (*WheelInfo, error) { parts := strings.Split(filename, "-") if len(parts) < 5 { @@ -48,12 +48,18 @@ func ParseWheelFilename(filename string) (*WheelInfo, error) { tags := parts[tagStartIdx:] tags[2] = strings.TrimSuffix(tags[2], ".whl") - // Everything before the tags except the version is the distribution - versionIdx := tagStartIdx - 1 + // The version is the second part + version := parts[1] + + // If there are build tags, they are between the version and the python tag + // Include them in the version + if tagStartIdx > 2 { + buildTags := parts[2:tagStartIdx] + version = version + "-" + strings.Join(buildTags, "-") + } - // Distribution may contain hyphens, so join all parts before the version - distribution := strings.Join(parts[:versionIdx], "-") - version := parts[versionIdx] + // The distribution is always the first part + distribution := parts[0] return &WheelInfo{ Distribution: distribution,