File tree 2 files changed +46
-1
lines changed
2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 15
15
import warnings
16
16
from collections import OrderedDict
17
17
from email .generator import BytesGenerator , Generator
18
+ from email .policy import EmailPolicy
18
19
from glob import iglob
19
20
from io import BytesIO
20
21
from shutil import rmtree
@@ -534,8 +535,13 @@ def adios(p):
534
535
adios (dependency_links_path )
535
536
536
537
pkg_info_path = os .path .join (distinfo_path , "METADATA" )
538
+ serialization_policy = EmailPolicy (
539
+ utf8 = True ,
540
+ mangle_from_ = False ,
541
+ max_line_length = 0 ,
542
+ )
537
543
with open (pkg_info_path , "w" , encoding = "utf-8" ) as out :
538
- Generator (out , mangle_from_ = False , maxheaderlen = 0 ).flatten (pkg_info )
544
+ Generator (out , policy = serialization_policy ).flatten (pkg_info )
539
545
540
546
for license_path in self .license_paths :
541
547
filename = os .path .basename (license_path )
Original file line number Diff line number Diff line change @@ -72,6 +72,45 @@ def test_unicode_record(wheel_paths):
72
72
assert "åäö_日本語.py" .encode () in record
73
73
74
74
75
+ UTF8_PKG_INFO = """\
76
+ Metadata-Version: 2.1
77
+ Name: helloworld
78
+ Version: 42
79
+ Author-email: "John X. Ãørçeč" <john@utf8.org>, Γαμα קּ 東 <gama@utf8.org>
80
+
81
+
82
+ UTF-8 描述 説明
83
+ """
84
+
85
+
86
+ def test_preserve_unicode_metadata (monkeypatch , tmp_path ):
87
+ monkeypatch .chdir (tmp_path )
88
+ egginfo = tmp_path / "dummy_dist.egg-info"
89
+ distinfo = tmp_path / "dummy_dist.dist-info"
90
+
91
+ egginfo .mkdir ()
92
+ (egginfo / "PKG-INFO" ).write_text (UTF8_PKG_INFO , encoding = "utf-8" )
93
+ (egginfo / "dependency_links.txt" ).touch ()
94
+
95
+ class simpler_bdist_wheel (bdist_wheel ):
96
+ """Avoid messing with setuptools/distutils internals"""
97
+
98
+ def __init__ (self ):
99
+ pass
100
+
101
+ @property
102
+ def license_paths (self ):
103
+ return []
104
+
105
+ cmd_obj = simpler_bdist_wheel ()
106
+ cmd_obj .egg2dist (egginfo , distinfo )
107
+
108
+ metadata = (distinfo / "METADATA" ).read_text (encoding = "utf-8" )
109
+ assert 'Author-email: "John X. Ãørçeč"' in metadata
110
+ assert "Γαμα קּ 東 " in metadata
111
+ assert "UTF-8 描述 説明" in metadata
112
+
113
+
75
114
def test_licenses_default (dummy_dist , monkeypatch , tmpdir ):
76
115
monkeypatch .chdir (dummy_dist )
77
116
subprocess .check_call (
You can’t perform that action at this time.
0 commit comments