[Distutils] distlib and data files => resources ?

Tarek Ziadé tarek at ziade.org
Sun Nov 18 23:40:06 CET 2012


On 11/18/12 11:25 PM, Antonio Cavallo wrote:
> Just come to my mind data test related to a package would be a natural 
> candidate:
>
>   mypack
>     |- __init__.py
>     |- test
>          |- __init__.py
>          |- test0.py
>          |- data
>              |- data.for.test0.dat
>
> It is natural deploying them as part of an installer file.
>
> I don't see why another indirection layer is required here: you have 
> the test.__file__ or the inspect.getfile *already*.
> What makes so special this case or a very similar one (eg. po files, 
> images files for a gui based app, etc.)?
>
> Is there any reason to invent/introduce something else?

One example:

- if you include test that means you want test to be run
- your test writes in that .dat file

what happens in distros that have a read-only site-packages and only 
allow writes under /var/xxx ?

if you define all your data files under some categories, suddenly, you 
are allowing OS packagers
to tweak your package config to move these files to another spot, 
without having
to change your package's code.

Today, OS packagers will patch your code.



>
>
> I hope this helps,
> Antonio
>
>
>
>
> Vinay Sajip wrote:
>> Tarek Ziadé<tarek<at> ziade.org>  writes:
>>
>>> 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.
>>
>> Yes, but it seems like you're assuming everything's always installed 
>> in a
>> conventional way and not, say, deployed in a .zip. I'm not disputing 
>> what you
>> said - get_file_path and get_resource_path are still there in distlib 
>> - but I'm
>> not sure that there's *never* a case for data located in packages.
>>
>> Regards,
>>
>> Vinay Sajip
>>
>> _______________________________________________
>> Distutils-SIG maillist  -  Distutils-SIG at python.org
>> http://mail.python.org/mailman/listinfo/distutils-sig
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig



More information about the Distutils-SIG mailing list