Skip to content

Commit

Permalink
Add new long_description_content_type kwarg
Browse files Browse the repository at this point in the history
This is used to populate the new `Description-Content-Type` field.

`Description-Content-Type` is described at
pypa/packaging.python.org#258
  • Loading branch information
msabramo authored and di committed Jul 3, 2017
1 parent 6b95ab8 commit 85ab219
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def pypi_link(pkg_filename):
author="Python Packaging Authority",
author_email="[email protected]",
long_description=long_description,
long_description_content_type='text/x-rst; charset=UTF-8',
keywords="CPAN PyPI distutils eggs package management",
url="https://github.com/pypa/setuptools",
src_root=None,
Expand Down
4 changes: 4 additions & 0 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ def write_pkg_info(cmd, basename, filename):
metadata = cmd.distribution.metadata
metadata.version, oldver = cmd.egg_version, metadata.version
metadata.name, oldname = cmd.egg_name, metadata.name
metadata.long_description_content_type = getattr(
cmd.distribution,
'long_description_content_type'
)
try:
# write unescaped data to PKG-INFO, so older pkg_resources
# can still parse it
Expand Down
10 changes: 10 additions & 0 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def write_pkg_file(self, file):
if self.download_url:
file.write('Download-URL: %s\n' % self.download_url)

long_desc_content_type = getattr(
self,
'long_description_content_type',
None
) or 'UNKNOWN'
file.write('Description-Content-Type: %s\n' % long_desc_content_type)

long_desc = rfc822_escape(self.get_long_description())
file.write('Description: %s\n' % long_desc)

Expand Down Expand Up @@ -312,6 +319,9 @@ def __init__(self, attrs=None):
self.dist_files = []
self.src_root = attrs and attrs.pop("src_root", None)
self.patch_missing_pkg_info(attrs)
self.long_description_content_type = _attrs_dict.get(
'long_description_content_type'
)
# Make sure we have any eggs needed to interpret 'attrs'
if attrs is not None:
self.dependency_links = attrs.pop('dependency_links', [])
Expand Down

0 comments on commit 85ab219

Please sign in to comment.