From 13e8c8e7216ff52b92d9ba51125b939c021e26d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 10 Sep 2011 01:51:40 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20determination=20of=20Metadata=20version?= =?UTF-8?q?=20(#8933).=20=20Patch=20by=20Filip=20Gruszczy=C5=84ski.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/distutils/dist.py | 3 ++- Lib/distutils/tests/test_dist.py | 14 ++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 8ca5b6f4f12..69825f206f2 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -1018,7 +1018,8 @@ class DistributionMetadata: """Write the PKG-INFO format data to a file object. """ version = '1.0' - if self.provides or self.requires or self.obsoletes: + if (self.provides or self.requires or self.obsoletes or + self.classifiers or self.download_url): version = '1.1' file.write('Metadata-Version: %s\n' % version) diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py index 7050cbed260..8aaae88cae5 100644 --- a/Lib/distutils/tests/test_dist.py +++ b/Lib/distutils/tests/test_dist.py @@ -244,6 +244,20 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, "version": "1.0", "obsoletes": ["my.pkg (splat)"]}) + def test_classifier(self): + attrs = {'name': 'Boa', 'version': '3.0', + 'classifiers': ['Programming Language :: Python :: 3']} + dist = Distribution(attrs) + meta = self.format_metadata(dist) + self.assertIn('Metadata-Version: 1.1', meta) + + def test_download_url(self): + attrs = {'name': 'Boa', 'version': '3.0', + 'download_url': 'http://example.org/boa'} + dist = Distribution(attrs) + meta = self.format_metadata(dist) + self.assertIn('Metadata-Version: 1.1', meta) + def test_long_description(self): long_desc = textwrap.dedent("""\ example:: diff --git a/Misc/NEWS b/Misc/NEWS index 401e0225d5f..12ac26eb245 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -25,6 +25,10 @@ Core and Builtins Library ------- +- Issue #8933: distutils' PKG-INFO files will now correctly report + Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is + present. + - Issue #9561: distutils now reads and writes egg-info files using UTF-8, instead of the locale encoding.