Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My RST README is not formatted correctly on PyPi

I uploaded a package to pypi.org but my RST README isn't formatted correctly.

This is what it looks like on GitHub: https://github.com/NinjaSnail1080/akinator.py

This is what it looks like on PyPi: https://pypi.org/project/akinator.py/

For some reason, on GitHub everything is formatted correctly, but on PyPi, it isn't formatted at all. Instead of showing the README formatted in RST, it's just a complete mess of unformatted text.

I tried running python3 -m twine check dist/* on my project and got this:

Checking distribution dist/akinator.py-1.0.3.dev3-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 26: Error: Unexpected indentation.
Checking distribution dist/akinator.py-1.0.3.dev3.tar.gz: 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 26: Error: Unexpected indentation.
line 26: Error: Unexpected indentation.

For some reason, it says the long_description_content_type is missing, which is untrue. My setup.py file specifically says long_description_content_type="text/x-rst". It also mentions unexpected indentations in line 26 of the long description, but there are no indentations at all in that line.

I have absolutely no idea what I did wrong here. Somehow, it looks perfectly fine on GitHub, but on PyPi, it's just a mess. And the warnings that twine check gave me don't make any sense.

like image 264
NinjaSnail1080 Avatar asked Mar 29 '19 17:03

NinjaSnail1080


People also ask

When creating a Python package What is the purpose of a readme MD or readme RST file?

README files can help your users understand your project and can be used to set your project's description on PyPI.

How do I create a readme file in Python?

Create a new file from — →file →new file. Save the file as Readme.md or any suitable name with . md extension. Your file is created.

What is a readme file in Python?

In simple words, we can describe a README file as a guide that gives users a detailed description of a project you have worked on. It can also be described as documentation with guidelines on how to use a project. Usually it will have instructions on how to install and run the project.


1 Answers

The issue is that you're including your entire license in the License field, but this field is only supposed to be a short description or name of the license -- it should not contain newlines.

This is producing the following metadata:

Metadata-Version: 2.1
Name: akinator.py
Version: 1.0.3.dev2
Summary: An API wrapper for the online game, Akinator, written in Python
Home-page: https://github.com/NinjaSnail1080/akinator.py
Author: NinjaSnail1080
Author-email: [email protected]
License: MIT License

Copyright (c) 2019 NinjaSnail1080

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

Where everything after the first newline is interpreted as the Long-Description.

To fix this, just set license="MIT", or omit it entirely -- it's optional, and you already have it in your list of classifiers.

There is an outstanding bug to fix this in setuptools here: https://github.com/pypa/setuptools/issues/1390

like image 63
Dustin Ingram Avatar answered Sep 20 '22 01:09

Dustin Ingram