diff options
-rw-r--r-- | changelog.d/2828.change.rst | 2 | ||||
-rw-r--r-- | setuptools/dist.py | 8 | ||||
-rw-r--r-- | setuptools/tests/test_egg_info.py | 21 |
3 files changed, 29 insertions, 2 deletions
diff --git a/changelog.d/2828.change.rst b/changelog.d/2828.change.rst new file mode 100644 index 00000000..9d607cbd --- /dev/null +++ b/changelog.d/2828.change.rst @@ -0,0 +1,2 @@ +Write long description in message payload of PKG-INFO file. +Changed in metadata version 2.1 diff --git a/setuptools/dist.py b/setuptools/dist.py index a1b7e832..71b31873 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -176,8 +176,9 @@ def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME for project_url in self.project_urls.items(): write_field('Project-URL', '%s, %s' % project_url) - long_desc = rfc822_escape(self.get_long_description()) - write_field('Description', long_desc) + if version < StrictVersion('2.1'): + long_desc = rfc822_escape(self.get_long_description()) + write_field('Description', long_desc) keywords = ','.join(self.get_keywords()) if keywords: @@ -207,6 +208,9 @@ def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME for extra in self.provides_extras: write_field('Provides-Extra', extra) + if version >= StrictVersion('2.1'): + file.write("\n%s\n\n" % self.get_long_description()) + sequence = tuple, list diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 0d595ad0..ba683d08 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -875,6 +875,27 @@ class TestEggInfo: assert expected_line in pkg_info_lines assert 'Metadata-Version: 2.1' in pkg_info_lines + def test_description(self, tmpdir_cwd, env): + self._setup_script_with_requires( + "long_description='This is a long description\\nover multiple lines',") + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + code, data = environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file: + pkg_info_lines = pkginfo_file.read().split('\n') + assert 'Metadata-Version: 2.1' in pkg_info_lines + assert '' == pkg_info_lines[-1] + long_desc_lines = pkg_info_lines[pkg_info_lines.index(''):] + assert 'This is a long description' in long_desc_lines + assert 'over multiple lines' in long_desc_lines + def test_project_urls(self, tmpdir_cwd, env): # Test that specifying a `project_urls` dict to the `setup` # function results in writing multiple `Project-URL` lines to |