[Zope3-dev] Re: More thoughts on packaging

Phillip J. Eby pje at telecommunity.com
Mon Feb 16 22:29:51 EST 2004


At 12:28 PM 2/17/04 +1100, Richard Jones wrote:
>On 17/02/2004, at 9:05 AM, Jeremy Hylton wrote:
>>On Mon, 2004-02-16 at 11:20, Tres Seaver wrote:
>>>    - Make it trivial to include "data" (e.g., page template files,
>>>      images, ZCML, documentation) along with code (distutils is
>>>      pathetic in its handling of "data");
>>
>>There's widespread agreement on this point.  I think it would be fairly
>>straightforward to write a patch for distutils for 2.4 to make it handle
>>data usefully.
>
>It has a data_files option (see section 3.5 of the distutils manual) which 
>lists data files to install in subdirs of the install prefix. So in 
>Roundup, I specify things like:
>
>     ('share/roundup/cgi-bin', ['cgi-bin/roundup.cgi'])
>
>and
>
>     ('man/man1', ['doc/roundup-admin.1',
>             'doc/roundup-mailgw.1', 'doc/roundup-server.1'])
>
>Or were you thinking of something else?

Data files that need to be installed *in* the package directory, ala 
ZConfig 'component.xml' files.

Personally, I use the following subclass of install_data:


class install_data(install_data):

     """Variant of 'install_data' that installs data to module directories"""

     def finalize_options (self):
         self.set_undefined_options('install',
                                    ('install_lib', 'install_dir'),
                                    ('root', 'root'),
                                    ('force', 'force'),
                                   )


This causes the data files to be installed relative to site_packages, which 
is a bit easier to manage.  There is no way that I know of to use an 
unmodified distutils and still specify platform-independent paths to data 
files for installation.

There probably needs to be a different way to address this than the one I'm 
using, though, because changing install_data to do what I do would clearly 
break yours and other people's code who are using install_data to install 
non-package files.

One possible way to address it would be a function that would generate the 
data that the current install_data command expects, but in a way that's 
sensitive to the directory layout of the platform.  Or, maybe install_data 
could handle interpolation in the target paths, e.g.:

('$LIBDIR/some/package', ['src/some/package/somedata.xml'])

or the more Pythonic:

('%(LIBDIR)s/some/package', ['src/some/package/somedata.xml'])




More information about the Zope3-dev mailing list