-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utility functions to compose file distribution names #408
Comments
Not so much an omission as no one has shown a need yet and we prefer to only add support for things people have demonstrable need for instead of guessing. E.g. f the wheel project told us they could use such a thing, though, we would consider adding it. |
Also other PEP 517 backend authors since they would have need for it. |
I have somewhat of a need for it in my project, so I can PR this if you're willing to accept it. |
@MrMino can I ask why it's only "somewhat"? If you have an actual need then we will totally look at a PR, but I would rather avoid speculative code. |
Isn't it going to be just "-".join(...) + extension? Does this really need to be a function here? |
@brettcannon Well, I'm doing it inside wheelfile. It isn't a big deal at all, I just feel like it would be elegant to have it. I haven't utilized @pradyunsg technically |
It's a little more complicated than that due to tag sets. If we added a function to construct that part of the wheel file name then you might as well just skip having that as a separate function (since I don't think it would be that useful on its own) and go as far as constructing the wheel file name entirely. As an example, this is untested code written for Python 3.9: import operator
def _compress_wheel_tags(tags: AbstractSet[Tag], attr: str) -> str:
tag_portions = []
for attr in "interpreter", "abi", "platform":
parts = map(operator.attrgetter(attr), tags)
compressed = ".".join(sorted(parts))
tag_portions.append(compressed)
return "-".join(tag_portions)
def create_wheel_filename(project: NormalizedName, version: Version, build: BuildTag | None, tags: AbstractSet[Tag]) -> str:
compressed_tag = _compress_wheel_tags(tags)
if build:
parts = project, version, build, compressed_tag
else:
parts = project, version, compressed_tag
return "-".join(map(str, parts)) + ".whl" |
If I were to ask for such a function (I am not), I would want name and version normalisation, ensuring components don’t contain |
FYI there is a PR for this, but I think we need to resolve PEP 625 first. |
FYI https://peps.python.org/pep-0625/ has been accepted! |
I've resoled the merge conflicts in the PR. |
Is there interest in a pull request for functions that perform the inverse operation of
packaging.utils.parse_wheel_filename
andparse_sdist_filename
?It seems like an omission that there is no function such that
x == compose_wheel_filename(*parse_wheel_filename(x))
The text was updated successfully, but these errors were encountered: