Skip to content

Commit bdada13

Browse files
Using the metadata parser packaging.metadata
Fixes #561. Replacing the metadata parser with the metadata parser from packaging.metadata. As we need to use the packaging library to parse metadata instead of using the email library ourselves. Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
1 parent 4fa10a0 commit bdada13

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/fromager/bootstrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import tempfile
1010
import typing
1111
import zipfile
12-
from email.parser import BytesParser
1312
from urllib.parse import urlparse
1413

14+
from packaging.metadata import Metadata, parse_email
1515
from packaging.requirements import Requirement
1616
from packaging.utils import NormalizedName, canonicalize_name
1717
from packaging.version import Version
@@ -784,9 +784,9 @@ def _get_version_from_package_metadata(
784784
)
785785
metadata_filename = source_dir.parent / metadata_dir_base / "METADATA"
786786
with open(metadata_filename, "rb") as f:
787-
p = BytesParser()
788-
metadata = p.parse(f, headersonly=True)
789-
return Version(metadata["Version"])
787+
raw_metadata, _ = parse_email(f.read())
788+
metadata = Metadata.from_raw(raw_metadata)
789+
return metadata.version
790790

791791
def _resolve_prebuilt_with_history(
792792
self,

0 commit comments

Comments
 (0)