Imported Upstream version 39.0.1 upstream/39.0.1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:42:03 +0000 (10:42 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:42:03 +0000 (10:42 +0900)
CHANGES.rst
setup.cfg
setup.py
setuptools/dist.py
setuptools/tests/test_dist.py

index 8fae9816d53348c9d766194ed72f28476c4a6435..05de76e50a57f838655fa42a194366fc27480060 100644 (file)
@@ -1,3 +1,9 @@
+v39.0.1
+-------
+
+* #1297: Restore Unicode handling for Maintainer fields in
+  metadata.
+
 v39.0.0
 -------
 
index 4b5a26ab622a2ec950aab985de1fbd386d928fc1..daec5c99f3c74283b95be21af24f40acff54867e 100755 (executable)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 39.0.0
+current_version = 39.0.1
 commit = True
 tag = True
 
index b2cff53bf2c96e58db47515021a45118df45a9c7..9ac05104d4348e6d2bc9e192a3ccde24c12aa46f 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
 
 setup_params = dict(
     name="setuptools",
-    version="39.0.0",
+    version="39.0.1",
     description=(
         "Easily download, build, install, upgrade, and uninstall "
         "Python packages"
index cd34eef6390daeffe798ae27f67b68833ff539d2..284d922df528cb4daee397d912639c98420cdc56 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 __all__ = ['Distribution']
 
 import re
@@ -35,10 +36,13 @@ def _get_unpatched(cls):
     warnings.warn("Do not call this function", DeprecationWarning)
     return get_unpatched(cls)
 
+
 def get_metadata_version(dist_md):
     if dist_md.long_description_content_type or dist_md.provides_extras:
         return StrictVersion('2.1')
-    elif getattr(dist_md, 'python_requires', None) is not None:
+    elif (dist_md.maintainer is not None or
+          dist_md.maintainer_email is not None or
+          getattr(dist_md, 'python_requires', None) is not None):
         return StrictVersion('1.2')
     elif (dist_md.provides or dist_md.requires or dist_md.obsoletes or
             dist_md.classifiers or dist_md.download_url):
@@ -59,7 +63,7 @@ def write_pkg_file(self, file):
     file.write('Summary: %s\n' % self.get_description())
     file.write('Home-page: %s\n' % self.get_url())
 
-    if version == '1.2':
+    if version < StrictVersion('1.2'):
         file.write('Author: %s\n' % self.get_contact())
         file.write('Author-email: %s\n' % self.get_contact_email())
     else:
@@ -72,6 +76,9 @@ def write_pkg_file(self, file):
 
         for field, attr in optional_fields:
             attr_val = getattr(self, attr)
+            if six.PY2:
+                attr_val = self._encode_field(attr_val)
+
             if attr_val is not None:
                 file.write('%s: %s\n' % (field, attr_val))
 
@@ -88,7 +95,7 @@ def write_pkg_file(self, file):
     if keywords:
         file.write('Keywords: %s\n' % keywords)
 
-    if version == '1.2':
+    if version >= StrictVersion('1.2'):
         for platform in self.get_platforms():
             file.write('Platform: %s\n' % platform)
     else:
@@ -556,7 +563,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
                 # don't use any other settings
                 'find_links', 'site_dirs', 'index_url',
                 'optimize', 'site_dirs', 'allow_hosts',
-        ))
+            ))
         if self.dependency_links:
             links = self.dependency_links[:]
             if 'find_links' in opts:
index 0c10f05bc1fc2fac3658ac326e82c46ca8401077..5162e1c9858648848c12244d100a8d8196c1b4ba 100644 (file)
@@ -1,20 +1,26 @@
 # -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+
+import io
+
 from setuptools import Distribution
 from setuptools.extern.six.moves.urllib.request import pathname2url
 from setuptools.extern.six.moves.urllib_parse import urljoin
-from setuptools.extern.six import StringIO
 
 from .textwrap import DALS
 from .test_easy_install import make_nspkg_sdist
 
 import pytest
 
