[Distutils] Data files with setuptools

P.J. Eby pje at telecommunity.com
Mon Jul 27 20:17:12 CEST 2009


At 11:36 AM 7/27/2009 -0500, Robert Kern wrote:
>On 2009-07-27 11:29, Adeel Ahmad Khan wrote:
>>>The README is not "package data" because it's not inside a package.  You
>>>can't install package data in a project that only includes modules.  In any
>>>case, there's no point in shipping documentation inside an egg, because only
>>>your project's *code* will be able to read it, not humans.  Human-readable
>>>documentation only belongs in a source distribution.
>>
>>I'm writing a command-line program and I was using the README to print
>>help.  Should I just copy the README into my module then or is there a
>>better way?
>
>Most likely, the README and the help text should be different. 
>READMEs need information like how to install the program. Help text does not.

However, if you do need some sort of data files included with your 
code, it's simplest to use a package, i.e. a subdirectory with an 
__init__.py.  If you use 'include_package_data=True' with setuptools 
(and the data files are under revision control), they will be 
included at install time, and accessible using 
pkg_resources.resource_string() etc.

Alternately, you can use the package_data option to specify data 
files to be included from your package directories; this works 
without setuptools (on Python 2.4 and up) and does not require 
revision control.



More information about the Distutils-SIG mailing list