Skip to content

Commit d727449

Browse files
committed
Move monkeypatching of metadata 2.0 support to a more proper place
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.
1 parent 1e67470 commit d727449

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

twine/package.py

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
from twine import wheel
3030
from twine import wininst
3131

32+
# Monkeypatch Metadata 2.0 support
33+
metadata._VALID_METADATA_VERSIONS = [
34+
"1.0",
35+
"1.1",
36+
"1.2",
37+
"2.0",
38+
"2.1",
39+
"2.2",
40+
"2.3",
41+
"2.4",
42+
]
43+
3244
DIST_TYPES = {
3345
"bdist_wheel": wheel.Wheel,
3446
"bdist_wininst": wininst.WinInst,

twine/wheel.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,11 @@
1414
import os
1515
import re
1616
import zipfile
17-
from typing import List, Literal, Optional
18-
19-
import packaging.metadata
17+
from typing import List, Optional
2018

2119
from twine import distribution
2220
from twine import exceptions
2321

24-
# Monkeypatch Metadata 2.0 support
25-
packaging.metadata._VALID_METADATA_VERSIONS = ["1.0", "1.1", "1.2", "2.0", "2.1", "2.2", "2.3", "2.4"]
26-
27-
2822
wheel_file_re = re.compile(
2923
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
3024
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)

0 commit comments

Comments
 (0)