[Distutils] installing data files and headers

René Liebscher R.Liebscher@gmx.de
Mon Mar 3 03:23:01 2003


"A.M. Kuchling" schrieb:
> 
> On Fri, Feb 28, 2003 at 10:31:00AM -0500, Jeremy Hylton wrote:
> >Another problem we've been struggling with for Zope projects is that
> >distutils really only installs Python modules and extensions.  It's
> >support for data files and C header files is pretty limited.  We've got
> 
> Good idea.  We have a similar subclass for Quixote that installs *.ptl
> files, and it's a common need.
> 
> >installed, so that you don't install .py~ files.  One possibility is to
> >explicitly list the file extensions that constitute installable data.
> >We did that for Zope3, but the list of extensions ended up being fairly
> >long.
> 
> Well, what are the options?
> 
> 1) List extensions.
> 2) Explicitly list pathnames for additional files.
> 3) A MANIFEST.in-like mini-language for specifying which files should
>    be installed.
> 4) Automatically add things in package directories that
>    aren't obviously irrelevant (*~, *.pyc, CVS, .svn).
> 
> Any other ideas?
> 
> 4) probably offers too little control, and 3) might be too much, and
> adds yet another file to write.  What if both 1) and 2) were
> supported, say, like this:
> 
> setup(...
>       package_files=['zope/app/config.xml', 'zope/app/dtd.xml'],
>       package_patterns=['*.cfg'],
>      )
> 

In my opinion the third option is the best because it can be done
without much effort.
Look at pyxml or PYOpenGL for an example which uses one of my scripts I
wrote some time ago. 

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyxml/xml/setupext/install_data.py?rev=1.3&content-type=text/vnd.viewcvs-markup
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/setup.py?rev=1.54&content-type=text/vnd.viewcvs-markup
And its use in PyOpenGL setup.py:
...
           # Overridden command classes
           cmdclass = {
...
                                   # the next line is very important
                                   # because we use another format for
data_files
                                   'install_data': my_install_data},
            data_files = [Data_Files(
                           base_dir='install_lib',
                           copy_to = 'OpenGL',
                           strip_dirs = 1,
                           template=[
                                   # take the whole tree
                                   'graft OpenGL',
                                   'global-exclude *.py',
                                   'global-exclude Cvs/*',
                                   'global-exclude CVS/*',
                                   ],
                           preserve_path=1
                   )],
...

It replaces the install_data command, still accepts old parameter lists,
supports
MANIFEST like specification of files and directories, and allows paths
relative to
'install_lib', ...

So this might be a good start point to replace the distutils
install_data command.


Kind regards
Rene Liebscher