views:

65

answers:

3

For a package of mine, I have a README.rst file that is read into the setup.py's long description like so:

readme = open('README.rst', 'r')
README_TEXT = readme.read()
readme.close()

setup(
    ...
    long_description = README_TEXT,
    ....
    )

This way that I can have the README file show up on my github page every time I commit and on the pypi page every time I python setup.py register. There's only one problem. I'd like the github page to say something like "This document reflects a pre-release version of envbuilder. For the most recent release, see pypi."

I could just put those lines in README.rst and delete them before I python setup.py register, but I know that there's going to be a time that I forget to remove the sentences before I push to pypi.

I'm trying to think of the best way to automate this so I don't have to worry about it. Anyone have any ideas? Is there any setuptools/distutils magic I can do?

+1  A: 

You could always do this:

GITHUB_ALERT = 'This document reflects a pre-release version...'
readme = open('README.rst', 'r')
README_TEXT = readme.read().replace(GITHUB_ALERT, '')
readme.close()

setup(
    ...
    long_description = README_TEXT,
    ....
    )

But then you'd have to keep that GITHUB_ALERT string in sync with the actual wording of the README. Using a regular expression instead (to, say, match a line beginning with Note for Github Users: or something) might give you a little more flexibility.

Will McCutchen
Hadn't thought of doing it that way. I'll try it out.
Jason Baker
+4  A: 

Another option is to side-step the issue completely by adding a paragraph that works in both environments: "The latest unstable code is on github. The latest stable kits are on pypi."

After all, why assume that pypi people don't want to be pointed to github? This would be more helpful to both audiences, and simplifies your setup.py.

Ned Batchelder
There are instructions for installing both versions. It's not as much about pypi people not wanting to get pointed to github as it is about someone doing an `easy_install envbuilder`, then looking at the documentation on github (which would be for the development version) and wondering why it's not working. That said, I suppose I *can* be a bit more clear about where the stable and unstable versions are.
Jason Baker
+2  A: 

You can just use a ReST comment with some text like "split here", and then split on that in your setup.py. Ian Bicking does that in virtualenv with index.txt and setup.py.

Carl Meyer
This ended up being what I did. Thanks!
Jason Baker