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.

StackUnderflow
  • 24,080
  • 14
  • 54
  • 77
  • 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. – merwok Aug 23 '11 at 05:35
  • What python version are you using? – Omer Dagan Apr 30 '15 at 11:08

2 Answers2

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.

Zearin
  • 1,474
  • 2
  • 17
  • 36
Carl Meyer
  • 122,012
  • 20
  • 106
  • 116
  • 3
    I am still experiencing the same problem with Python 2.7.1+. I found [this bug report](http://bugs.python.org/issue2279) 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! – mac Aug 22 '11 at 00:10
  • 1
    The status committed/rejected is used with fixed bugs. – merwok Aug 23 '11 at 05:33
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.

Matthew
  • 393
  • 4
  • 9
  • 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 Jun 11 '10 at 01:03
  • @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. – Matthew Jun 11 '10 at 19:01
  • 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 Jun 11 '10 at 20:35
  • @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. – Matthew Jun 14 '10 at 22:47