warehouse: HTTPError: 400 Client Error: The description failed to render in the default format of reStructuredText

Related: https://github.com/pypa/warehouse/issues/5855 The description failed to render in the default format of reStructuredText

$ rm -rf ./dist && python3 setup.py sdist && twine upload dist/*
running sdist
running check
F:\Python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

writing manifest file 'MANIFEST'
creating fastfilepackage-1.0.6
creating fastfilepackage-1.0.6\source
creating fastfilepackage-1.0.6\source\cppimplementation
creating fastfilepackage-1.0.6\source\fastfilepackage
making hard links in fastfilepackage-1.0.6...
hard linking LICENSE.txt -> fastfilepackage-1.0.6
hard linking README -> fastfilepackage-1.0.6
hard linking README.md -> fastfilepackage-1.0.6
hard linking setup.cfg -> fastfilepackage-1.0.6
hard linking setup.py -> fastfilepackage-1.0.6
hard linking source/cppimplementation\fastfile.cpp -> fastfilepackage-1.0.6\source/cppimplementation
hard linking source/cppimplementation\fastfilewrapper.cpp -> fastfilepackage-1.0.6\source/cppimplementation
hard linking source\fastfilepackage\__init__.py -> fastfilepackage-1.0.6\source\fastfilepackage
hard linking source\fastfilepackage\version.py -> fastfilepackage-1.0.6\source\fastfilepackage
creating dist
Creating tar archive
removing 'fastfilepackage-1.0.6' (and everything under it)
Enter your username: addons_zz
Uploading distributions to https://upload.pypi.org/legacy/
Uploading fastfilepackage-1.0.6.tar.gz
100%|##########| 19.4k/19.4k [00:01<00:00, 16.1kB/s]
NOTE: Try --verbose to see response content.
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/

Contents of fastfilepackage-1.0.6.tar.gz:

  1. image
  2. image

i.e., README.md is present on the package file and its contents are just simple markdown.

$ pip list
Package                  Version    
------------------------ ---------- 
twine                    1.13.0
setuptools               41.0.1
wheel                    0.33.4
...

I only manage to upload the package by commenting out these 2 lines:

        # long_description = readme_contents,
        # long_description_content_type='text/markdown',

https://github.com/evandrocoan/fastfilepackage/blob/master/setup.py

Then, I was able to upload things successfully:

$ rm -rf ./dist && python3 setup.py sdist && twine upload dist/*
running sdist
running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

warning: sdist: standard file not found: should have one of README, README.txt, README.rst

writing manifest file 'MANIFEST'
creating fastfilepackage-1.0.6
creating fastfilepackage-1.0.6\source
creating fastfilepackage-1.0.6\source\cppimplementation
creating fastfilepackage-1.0.6\source\fastfilepackage
making hard links in fastfilepackage-1.0.6...
hard linking LICENSE.txt -> fastfilepackage-1.0.6
hard linking README.md -> fastfilepackage-1.0.6
hard linking setup.cfg -> fastfilepackage-1.0.6
hard linking setup.py -> fastfilepackage-1.0.6
hard linking source/cppimplementation\fastfile.cpp -> fastfilepackage-1.0.6\source/cppimplementation
hard linking source/cppimplementation\fastfilewrapper.cpp -> fastfilepackage-1.0.6\source/cppimplementation
hard linking source\fastfilepackage\__init__.py -> fastfilepackage-1.0.6\source\fastfilepackage
hard linking source\fastfilepackage\version.py -> fastfilepackage-1.0.6\source\fastfilepackage
creating dist
Creating tar archive
removing 'fastfilepackage-1.0.6' (and everything under it)
Enter your username: addons_zz
Uploading distributions to https://upload.pypi.org/legacy/
Uploading fastfilepackage-1.0.6.tar.gz
100%|##########| 17.3k/17.3k [00:03<00:00, 5.78kB/s]

If I replace distutils.core.setup by setuptools.setup everything works fine without having to remove the long_description and long_description_content_type lines. But I use distutils.core.setup instead of setuptools.setup in my project because I do not know how to build Python C API with setuptools.setup. Everywhere I look on internet just tells me how to build Python C Extensions with distutils.core.setup. No one ever uses setuptools.setup.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Folks arriving at this issue: The cause is that in #5835 we merged a change which blocks uploads that have an invalid long_description that we won’t be able to render. This is intentional and not a bug.

Before, the behavior was that if the reStructuredText or metadata was invalid, we would just fall back to a plaintext. Now, to prevent unrendered descriptions on PyPI, we just block the upload instead.

Depending on what format you’re using for your long_description, there’s two solutions here:

If you’re using a reStructuredText long_description:

Your long_description is invalid and will not render. You should upgrade twine:

$ pip install -U twine

And then check your distributions for invalid markup:

$ twine check dist/*

And fix the errors that it reports.

If you’re using a Markdown long_description:

The metadata for your distribution is invalid and is not specifying Markdown.

This means that either you haven’t set long_description_content_type='text/markdown', in your setup.py file, or that the tools that you’re using are out of date and don’t support this metadata field. Upgrade them to latest:

$ pip install -U twine wheel setuptools

Remove previous distributions:

$ rm -rf dist

Rebuild your distributions:

$ python setup.py sdist
$ python setup.py bdist_wheel

Check that the distributions are valid:

$ twine check dist/*

I was also having this problem suddenly, even though my setup.py and README.rst have not changed since the last successful deploy.

I am using the travis-ci PyPI deploy feature.

In my case, the extended error was as follows (as produced by twine check)

The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 220: Warning: Cannot analyze code. No Pygments lexer found for "guess".
line 220: Warning: Cannot analyze code. No Pygments lexer found for "guess".

Which was odd because this previously worked… and is accepted by sphinx/rtd. Simply removing the specification let the upload work.

Related: spyoungtech/behave-webdriver#77