Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read README in setup.py

So, I want the long_description of my setup script to be the contents from my README.md file. But when I do this, the installation of the source distribution will fail since python setup.py sdist does not copy the readme file.

Is there a way to let distutils.core.setup() include the README.md file with the sdist command so that the installation will not fail?

I have tried a little workaround where I default to some shorter text when the README.md file is not available, but I actually do want that not only PyPi gets the contents of the readme file but also the user that installs the package.

like image 227
Niklas R Avatar asked Apr 19 '14 19:04

Niklas R


People also ask

What is a README file in Python?

README files can help your users understand your project and can be used to set your project’s description on PyPI. This guide helps you create a README in a PyPI-friendly format and include your README in your package so it appears on PyPI. README files for Python projects are often named README, README.txt, README.rst, or README.md.

How do I add a README file to my project?

It’s customary to save your README file in the root of your project, in the same directory as your setup.py file. To include your README’s contents as your package description, set your project’s Description and Description-Content-Type metadata, typically in your project’s setup.py file.

What is the best way to create a readme for PyPI?

This guide helps you create a README in a PyPI-friendly format and include your README in your package so it appears on PyPI. README files for Python projects are often named README, README.txt, README.rst, or README.md. For your README to display properly on PyPI, choose a markup language supported by PyPI.

How do I include a README in a package description?

To include your README’s contents as your package description, set your project’s Description and Description-Content-Type metadata, typically in your project’s setup.py file. For example, to set these values in a package’s setup.py file, use setup () ’s long_description and long_description_content_type.


1 Answers

To manually include files in a distribution do the following:

  1. set include_package_data = True

  2. Create a MANIFEST.in file that has a list of include <glob> lines for each file you want to include from the project root. You can use recursive-include <dirname> <glob> to include from sub-directories of the project root.

Unfortunately the documentation for this stuff is really fragmented and split across the Python distutils, setuptools, and old distribute docs so it can be hard to figure out what you need to do.

like image 62
Kevin Thibedeau Avatar answered Oct 16 '22 08:10

Kevin Thibedeau