[Distutils] setuptools and data files

Phillip J. Eby pje at telecommunity.com
Sun Oct 1 23:01:30 CEST 2006


At 09:43 PM 9/30/2006 +0200, Walter Dörwald wrote:
>Hello Philip!
>
>I'm having trouble with using setuptools with data files. The layout of
>my directory is this:
>
>./src
>./src/CVS
>./src/CVS/Root
>./src/CVS/Repository
>./src/CVS/Entries
>./src/coverage.css
>./src/pycoco.py
>./CVS
>./CVS/Root
>./CVS/Repository
>./CVS/Entries
>./setup.cfg
>./installer.bmp
>./MANIFEST.in
>./setup.py
>
>MANIFEST.in contains the line:
>include src/coverage.css

Setuptools only includes data files that are inside a *package* (which is 
why it's called "package_data"), or inside the .egg-info directory 
(metadata files), as that's the only way to ensure the files are accessible 
in all possible installation configurations (egg zips, egg dirs, and 
"traditional" installs).



>My arguments to setup() look like this:
>
>   args = dict(
>      name="pycoco",
>      version="0.1",
>      description="Python code coverage",
>      long_description="...",
>      author=u"Walter Doerwald",
>      author_email="walter at livinglogic.de",
>      url="...",
>      download_url="...",
>      license="Python",
>      classifiers="...",
>      keywords="...",
>      package_dir={"": "src"},
>      py_modules=["pycoco"],
>      package_data={
>         "": ["*.css"],
>      }
>   )

For this configuration, I would suggest that you move the .css file to the 
package's .egg-info directory, and use this expression at runtime to 
retrieve the contents:

     data = 
pkg_resources.get_distribution('pycoco').get_metadata('coverage.css')



>However when I do an "easy_install -Z ." I get the following directory
>layout:
>
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/pycoco.py
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/pycoco.pyc
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO/PKG-INFO
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO/SOURCES.txt
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO/dependency_links.txt
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO/top_level.txt
>/var/home/coverage/pythonroot/pycoco-0.1-py2.5.egg/EGG-INFO/not-zip-safe
>
>with no coverage.css in sight. I'm using a ~/.pydistutils.cfg, which
>contains:
>
>[install]
>install_lib = ~/pythonroot
>
>I've also tried including the include_package_data=True argument, moved
>the CSS file out of the src directory, changes the include statement in
>MANIFEST.in to "include coverage.css" and various combination thereof
>always with the same result. I'm using setuptools 0.6c3.
>
>Am I doing something stupid?
>
>BTW, I've moved most of our Python packages to setuptools, and so far it
>really simplifies packages handling. The only remaining problem is
>setuptools+pyexe. So thanks for all your work on setuptools.
>
>Servus,
>    Walter



More information about the Distutils-SIG mailing list