+
 def test_dist_fetch_build_egg(tmpdir):
     """
     Check multiple calls to `Distribution.fetch_build_egg` work as expected.
     """
     index = tmpdir.mkdir('index')
     index_url = urljoin('file://', pathname2url(str(index)))
+
     def sdist_with_index(distname, version):
         dist_dir = index.mkdir(distname)
         dist_sdist = '%s-%s.tar.gz' % (distname, version)
@@ -63,37 +69,47 @@ def __maintainer_test_cases():
 
     test_cases = [
         ('No author, no maintainer', attrs.copy()),
-        ('Author (no e-mail), no maintainer', merge_dicts(attrs,
+        ('Author (no e-mail), no maintainer', merge_dicts(
+            attrs,
             {'author': 'Author Name'})),
-        ('Author (e-mail), no maintainer', merge_dicts(attrs,
+        ('Author (e-mail), no maintainer', merge_dicts(
+            attrs,
             {'author': 'Author Name',
              'author_email': 'author@name.com'})),
-        ('No author, maintainer (no e-mail)', merge_dicts(attrs,
+        ('No author, maintainer (no e-mail)', merge_dicts(
+            attrs,
             {'maintainer': 'Maintainer Name'})),
-        ('No author, maintainer (e-mail)', merge_dicts(attrs,
+        ('No author, maintainer (e-mail)', merge_dicts(
+            attrs,
             {'maintainer': 'Maintainer Name',
              'maintainer_email': 'maintainer@name.com'})),
-        ('Author (no e-mail), Maintainer (no-email)', merge_dicts(attrs,
+        ('Author (no e-mail), Maintainer (no-email)', merge_dicts(
+            attrs,
             {'author': 'Author Name',
              'maintainer': 'Maintainer Name'})),
-        ('Author (e-mail), Maintainer (e-mail)', merge_dicts(attrs,
+        ('Author (e-mail), Maintainer (e-mail)', merge_dicts(
+            attrs,
             {'author': 'Author Name',
              'author_email': 'author@name.com',
              'maintainer': 'Maintainer Name',
              'maintainer_email': 'maintainer@name.com'})),
-        ('No author (e-mail), no maintainer (e-mail)', merge_dicts(attrs,
+        ('No author (e-mail), no maintainer (e-mail)', merge_dicts(
+            attrs,
             {'author_email': 'author@name.com',
              'maintainer_email': 'maintainer@name.com'})),
-        ('Author unicode', merge_dicts(attrs,
+        ('Author unicode', merge_dicts(
+            attrs,
             {'author': '鉄沢寛'})),
-        ('Maintainer unicode', merge_dicts(attrs,
+        ('Maintainer unicode', merge_dicts(
+            attrs,
             {'maintainer': 'Jan Łukasiewicz'})),
     ]
 
     return test_cases
 
+
 @pytest.mark.parametrize('name,attrs', __maintainer_test_cases())
-def test_maintainer_author(name, attrs):
+def test_maintainer_author(name, attrs, tmpdir):
     tested_keys = {
         'author': 'Author',
         'author_email': 'Author-email',
@@ -103,12 +119,17 @@ def test_maintainer_author(name, attrs):
 
     # Generate a PKG-INFO file
     dist = Distribution(attrs)
-    PKG_INFO = StringIO()
-    dist.metadata.write_pkg_file(PKG_INFO)
-    PKG_INFO.seek(0)
+    fn = tmpdir.mkdir('pkg_info')
+    fn_s = str(fn)
+
+    dist.metadata.write_pkg_info(fn_s)
+
+    with io.open(str(fn.join('PKG-INFO')), 'r', encoding='utf-8') as f:
+        raw_pkg_lines = f.readlines()
+
+    # Drop blank lines
+    pkg_lines = list(filter(None, raw_pkg_lines))
 
-    pkg_lines = PKG_INFO.readlines()
-    pkg_lines = [_ for _ in pkg_lines if _]   # Drop blank lines
     pkg_lines_set = set(pkg_lines)
 
     # Duplicate lines should not be generated
@@ -122,4 +143,3 @@ def test_maintainer_author(name, attrs):
         else:
             line = '%s: %s' % (fkey, val)
             assert line in pkg_lines_set
-