[Distutils] distlib and data files => resources ?

Tarek Ziadé tarek at ziade.org
Sun Nov 18 22:36:23 CET 2012


On 11/18/12 10:15 PM, Vinay Sajip wrote:
> Tarek Ziadé <tarek <at> ziade.org> writes:
>
>> and I thought I should bring up that distutils2 has implemented a way to
>> define data files that can be installed in the "right" places on the
>> target system. "right" here being what the linux distros decides, or the
>> default win location etc.
>>
>> There is a description here:
>> http://alexis.notmyidea.org/distutils2/setupcfg.html#resources
>>
>> I think it's a better system than the data files that are located/and
>> stay in the python package, maybe it would be interesting not to lose it.
> I would agree that it shouldn't be lost, but there are some scenarios where data
> located in packages might be desirable - perhaps, for example,
>
> - translation files (.mo)
> - templates
Those two examples have usually a specific location on the various linux 
distros.


> Particularly where these relate to plugins of some sort.

Having a indirection like distutils2's resources allows the data files 
to live alongside the code
in development and to be installed wherever that's desired by the 
distro, without breaking
the code as long as it uses the indirection function to find back the file.

Since the indirection is provided by a file that can be browsed in the 
metadata directory,
it means anyone can get the file location by using the API we provided.

e.g.

get_file_path('ProjectName', 'relative/path/file.mo')

see 
http://hg.python.org/distutils2/file/65e23cccd0db/distutils2/database.py#l595


>
> At the moment distlib functionality is lower-level than pysetup, so I haven't
> looked at these issues in detail yet. However, I agree that an important element
> is the mapping of logical paths to physical paths in a standardised but
> extensible way which is distro packager friendly and also sensible on Windows/
> OS X.

That's been an issue for OS packagers since day 1, so it would be great 
if we solve this in this round of new tools :)

>
> Regards,
>
> Vinay Sajip
>
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig



More information about the Distutils-SIG mailing list