Skip to content

Commit

Permalink
WIP: Add new long_description_content_type kwarg
Browse files Browse the repository at this point in the history
This is used to populate the newly proposed `Description-Content-Type`
field, that is proposed in
pypa/packaging.python.org#258.
  • Loading branch information
msabramo committed Jul 30, 2016
1 parent 7cb842e commit b6fd44c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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 @@ -397,6 +397,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
8 changes: 8 additions & 0 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def write_pkg_file(self, file):
if self.download_url:
file.write('Download-URL: %s\n' % self.download_url)

file.write(
'Description-Content-Type: %s\n'
% (self.long_description_content_type or "UNKNOWN")
)

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

Expand Down Expand Up @@ -340,6 +345,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 b6fd44c

Please sign in to comment.