From 16e452a42a3dbbb0ab3d3146ffa3b743cdca2539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 6 Mar 2019 15:22:28 +0100 Subject: Remove duplicate import io (#1713) Found by lgtm --- setuptools/dist.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index ddb1787a..6233d5dc 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -1103,7 +1103,6 @@ class Distribution(_Distribution): return _Distribution.handle_display_options(self, option_order) # Stdout may be StringIO (e.g. in tests) - import io if not isinstance(sys.stdout, io.TextIOWrapper): return _Distribution.handle_display_options(self, option_order) -- cgit v1.2.1 From c27c705f6a326e4820f1a34d6ce1db101dad3a30 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Sat, 16 Mar 2019 10:06:53 -0700 Subject: Fix typo in docstring (#1718) --- setuptools/dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index 6233d5dc..e6d08b92 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -885,7 +885,7 @@ class Distribution(_Distribution): def include(self, **attrs): """Add items to distribution that are named in keyword arguments - For example, 'dist.exclude(py_modules=["x"])' would add 'x' to + For example, 'dist.include(py_modules=["x"])' would add 'x' to the distribution's 'py_modules' attribute, if it was not already there. -- cgit v1.2.1 From 393809a02ed4d0f07faec5c1f23384233e6cd68e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 5 Apr 2019 09:27:23 -0400 Subject: Feed the hobgoblins (delint). --- setuptools/dist.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index e6d08b92..ae380290 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -11,7 +11,6 @@ import distutils.log import distutils.core import distutils.cmd import distutils.dist -from distutils.errors import DistutilsOptionError from distutils.util import strtobool from distutils.debug import DEBUG from distutils.fancy_getopt import translate_longopt @@ -135,7 +134,6 @@ def write_pkg_file(self, file): def write_field(key, value): file.write("%s: %s\n" % (key, value)) - write_field('Metadata-Version', str(version)) write_field('Name', self.get_name()) write_field('Version', self.get_version()) @@ -1281,4 +1279,5 @@ class Feature: class DistDeprecationWarning(SetuptoolsDeprecationWarning): - """Class for warning about deprecations in dist in setuptools. Not ignored by default, unlike DeprecationWarning.""" + """Class for warning about deprecations in dist in + setuptools. Not ignored by default, unlike DeprecationWarning.""" -- cgit v1.2.1 From 85fa4a6bc506be12fdbd0f4cff139e7c4e3bc6a8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 5 Apr 2019 10:04:50 -0400 Subject: When reading config files, require them to be encoded with UTF-8. Fixes #1702. --- setuptools/dist.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index ae380290..9a165de0 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -35,7 +35,6 @@ from setuptools.depends import Require from setuptools import windows_support from setuptools.monkey import get_unpatched from setuptools.config import parse_configuration -from .unicode_utils import detect_encoding import pkg_resources __import__('setuptools.extern.packaging.specifiers') @@ -587,13 +586,9 @@ class Distribution(_Distribution): parser = ConfigParser() for filename in filenames: - with io.open(filename, 'rb') as fp: - encoding = detect_encoding(fp) + with io.open(filename, encoding='utf-8') as reader: if DEBUG: - self.announce(" reading %s [%s]" % ( - filename, encoding or 'locale') - ) - reader = io.TextIOWrapper(fp, encoding=encoding) + self.announce(" reading {filename}".format(**locals())) (parser.read_file if six.PY3 else parser.readfp)(reader) for section in parser.sections(): options = parser.options(section) -- cgit v1.2.1 From 880ff4a3579bac7839f8f038085381ae14155f31 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Thu, 16 May 2019 12:46:50 +0200 Subject: Force metadata-version = 1.2 when project urls are present. Closes: #1756 --- setuptools/dist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index 9a165de0..ea6411b1 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -54,7 +54,8 @@ def get_metadata_version(self): mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or - getattr(self, 'python_requires', None) is not None): + getattr(self, 'python_requires', None) is not None or + self.project_urls): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): -- cgit v1.2.1 From 305bb1cefc3251c67b55149139a768ddf474f7b6 Mon Sep 17 00:00:00 2001 From: Daniel Himmelstein Date: Thu, 23 May 2019 14:15:19 -0400 Subject: fix assert_string_list docstring value=None raises TypeError DistutilsSetupError: 2 must be a list of strings (got None) --- setuptools/dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index ea6411b1..1e1b83be 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -213,7 +213,7 @@ def check_importable(dist, attr, value): def assert_string_list(dist, attr, value): - """Verify that value is a string list or None""" + """Verify that value is a string list""" try: assert ''.join(value) != value except (TypeError, ValueError, AttributeError, AssertionError): -- cgit v1.2.1 From 8f848bd777278fc8dcb42dc45751cd8b95ec2a02 Mon Sep 17 00:00:00 2001 From: Daniel Himmelstein Date: Wed, 22 May 2019 17:45:44 -0400 Subject: improve `package_data` check Ensure the dictionary values are lists/tuples of strings. Fix #1459. --- setuptools/dist.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'setuptools/dist.py') diff --git a/setuptools/dist.py b/setuptools/dist.py index 1e1b83be..f0f030b5 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -215,6 +215,10 @@ def check_importable(dist, attr, value): def assert_string_list(dist, attr, value): """Verify that value is a string list""" try: + # verify that value is a list or tuple to exclude unordered + # or single-use iterables + assert isinstance(value, (list, tuple)) + # verify that elements of value are strings assert ''.join(value) != value except (TypeError, ValueError, AttributeError, AssertionError): raise DistutilsSetupError( @@ -307,20 +311,17 @@ def check_test_suite(dist, attr, value): def check_package_data(dist, attr, value): """Verify that value is a dictionary of package names to glob lists""" - if isinstance(value, dict): - for k, v in value.items(): - if not isinstance(k, str): - break - try: - iter(v) - except TypeError: - break - else: - return - raise DistutilsSetupError( - attr + " must be a dictionary mapping package names to lists of " - "wildcard patterns" - ) + if not isinstance(value, dict): + raise DistutilsSetupError( + "{!r} must be a dictionary mapping package names to lists of " + "string wildcard patterns".format(attr)) + for k, v in value.items(): + if not isinstance(k, six.string_types): + raise DistutilsSetupError( + "keys of {!r} dict must be strings (got {!r})" + .format(attr, k) + ) + assert_string_list(dist, 'values of {!r} dict'.format(attr), v) def check_packages(dist, attr, value): -- cgit v1.2.1