[Distutils] how can I egt the packages and modules in a distribution?
P.J. Eby
pje at telecommunity.com
Fri Aug 20 16:17:12 CEST 2010
At 11:49 AM 8/20/2010 +0100, Chris Withers wrote:
>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?
You get whatever was installed last.
>Would it work okay if each distribution was unpacked in its own
>folder (as buildout and easy_install do)?
Yep. And of course, it'll also work if they put their templates
under x/a or x/b, like they really ought to be doing in the first
place, for precisely this reason.
(Alternatively, they can put their stuff under the project's egg-info
directory, the way EggTranslations does.)
More information about the Distutils-SIG
mailing list