9

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.

1 Answer 1

9

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.

Sign up to request clarification or add additional context in comments.

4 Comments

that worked for me too though I just used point 2 (point 1 seems redundant)
The doc is not fragmented anymore if you use setuptools, which is the defacto packaging standard right now. See here: pythonhosted.org//setuptools/…
@Marconius moved to here: setuptools.readthedocs.io/en/latest/…
I would recommend ignoring 1. as it would include .pyc files too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.