warehouse: `long_description_content_type` flag in setup.py seems to be ignored on upload.

Describe the bug I have a python package on PyPi that just (as of the last ~4-5 days) now fails to upload, with a new error:

durr@rwpscrape /m/S/S/WebRequest> python3 setup.py sdist upload

[snip build process]

Submitting dist/WebRequest-0.0.28.tar.gz to https://upload.pypi.org/legacy/
Upload failed (400): The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.
error: Upload failed (400): The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.

Ok, that’s clear enough. My readme is in markdown, let’s see how to fix this.

Going to https://packaging.python.org/tutorials/packaging-projects/#description, it states you can add long_description_content_type="text/markdown", to your setup.py file, and it’ll be processed as markdown.

<does edits>....
<submits to PyPi again
Submitting dist/WebRequest-0.0.28.tar.gz to https://upload.pypi.org/legacy/

[snip build process]

Upload failed (400): The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.
error: Upload failed (400): The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.

What?

Expected behavior I expect if I specify the readme is markdown, as the documentation says to do so, the readme should be treated as markdown.

To Reproduce Attempt to upload a package with a readme that is valid markdown, but not valid reStructuredText.

My Platform

  • Python 3.5.2 x64
  • Ubuntu 16.04 LTS
  • setuptools-39.2.0 (I specifically checked that it’s the most current version)
  • readme_renderer 20.0

Actual project in question is here. The readme.md in question is here, and the setup.py is here

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 45 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I have setuptools upgraded to version 41.0.1 twine version 1.13.0 wheel version 0.33.4 and i am still getting this issue

We’re reverting this behavior in #4099, hang tight.

Still have the issue with latest packages installed: setuptools 41.0.1
twine 1.13.0
wheel 0.33.4

HTTPError: 400 Client Error: The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information. for url: https://upload.pypi.org/legacy/

Seems I can make it working by modifying the README.md a bit, which is change ```python Some code ```

to ```

some code ```

Hi @frmdstryr, it’s not possible to change anything about a published package – they are essentially immutable.

It’s likely that you have an out-of-date version of either twine, wheel or setuptools which cannot interpret this new metadata field. You can upgrade them all with:

$ pip install -U twine wheel setuptools

Once you do that, you can either increment the version number and make a new release, or make a post release to fix your description.

long_description_content_type works with twine, but seems to have no effect when using setuptools.

Works:

  • setup.py contains long_description_content_type='text/markdown',
  • setup.py bdist_wheel (sdist also works)
  • twine upload -r test dist/*

Does not work:

  • setup.py contains long_description_content_type='text/markdown',
  • setup.py bdist_wheel upload -r test

Pacakges:

pip==10.0.1
setuptools==39.2.0
twine==1.11.0
wheel==0.31.1

PyPI only renders rst(reStructuredText) file so if you have README.md then you have to convert into README.rst file after that you will be able to upload the file on PyPI.

Refer below site for install pandoc: [https://pandoc.org/installing.html]

run below command for convert file into .rst file python setup.py sdist pandoc --from=markdown --to=rst --output=README.rst README.md

check whether twine is able to render .rst file or not; twine check dist/*

Let me know if you encounter any other problems.

It works if your

setuptools is upgraded to version 38.6.0 or newer

twine is upgraded to version 1.11.0 or newer

wheel is upgraded to version 0.31.0 or newer

I think one good option would be to make readme-renderer more gracefully fail, see https://github.com/pypa/readme_renderer/issues/102

Having the same issue. I have all requirements updated:

$ pip install --upgrade setuptools wheel twine
Requirement already up-to-date: setuptools in c:\python27\lib\site-packages (39.2.0)
Requirement already up-to-date: wheel in c:\python27\lib\site-packages (0.31.1)
Requirement already up-to-date: twine in c:\python27\lib\site-packages (1.11.0)

setup.py:

from setuptools import setup

basedir = path.abspath(path.dirname(__file__))
with open(path.join(basedir, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    ...
    long_description=long_description,
    long_description_content_type='text/markdown',
    ...
)

PKG_INFO:

Metadata-Version: 2.1
...
Description: # Flask-CKEditor
...
Description-Content-Type: text/markdown

Here is the error output when upload:

$ twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading Flask_CKEditor-0.4-py2.py3-none-any.whl
100%|##########################################################################################################################################| 4.95M/4.95M [01:15<00:00, 22.7KB/s]
Uploading Flask-CKEditor-0.4.tar.gz
100%|##########################################################################################################################################| 3.70M/3.70M [00:55<00:00, 33.8KB/s]
HTTPError: 400 Client Error: The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information. fo
r url: https://upload.pypi.org/legacy/

Any idea? It seems that only the wheel file (.whl) can be uploaded successful.

You might try using the latest version of twine to handle the upload. Also, more metadata is available when you upload a wheel first, IIRC.

$ python setup.py sdist
$ pip install -U wheel
$ python setup.py bdist_wheel
$ twine upload dist/*whl dist/*gz