summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2017-11-26 23:11:14 +0100
committerBenoit Pierre <benoit.pierre@gmail.com>2017-11-26 23:11:14 +0100
commite72afd6243713cd0d3f8a5bc5b50fb59934d7ff8 (patch)
treec581ac167e585999386d3ac2983b6416e4ff5430 /setuptools
parent7b3ed4f22aad1b62c537cc89b07b1691033730c3 (diff)
downloadpython-setuptools-git-e72afd6243713cd0d3f8a5bc5b50fb59934d7ff8.tar.gz
fix encoding handling of wheels metadata
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/tests/files.py9
-rw-r--r--setuptools/tests/test_wheel.py14
-rw-r--r--setuptools/wheel.py3
3 files changed, 21 insertions, 5 deletions
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')