README files can help your users understand your project and can be used to set your project’s description on PyPI.This guide helps you create a README in a PyPI-friendly format and include your README in your package so it appears on PyPI.
Creating a README file¶
This guide helps you create a README in a PyPI-friendly format and include your README in your package so it appears on PyPI. Creating a README file¶ README files for Python projects are often named README, README.txt, README.rst, or README.md. For your README to display properly on PyPI, choose a markup language supported by PyPI. Just like HTML or LaTeX, Markdown is a markup language. In contrast to these examples, however, Markdown aims to be as easy as possible for people to read. Each markup element is closely related to the actual meaning, rather than being abstract. The HyperText Markup Language is an application conforming to International Standard ISO 8879 - Standard Generalized Markup Language SGML. A Markdown file on its own is just code. In fact, it’s called a markup language. To view the document the way the Markdown formatting intended, it has to be in HTML. If you have a static website, sometimes it is quicker to write a web page using Markdown. Then, convert your Markdown page to HTML, which you can upload to your website.
README files for Python projects are often named README
, README.txt
, README.rst
, or README.md
.
For your README to display properly on PyPI, choose a markup language supported by PyPI.Formats supported by PyPI’s README renderer are:
plain text
reStructuredText (without Sphinx extensions)
Markdown (GitHub Flavored Markdown by default,or CommonMark)
It’s customary to save your README file in the root of your project, in the same directory as your setup.py
file.
Including your README in your package’s metadata¶
To include your README’s contents as your package description,set your project’s Description
and Description-Content-Type
metadata,typically in your project’s setup.py
file.
For example, to set these values in a package’s setup.py
file,use setup()
’s long_description
and long_description_content_type
.
Readme Markup Languages
Set the value of long_description
to the contents (not the path) of the README file itself.Set the long_description_content_type
to an accepted Content-Type
-style value for your README file’s markup,such as text/plain
, text/x-rst
(for reStructuredText), or text/markdown
.
Note
If you’re using GitHub-flavored Markdown to write a project’s description, ensure you upgradethe following tools:
The minimum required versions of the respective tools are:
setuptools>=38.6.0
wheel>=0.31.0
twine>=1.11.0
It’s recommended that you use twine
to upload the project’s distribution packages:
For example, see this setup.py
file,which reads the contents of README.md
as long_description
and identifies the markup as GitHub-flavored Markdown:
Readme Markup Language Translator
Validating reStructuredText markup¶
If your README is written in reStructuredText, any invalid markup will preventit from rendering, causing PyPI to instead just show the README’s raw source.
Git Readme Markup
Note that Sphinx extensions used in docstrings, such asdirectives and roles(e.g., “:py:func:`getattr`
” or “:ref:`my-reference-label`
”), are not allowed here and will result in errormessages like “Error:Unknowninterpretedtextrole'py:func'.
”.
Bitbucket Readme Markup Language
Github Readme Markup Cheat Sheet
You can check your README for markup errors before uploading as follows:
Readme Markup List
Install the latest version of twine;version 1.12.0 or higher is required:
Build the sdist and wheel for your project as described underPackaging your project.
Run
twinecheck
on the sdist and wheel:This command will report any problems rendering your README. If your markuprenders fine, the command will output
CheckingdistributionFILENAME:Passed
.