开发者

How can I make this long_description and README differ by a couple of sentences?

开发者 https://www.devze.com 2022-12-17 21:25 出处:网络
For a package of mine, I have a README.rst file that is read into the setup.py\'s long description like so:

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 = R开发者_StackOverflowEADME_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?


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号