Skip to content

Commit

Permalink
Move monkeypatching of metadata 2.0 support to a more proper place
Browse files Browse the repository at this point in the history
It was done in the support code for the wheel file format but it
affects metadata loading from all supported distribution types. Move
it to generic code.
  • Loading branch information
dnicolodi committed Dec 1, 2024
1 parent 13749dc commit ed7e371
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 12 additions & 0 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
from twine import wheel
from twine import wininst

# Monkeypatch Metadata 2.0 support
metadata._VALID_METADATA_VERSIONS = [
"1.0",
"1.1",
"1.2",
"2.0",
"2.1",
"2.2",
"2.3",
"2.4",
]

DIST_TYPES = {
"bdist_wheel": wheel.Wheel,
"bdist_wininst": wininst.WinInst,
Expand Down
8 changes: 1 addition & 7 deletions twine/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@
import os
import re
import zipfile
from typing import List, Literal, Optional

import packaging.metadata
from typing import List, Optional

from twine import distribution
from twine import exceptions

# Monkeypatch Metadata 2.0 support
packaging.metadata._VALID_METADATA_VERSIONS = ["1.0", "1.1", "1.2", "2.0", "2.1", "2.2", "2.3", "2.4"]


wheel_file_re = re.compile(
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
Expand Down

0 comments on commit ed7e371

Please sign in to comment.