views:

173

answers:

2

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.

+3  A: 

You probably need to add a MANIFEST.in file containing "include app/scrapper.db". It's a bug in distutils that this is 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.

Carl Meyer
+1  A: 

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
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
@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
@Matthew 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
@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