From 32588cfa8202141164f14f138fdbed0e832ad865 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Mon, 14 Jan 2019 10:40:24 +0900 Subject: [PATCH] Imported Upstream version 38.2.1 --- CHANGES.rst | 6 ++++++ setup.cfg | 2 +- setup.py | 2 +- setuptools/tests/files.py | 9 +++++++-- setuptools/tests/test_wheel.py | 14 ++++++++++++-- setuptools/wheel.py | 3 ++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 63d17d5..d5fd66a 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/setup.cfg b/setup.cfg index f00b544..fd93d44 100755 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 38.2.0 +current_version = 38.2.1 commit = True tag = True diff --git a/setup.py b/setup.py index 7b2c100..8662816 100755 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ def pypi_link(pkg_filename): setup_params = dict( name="setuptools", - version="38.2.0", + version="38.2.1", description="Easily download, build, install, upgrade, and uninstall " "Python packages", author="Python Packaging Authority", diff --git a/setuptools/tests/files.py b/setuptools/tests/files.py index 98de9fc..75ec740 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 a0c16c5..2e85725 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 6e3df77..f711f38 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') -- 2.7.4