Repository: encode/django-rest-framework

Issue:
long_description renders improperly on PyPI
## Steps to reproduce

View https://pypi.python.org/pypi/djangorestframework/3.3.3 on PyPI.
## Expected behavior

Rendered HTML that includes links, headings, and the like.
## Actual behavior

Raw reST markup appears in a non-monospace font.

I looked at the `setup.py` and observed that the project does not actually use the `long_description` field. I think PyPI is trying to convert the `README.md` to reST and failing. Since PyPI does not support Markdown (see https://bitbucket.org/pypa/pypi/issues/148/support-markdown-for-readmes), maybe an explicit `long_description` directing users to the proper documentation would be appropriate.



Discussion:
pandoc has been configured to provide a long desc which should override the README.md.
We need to investigate why this didn't work for 3.3.3.

I'll add that this is not unique for 3.3.3. The issue goes back to 3.1.2. Prior to that, it appears that the README content was not included in the `long_description`. Unless something has changed about PyPI rendering of the `long_description`, maybe this never worked properly. _shrug_

Should I be reporting this somewhere else? I'm new to reporting issues for this project. It seems like this is a valid issue so I'm unclear on why it is closed. Is there some further action I can take to help this get fixed?

This issue is already reported as #3817

Cool, thanks for clarifying!

Sorry to dig this up but it seems that the Readme is - again - not rendered properly: https://pypi.org/project/djangorestframework/

`setup.py` looks good though... Really odd.

@xordoquy 
Hmm. OK. Something has gone wrong there. Thanks for the report. I’ll look into it next week. 
Also, `twine check dist/*` passes on master and the 3.9.3 tag. Note that the last working readme render was 3.9.0
The diff between https://github.com/encode/django-rest-framework/compare/3.9.0...3.9.1 doesn't point out anything obvious as to why this would fail. I've also successfully rendered the readme locally (using the snippet from https://github.com/pypa/readme_renderer/issues/117), so it's not clear to me why this is failing on PyPI.
Ah, finally figured it out. A lot of additional info in https://github.com/pypa/twine/issues/425, but the short version is that we were using an outdated `wheel` v0.30.0 to create the distributions, which doesn't support metadata 2.1 and the `long_description_content_type` option. 

The fix is to ensure we run `twine check dist/*` to the publish command, which will complain when the readme is malformed. e.g., here's the output when wheel v0.30.0 is used:
```
Checking distribution dist/djangorestframework-3.9.3-py3-none-any.whl: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Failed
The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 73: Warning: Definition list ends without a blank line; unexpected unindent.
Checking distribution dist/djangorestframework-3.9.3.tar.gz: Passed
```

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -56,6 +56,10 @@ def get_version(package):
         print("twine not installed.\nUse `pip install twine`.\nExiting.")
         sys.exit()
     os.system("python setup.py sdist bdist_wheel")
+    if os.system("twine check dist/*"):
+        print("twine check failed. Packages might be outdated.")
+        print("Try using `pip install -U twine wheel`.\nExiting.")
+        sys.exit()
     os.system("twine upload dist/*")
     print("You probably want to also tag the version now:")
     print("  git tag -a %s -m 'version %s'" % (version, version))


Test patch: