Skip to content

Commit

Permalink
Cover some more interpreter tags (#15653)
Browse files Browse the repository at this point in the history
  • Loading branch information
di committed Mar 21, 2024
1 parent 4db4f74 commit 244cad5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
19 changes: 17 additions & 2 deletions tests/unit/utils/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
["CPython 3.12", "musllinux: musl 1.1+ x86-64"],
),
(
"numpy-1.26.4-lol-lol-musllinux_1_1_x86_64.whl",
["musllinux: musl 1.1+ x86-64"],
"numpy-1.26.4-lolinterpreter-lolabi-musllinux_1_1_x86_64.whl",
["lolinterpreter", "musllinux: musl 1.1+ x86-64"],
),
(
(
Expand All @@ -69,6 +69,21 @@
),
("numpy-1.13.1-cp36-none-win_amd64.whl", ["CPython 3.6", "Windows x86-64"]),
("cryptography-38.0.2-cp36-abi3-win32.whl", ["CPython 3.6+", "Windows x86"]),
(
"plato_learn-0.4.7-py36.py37.py38.py39-none-any.whl",
[
"Python 3.6",
"Python 3.7",
"Python 3.8",
"Python 3.9",
],
),
("juriscraper-1.1.11-py27-none-any.whl", ["Python 2.7"]),
("OZI-0.0.291-py312-none-any.whl", ["Python 3.12"]),
("foo-0.0.0-ip27-none-any.whl", ["IronPython 2.7"]),
("foo-0.0.0-jy38-none-any.whl", ["Jython 3.8"]),
("foo-0.0.0-garbage-none-any.whl", ["garbage"]),
("foo-0.0.0-69-none-any.whl", []),
],
)
def test_wheel_to_pretty_tags(filename, expected_tags):
Expand Down
29 changes: 16 additions & 13 deletions warehouse/utils/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,21 @@ def filename_to_pretty_tags(filename: str) -> list[str]:
if match := prefix_re.match(tag.platform):
pretty_tags.add(tmpl(match))

if tag.interpreter.startswith("pp"):
if len(tag.interpreter) < 3 or not tag.interpreter[:2].isalpha():
# This tag doesn't fit our format, give up
pass
elif tag.interpreter.startswith("pp"):
# PyPy tags are a disaster, give up.
pretty_tags.add("PyPy")
elif tag.interpreter == "py3":
pretty_tags.add("Python 3")
elif tag.interpreter == "py2":
pretty_tags.add("Python 2")
elif tag.interpreter.startswith("py"):
major, minor = tag.interpreter[2:3], tag.interpreter[3:]
pretty_tags.add(f"Python {major}{'.' if minor else ''}{minor}")
elif tag.interpreter.startswith("ip"):
major, minor = tag.interpreter[2:3], tag.interpreter[3:]
pretty_tags.add(f"IronPython {major}{'.' if minor else ''}{minor}")
elif tag.interpreter.startswith("jy"):
major, minor = tag.interpreter[2:3], tag.interpreter[3:]
pretty_tags.add(f"Jython {major}{'.' if minor else ''}{minor}")
elif tag.abi == "abi3":
assert tag.interpreter.startswith("cp")
version = _format_version(tag.interpreter.removeprefix("cp"))
Expand All @@ -94,13 +102,8 @@ def filename_to_pretty_tags(filename: str) -> list[str]:
version = _format_version(tag.interpreter.removeprefix("cp"))
pretty_tags.add(f"CPython {version}")
else:
pass
# Disable until we can cover ~all tags
# with sentry_sdk.push_scope() as scope:
# scope.fingerprint = [str(tag)]
# sentry_sdk.capture_message(
# f"wheel has unrecognized interpreter tag: {tag}. "
# f"Filename: {filename}."
# )
# There's a lot of cruft from over the years. If we can't identify
# the interpreter tag, just add it directly.
pretty_tags.add(tag.interpreter)

return sorted(pretty_tags)

0 comments on commit 244cad5

Please sign in to comment.