Special case long_description_content_type

As described in the pypa pull request, special-case passing through
these fields into the metadata.  setuptools will maintain them.

Change-Id: I89eb8c6d627790680a61a0a4b7490191b6e8e90c
Closes-Bug: #1762494
This commit is contained in:
Ian Wienand 2018-04-30 19:32:01 +10:00 committed by Stephen Finucane
parent f14a3b2b73
commit 77e75e25e3
3 changed files with 22 additions and 0 deletions

View File

@ -181,6 +181,10 @@ probably a good long_description. So we'll just inject the contents of your
You can also specify the exact file you want to use using the
``description-file`` parameter.
You can set the ``description-content-type`` to a MIME type that may
help rendering of the description; for example ``text/markdown`` or
``text/x-rst; charset=UTF-8``.
Requirements
~~~~~~~~~~~~

View File

@ -103,6 +103,16 @@ def pbr(dist, attr, value):
raise errors.DistutilsSetupError(
'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))
# There are some metadata fields that are only supported by
# setuptools and not distutils, and hence are not in
# dist.metadata. We are OK to write these in. For gory details
# see
# https://github.com/pypa/setuptools/pull/1343
_DISTUTILS_UNSUPPORTED_METADATA = (
'long_description_content_type', 'project_urls', 'provides_extras'
)
# Repeat some of the Distribution initialization code with the newly
# provided attrs
if attrs:
@ -115,6 +125,8 @@ def pbr(dist, attr, value):
setattr(dist.metadata, key, val)
elif hasattr(dist, key):
setattr(dist, key, val)
elif key in _DISTUTILS_UNSUPPORTED_METADATA:
setattr(dist.metadata, key, val)
else:
msg = 'Unknown distribution option: %s' % repr(key)
warnings.warn(msg)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
The ``description-content-type`` was not being set correctly. It
will now be correctly populated when using ``setuptools`` 39.2.0
and beyond.