Friday, January 8, 2010

Testing the layout for python egg's README.txt file

Before uploading an egg, i like to test the layout of the egg to see if it is correct ReST, so it shows up nicely on the plone.org/products page and pypi.python.org.

$ python setup.py --long-description | rst2html > description.html

This is assuming that you create the long-description in your setup.py by reading the README.txt. My setup.py usually contains something like this:
version = '1.0'

setup(name='Products.MyProduct',
version=version,
description="Some description about what this does, who might use it etc.",
long_description="\n\n".join([
open(os.path.join("README.txt")).read(),
open(os.path.join("docs", "NEWS.txt")).read(),
open(os.path.join("docs", "TODO.txt")).read(),
]),
...)

The "\n\n".join() bit is used to make sure there's enough separation between chapters (from the various files), because otherwise you could remove a line which would result in invalid ReST.

No comments: