aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst6
-rw-r--r--setuptools/tests/files.py9
-rw-r--r--setuptools/tests/test_wheel.py14
-rw-r--r--setuptools/wheel.py3
4 files changed, 27 insertions, 5 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 63d17d5d..d5fd66a3 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,9 @@
+v38.2.1
+-------
+
+* #1212: fix encoding handling of metadata when installing
+ from a wheel.
+
v38.2.0
-------
diff --git a/setuptools/tests/files.py b/setuptools/tests/files.py
index 98de9fc3..75ec740d 100644
--- a/setuptools/tests/files.py
+++ b/setuptools/tests/files.py
@@ -1,6 +1,7 @@
import os
+from pkg_resources.extern.six import binary_type
import pkg_resources.py31compat
@@ -30,5 +31,9 @@ def build_files(file_defs, prefix=""):
pkg_resources.py31compat.makedirs(full_name, exist_ok=True)
build_files(contents, prefix=full_name)
else:
- with open(full_name, 'w') as f:
- f.write(contents)
+ if isinstance(contents, binary_type):
+ with open(full_name, 'wb') as f:
+ f.write(contents)
+ else:
+ with open(full_name, 'w') as f:
+ f.write(contents)
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index a0c16c53..2e857253 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
"""wheel tests
"""
@@ -72,13 +74,14 @@ def test_wheel_info(filename, info):
@contextlib.contextmanager
def build_wheel(extra_file_defs=None, **kwargs):
file_defs = {
- 'setup.py': DALS(
+ 'setup.py': (DALS(
'''
+ # -*- coding: utf-8 -*-
from setuptools import setup
import setuptools
setup(**%r)
'''
- ) % kwargs,
+ ) % kwargs).encode('utf-8'),
}
if extra_file_defs:
file_defs.update(extra_file_defs)
@@ -171,6 +174,13 @@ WHEEL_INSTALL_TESTS = (
),
dict(
+ id='utf-8',
+ setup_kwargs=dict(
+ description='Description accentuée',
+ )
+ ),
+
+ dict(
id='data',
file_defs={
'data.txt': DALS(
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index 6e3df77c..f711f38b 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -8,6 +8,7 @@ import re
import zipfile
from pkg_resources import Distribution, PathMetadata, parse_version
+from pkg_resources.extern.six import PY3
from setuptools import Distribution as SetuptoolsDistribution
from setuptools import pep425tags
from setuptools.command.egg_info import write_requirements
@@ -55,7 +56,7 @@ class Wheel(object):
dist_data = '%s.data' % dist_basename
def get_metadata(name):
with zf.open('%s/%s' % (dist_info, name)) as fp:
- value = fp.read().decode('utf-8')
+ value = fp.read().decode('utf-8') if PY3 else fp.read()
return email.parser.Parser().parsestr(value)
wheel_metadata = get_metadata('WHEEL')
dist_metadata = get_metadata('METADATA')