|
14 | 14 | import sysconfig
|
15 | 15 | import warnings
|
16 | 16 | from collections.abc import Iterable, Sequence
|
17 |
| -from email.generator import BytesGenerator, Generator |
18 |
| -from email.policy import EmailPolicy |
| 17 | +from email.generator import BytesGenerator |
19 | 18 | from glob import iglob
|
20 | 19 | from typing import Literal, cast
|
21 | 20 | from zipfile import ZIP_DEFLATED, ZIP_STORED
|
22 | 21 |
|
23 | 22 | from packaging import tags, version as _packaging_version
|
24 |
| -from wheel.metadata import pkginfo_to_metadata |
25 | 23 | from wheel.wheelfile import WheelFile
|
26 | 24 |
|
27 | 25 | from .. import Command, __version__, _shutil
|
@@ -569,42 +567,30 @@ def adios(p: str) -> None:
|
569 | 567 |
|
570 | 568 | raise ValueError(err)
|
571 | 569 |
|
572 |
| - if os.path.isfile(egginfo_path): |
573 |
| - # .egg-info is a single file |
574 |
| - pkg_info = pkginfo_to_metadata(egginfo_path, egginfo_path) |
575 |
| - os.mkdir(distinfo_path) |
576 |
| - else: |
577 |
| - # .egg-info is a directory |
578 |
| - pkginfo_path = os.path.join(egginfo_path, "PKG-INFO") |
579 |
| - pkg_info = pkginfo_to_metadata(egginfo_path, pkginfo_path) |
580 |
| - |
581 |
| - # ignore common egg metadata that is useless to wheel |
582 |
| - shutil.copytree( |
583 |
| - egginfo_path, |
584 |
| - distinfo_path, |
585 |
| - ignore=lambda x, y: { |
586 |
| - "PKG-INFO", |
587 |
| - "requires.txt", |
588 |
| - "SOURCES.txt", |
589 |
| - "not-zip-safe", |
590 |
| - }, |
591 |
| - ) |
592 |
| - |
593 |
| - # delete dependency_links if it is only whitespace |
594 |
| - dependency_links_path = os.path.join(distinfo_path, "dependency_links.txt") |
595 |
| - with open(dependency_links_path, encoding="utf-8") as dependency_links_file: |
596 |
| - dependency_links = dependency_links_file.read().strip() |
597 |
| - if not dependency_links: |
598 |
| - adios(dependency_links_path) |
599 |
| - |
600 |
| - pkg_info_path = os.path.join(distinfo_path, "METADATA") |
601 |
| - serialization_policy = EmailPolicy( |
602 |
| - utf8=True, |
603 |
| - mangle_from_=False, |
604 |
| - max_line_length=0, |
| 570 | + # .egg-info is a directory |
| 571 | + pkginfo_path = os.path.join(egginfo_path, "PKG-INFO") |
| 572 | + |
| 573 | + # ignore common egg metadata that is useless to wheel |
| 574 | + shutil.copytree( |
| 575 | + egginfo_path, |
| 576 | + distinfo_path, |
| 577 | + ignore=lambda x, y: { |
| 578 | + "PKG-INFO", |
| 579 | + "requires.txt", |
| 580 | + "SOURCES.txt", |
| 581 | + "not-zip-safe", |
| 582 | + }, |
605 | 583 | )
|
606 |
| - with open(pkg_info_path, "w", encoding="utf-8") as out: |
607 |
| - Generator(out, policy=serialization_policy).flatten(pkg_info) |
| 584 | + |
| 585 | + # delete dependency_links if it is only whitespace |
| 586 | + dependency_links_path = os.path.join(distinfo_path, "dependency_links.txt") |
| 587 | + with open(dependency_links_path, encoding="utf-8") as dependency_links_file: |
| 588 | + dependency_links = dependency_links_file.read().strip() |
| 589 | + if not dependency_links: |
| 590 | + adios(dependency_links_path) |
| 591 | + |
| 592 | + metadata_path = os.path.join(distinfo_path, "METADATA") |
| 593 | + shutil.copy(pkginfo_path, metadata_path) |
608 | 594 |
|
609 | 595 | for license_path in self.license_paths:
|
610 | 596 | filename = os.path.basename(license_path)
|
|
0 commit comments