If, like me, you regularly use Markdown to give your GitHub projects nice pretty README's, but are trying to submit your new swanky Python module to the Python Package Index, you may have hit a bit of a snag. To get your nicely formatted README on your module's PyPi page, you need to use reStructuredTxt. Now you could admit defeat and change your README, or you could do this:
Install pyandoc python module
pip install pyandoc
Create a file called register.py and add the following code:
import pandoc import os pandoc.core.PANDOC_PATH = '/path/to/pandoc' doc = pandoc.Document() doc.markdown = open('README.md').read() f = open('README.txt','w+') f.write(doc.rst) f.close() os.system("setup.py register") os.remove('README.txt')
Now add the following code to the top of your setup.py file:
import os long_description = 'Add a fallback short description here' if os.path.exists('README.txt'): long_description = open('README.txt').read()
and set the longdescription arg equal to `longdescription`
Now just register your module using
and your Pypi page should have it's own nicely formatted instructions.
Basically all your doing is creating a temporary reStructeredTxt file for setup.py to read in, but avoiding trying to do any pandoc conversion in setup.py like I originally had, which caused issues for installing on other systems.