When registering a package on PyPI, README.md is used as a descriptive text unless otherwise specified. However, since it is not rendered in Markdown format, ugly sentences will be displayed as shown below.
This description is rendered in reStructuredText format. Therefore, the method of generating README.rst from README.md and setting it as an explanation is described as a memorandum.
If you manage the code base with GitHub etc., README.md is considered to be prepared, so Convert this Markdown text to reStructuredText format.
Use Pandoc for conversion.
$ pandoc --from markdown --to rst README.md -o README.rst
Pandoc can be installed with brew.
$ brew install pandoc
If both README.md and README.rst are included in the package Since README.md has priority, set up README.rst to be used as a descriptive text in setup.py.
Specifically, pass the contents of README.rst to the long_description keyword argument of the setup
function.
setup.py
from os import path
from setuptools import setup, find_packages
def read(fname):
return open(path.join(path.dirname(__file__), fname)).read()
setup(
long_description=read("README.rst"),
... #Other items omitted
)
If you register the package by the above procedure, it will be rendered safely as shown below.
Recommended Posts