Use Markdown document on brand new PyPI

Aki Ariga
2 min readApr 17, 2018

Yesterday, PyPI was renewed to the next-generation site. It is modern and stylish one.

@aodag told me that PEP 566, which was accepted Feb. 2018, allows us for a document on PyPI to use not only reStructuredText but also other formats such as Markdown.

So I enabled my Markdown document on brand-new PyPI.

Upgrade Python packages (if necessary)

We can use Markdown with setuptools as of v.38.6.0. Let’s upgrade you python packages if needed. Without that, Markdown description will not be rendered appropriately.

$ python -m pip install --upgrade pip
$ pip install --upgrade wheel
$ pip --version
pip 10.0.0 from c:\users\chezo\documents\source\tabula-py\venv\lib\site-packages\pip (python 3.6)
$ pip list
Package Version Location
----------------- ----------- --------------------------------------
(...snip...)
setuptools 38.1.0
(...snip...)
wheel 0.31.0

Modify setup.py

If you’ve already used README.md as a long description on PyPI, all you have to do is to add long_description_content_type to setup.py as follows:

long_description=open('README.md').read(),
long_description_content_type=”text/markdown”,

You can see the full description of the PR :

Build a wheel and upload with twine

Now, you can build a wheel and upload with twine.

$ python setup.py bdist_wheel
$ twine upload dist/*
The Markdown document was rendered!

CAVEAT: I didn’t upgrade PyPI because it is too much to bump up for just rendering Markdown. I tested on test.pypi.org.

References

--

--

Aki Ariga

ML Engineer at Arm Treasure Data. Previously Cloudera. Love machine learning, data analysis, Ruby and Python.