Coding · development

Getting the setup.py long_description in reStructuredText from your Markdown README

I write my README files for Python/GitHub projects in Markdown, which is quite easy and convenient. But the PyPi guidelines for projects require a README.rst file in “reStructuredText”. The setup.py file also has a field for a “long description”, which will get inserted on the Pypi project page,  see for example this one for NanoPlot.

UPDATE: TURNS OUT THIS WAS A REALLY BAD IDEA
By modifying the setup.py as I did I required all system to have pypandoc installed, to enable them to install my packages. So installations would fail without pypandoc installed. I just modified all my setup.py files 🙂

To avoid having to keep README.rst and README.md in sync I searched a bit online and found a convenient solution: pypandoc for converting the README.md on the fly to an rst format, as shown below with code which goes in your setup.py:

The full setup.py from NanoPlot is shown below. If yo u have suggestions for improvement I would be happy to hear them!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s