[Distutils] how can I egt the packages and modules in a distribution?

Chris Withers chris at simplistix.co.uk
Fri Aug 20 12:49:39 CEST 2010


P.J. Eby wrote:
>> Okay, so if we have two distributions, x.a and x.b both define 
>> template folders called 'templates', and each has a template called 
>> 'master', what ends up on disk? what does 
>> pkg_resources.resource_filename('x.a','templates/master') return?
>> It should be different to 
>> pkg_resources.resource_filename('x.b','templates/master'), but will it 
>> be?
> 
> You seem to be confusing distributions and packages.  If 'x.a' and 'x.b' 
> are package names, then each will have its own directory 
> ('x/a/templates' or 'x/b/templates').  If they used install_data to 
> specify non-package data, OTOH, it'll be mixed.

Now that I'm somewhere I can read the docs, I can be clearer.
'x.a' and 'x.b' were distribution names, such distributions names are 
quite common. However, for absolute clarity, assuming we have:

- A distribution called 'XA', that contains an 'x.a' package but also a 
'templates' directory at the root of the distribution, containing a 
'master' template

- A distribution called 'XB', that contains an 'x.b' package but also a 
'templates' directory at the root of the distribution, containing a 
'master' template.

Which template do I get if I do:

pkg_resources.resource_string(tuple(pkg_resources.parse_requirements('XA'))[0],'templates/master')

...in the context of pip or another flat-structure install?

Would it work okay if each distribution was unpacked in its own folder 
(as buildout and easy_install do)?

cheers,

Chris



More information about the Distutils-SIG mailing list