37

Python packaging tools expect that our readme file should be named README or README.txt. But if we follow this convention, GitHub displays it as plain text in the project page which is not pretty. (unlike the beautiful HTML version when named as README.rst)

Is there any technique to make both PyPI and GitHub happy about README.

  • 1
    PyPI does *not* expect the file to be named README or README.txt. I don't know what Python packaging tools you mean, but I don't know of any that requires this naming, and if it does it can likely be easily fixed. – Lennart Regebro Apr 24 '11 at 08:00
  • 4
    Lennart, when I run `setup.py sdist` without a README, it says `warning: sdist: standard file not found: should have one of README, README.txt`... but I guess this is just complaint I can ignore? – rescdsk Jul 26 '11 at 19:45
  • 1
    @rescdsk: Yes, you can ignore it. AFAIK there is nothing that uses that. In fact, that should really be submitted as a bug report. – Lennart Regebro Aug 11 '11 at 07:04
  • 1
    http://bugs.python.org/issue11913 – rescdsk Aug 26 '11 at 20:56
  • 2
    If you would like PyPI to support readmes in Markdown, please comment on the feature request at http://bitbucket.org/pypa/pypi/issue/148/support-markdown-for-readmes – Colonel Panic Jun 13 '14 at 22:53

5 Answers5

27

PyPI has no requirement that the file is called README or README.txt, so just call it README.rst. In fact, PyPI will not as far as I'm aware look in your package at all (although I could be wrong there, I haven't studied the code or anything), the text that ends up ion the front is the long_description parameter.

Then in your setup.py, you do something like this:

setup(name='Your module name',
      version="1.0",
      description="Whatever, dude.",
      long_description=open('docs/README.rst', 'rt').read()
)
Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
  • 3
    Lennart is right. PyPI can parse reST in long_description, it does not use README. The warning is just a warning; name your file README or ignore the warning. packaging/distutils2 is smarter; see the bug report for more info. – merwok Sep 19 '11 at 15:11
11

A crude way I can think of is to make a symlink to README called README.rst and check them both in.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
8

You could use a git filter driver which would, on checkout, take your README.md (needed by GitHub) and generate a proper README (needed by Python, although Lennart Regebro's answer suggests that PyPI does not require any README file)

So, keeping aside the fact that PyPI doesn't need a README (and the warning could be simply ignored), here is how you could (in general) generate the expected file with Git:

smudge clean process

However, any modification to that private file README would need to be reported manually to the README.md file (at least because of markdown syntax which no script can guess for you)

That is why Noufal Ibrahim's answer (which I upvoted) might be more adapted, especially if you have access to symlinks (I am still with Windows Xp at work, so no luck for me):

Having make README being a symlink to README.rst, or, as Arto Bendiken comments:
=> having README.rst being a symlink ro README.

Git will store the symlink (and not the file the symlink refers to), so you can have both README and its README.rst file in your Git repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
5

Quoting Éric Araujo at the Python bug about the distutils warning:

In packaging/distutils2, the recommended idiom looks like this (in setup.cfg):

[metadata]
description-file = README.whatever

sdist will include that file. You can also write the description in the setup.cfg directly and have your README file included with the extra_files field.

So, basically, ignore the warning from distutils about a missing README.txt. Also, distutils2 supposedly does not emit this warning (I haven't tested), so you could try upgrading.

rescdsk
  • 8,739
  • 4
  • 36
  • 32
1

In older (non-distutils2) setups, you can add your README.rst to the MANIFEST.in file explicitly. You'll still see a warning about the standard README{.txt} being absent, but your README.rst will be included in your sdist tarball, meaning it will be included for end-users who download directly from PIPY.

See http://docs.python.org/2/distutils/sourcedist.html#the-manifest-in-template for more details.

Jake Biesinger
  • 5,538
  • 2
  • 23
  • 25