Skip to content

Fix patchwheel.ParseWheelFilename to extract basename - #2521

Merged
denik merged 3 commits into
mainfrom
denik/acc-parse-wheel-base
Mar 19, 2025
Merged

Fix patchwheel.ParseWheelFilename to extract basename#2521
denik merged 3 commits into
mainfrom
denik/acc-parse-wheel-base

Conversation

@denik

@denikdenik commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

Why

This is a minor change but makes it easier to use, no need to remember doing this on the caller side.
Relying on this in #2520
Follow up to #2427

Tests

New unit tests.

@denik
denikforce-pushed the denik/acc-parse-wheel-base branch from 8c8f6e6 to 3f86ef5CompareMarch 19, 2025 11:21
@denik
deniktemporarily deployed to test-trigger-is March 19, 2025 11:21 — with GitHub Actions Inactive
Comment threadlibs/patchwheel/parse.go Outdated
// The function does not try hard to validate if the format is correct, it tries to parse whatever is available.
// However, it does require 5 or 6 components in the filename.
func ParseWheelFilename(filename string) (WheelInfo, error) {
filename = path.Base(filename)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be filepath.Base to be OS specific?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to use filepath.Base on Windows unless you know the path is slash-separated.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

good point, thanks f408143

Comment threadlibs/patchwheel/parse_test.go Outdated
require.Equal(t, tt.wantTags, info.Tags, "tags mismatch")
}
})
for _, prefix := range prefixes {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Double nesting is not really needed here. Can you add one additional case to the table?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

fair point, 972530f

Comment threadlibs/patchwheel/parse.go Outdated
// The function does not try hard to validate if the format is correct, it tries to parse whatever is available.
// However, it does require 5 or 6 components in the filename.
func ParseWheelFilename(filename string) (WheelInfo, error) {
filename = path.Base(filename)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to use filepath.Base on Windows unless you know the path is slash-separated.

@denik
deniktemporarily deployed to test-trigger-is March 19, 2025 11:23 — with GitHub Actions Inactive
@denik
denik added this pull request to the merge queueMar 19, 2025
Merged via the queue into main with commit 7cb0b45Mar 19, 2025
@denik
denik deleted the denik/acc-parse-wheel-base branch March 19, 2025 12:06
denik added a commit that referenced this pull request May 20, 2026
## Why
This is a minor change but makes it easier to use, no need to remember
doing this on the caller side.
Relying on this in #2520
Follow up to #2427
## Tests
New unit tests.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@denik@pietern@andrewnester