19

I am new to distutils.. I am trying to include few data files along with the package.. here is my code..

from distutils.core import setup

setup(name='Scrapper',
      version='1.0',
      description='Scrapper',      
      packages=['app', 'db', 'model', 'util'],
      data_files=[('app', ['app/scrapper.db'])]      
     )

The zip file created after executing python setup.py sdist does not include the scrapper.db file. I have scrapper.db file in the app directory..

thanks for the help.

2
  • 2
    A remark unrelated to your question: I’d recommend you to use one top-level package name, for example scrapper, instead of using four very widely used names for four packages. Commented Aug 23, 2011 at 5:35
  • What python version are you using? Commented Apr 30, 2015 at 11:08

2 Answers 2

21

You probably need to add a MANIFEST.in file containing "include app/scrapper.db".

It's a bug in distutils that makes this necessary: anything in data_files or package_data should be included in the generated MANIFEST automatically. But in Python 2.6 and earlier, it is not, so you have to include it in MANIFEST.in.

The bug is fixed in Python 2.7.

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

2 Comments

I am still experiencing the same problem with Python 2.7.1+. I found this bug report but I don't understand why the status is committed/rejected. Any guidance on how to solve without falling back to using MANIFEST.in? Thanks!
The status committed/rejected is used with fixed bugs.
1

Try removing MANIFEST, that way distutils will be forced to regenerate it.

Note: I've been using python 3.x, so I don't know if this works with 2.x or not.

4 Comments

You misunderstood my answer. I do not recommend creating a MANIFEST file. I am talking about "MANIFEST.in", the manifest template file. This allows you to add to what's included in the automatically-generated MANIFEST. Because of a bug in distutils in all Python versions up to and including 2.6, data_files and package_data entries are not included in the automatically-generated MANIFEST unless you add them to a MANIFEST.in file.
@Carl Meyer I wasn't commenting on what you did or didn't say. I only wanted to reference an answer that went into more detail on that part (which wasn't my main point.) And I used MANIFEST generally; I probably should have written MANIFEST.in (I've since changed it.) Sorry if I misrepresented your answer.
Unfortunately, your edited answer is now simply incorrect :/ distutils generates a MANIFEST for you whether or not you provide MANIFEST.in. MANIFEST.in allows you to add to the contents of the generated MANIFEST file.
@Carl Meyer Alright. I went ahead and removed all the junk that wasn't relevant to what I was trying to convey. Hopefully I didn't mess something else up. Thanks.

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.