-
Notifications
You must be signed in to change notification settings - Fork 250
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
Inverse of parse_wheel_filename #616
Comments
There’s no |
Well in that example no. The question was more about how it's supposed to be represented in the filename.
Yes, thanks. It's easy to do this in this example, my question is in general if there is a function that converts a sequence of N tags to their best-factorized string representation. I suppose packages that output wheel have to do something like this. For more context I'm writing a tool that py-compiles wheels in pyodide/pyodide#3253, while doing that it needs to update tags as well. So for example,
and I'm looking for code that converts a list of tags to a wheel filename string (particularly in the factorized representation). Of course, I can write something that works in most cases but I would rather rely on some well-tested logic in Unless you think this is out of scope for this package. |
I am not a maintainer of |
Thanks for the feedback! To clarify I'm not asking for the functionality that changes the tags following a logic that is indeed very specific and out of scope here. I only provided that information for context. What I'm looking for / or would like to propose is, packaging.tags.tags_to_string(tags: Sequence[Tag]) -> str which is very similar to what So my point is that currently, each tool that generate wheels has its own implementation for this and it would be good to have an official implementation in this package.
Well, we have been doing a lot of that in pyodide, and we are trying to use shared tooling when possible :) |
The |
Best we could do is: # In packaging.utils ...
def combine_tags(tags: Iterable[Tag], /) -> str:
"""Naively create a tag set string."""
interpreter = set()
abi = set()
platform = set()
for tag in tags:
interpreter.add(tag.interpreter)
abi.add(tag.abi)
platform.add(tag.platform)
return f"{'.'.join(interpreter)}-{'.'.join(abi)}-{'.'.join(platform)}" But I don't know how widely useful that would be (e.g. both auditwheel and flit wouldn't use this). Do we know which projects would actually use such a naive function? |
I'd add a sorted call, within the join. 😅 That's actually another thing here -- it's totally valid for someone to tag the wheel as FWIW, I'm in agreement with @uranusjr and @brettcannon that there's likely limited usability of such a generic function -- that said, I'm not opposed to adding it (assuming it's useful, at least occasionally). |
Thanks all for your feedback and examples of code, it's very helfpul! OK let close given your feedback on limited usability. |
I was wondering if there is any existing function that could be used as the inverse of
parse_wheel_filename
?For instance, given,
how do I reconstruct the original file name from those parts? Particularly given that,
so it looks like there is some factorization logic to get
py2.py3-none-any
from those two tags.And also I'm not sure what to do with the
build
tuple and PEP 427 is not very explicit about it. Is is justf"-{build[0]}{build[1]}"
when it's atuple[int, str]
?The text was updated successfully, but these errors were encountered: