[Distutils] namespace packages

David Cournapeau cournape at gmail.com
Fri Apr 23 03:16:54 CEST 2010


On Fri, Apr 23, 2010 at 1:10 AM, P.J. Eby <pje at telecommunity.com> wrote:
> At 04:36 PM 4/22/2010 +0900, David Cournapeau wrote:
>>
>> On Thu, Apr 22, 2010 at 1:10 PM, P.J. Eby <pje at telecommunity.com> wrote:
>> > At 10:18 AM 4/22/2010 +0900, David Cournapeau wrote:
>> >>
>> >> One problem with the setuptools implementation is
>> >> that several packages sharing the same namespace have files in common,
>> >
>> > If that were actually true (it isn't), then it would be considered a bug
>> > in
>> > setuptools.
>>
>> I am confused, then, by the setuptools doc:
>>
>> Note, by the way, that your project's source tree must include the
>> namespace packages' __init__.py files (and the __init__.py  of any
>> parent packages), in a normal Python package layout. These __init__.py
>> files must contain the line:
>
> If you read two paragraphs further in that doc, you'll see where it goes on
> to say:
>
> "You must NOT include any other code and data in a namespace package's
> __init__.py. Even though it may appear to work during development, or when
> projects are installed as .egg files, it will not work when the projects are
> installed using "system" packaging tools -- in such cases the __init__.py
> files **will not be installed**, let alone executed. "  (emphasis added)

Hm, you are right, the __init__.py is not installed for a trivial
namespace package with the right options. This is strange, because I
always install with --single-version-externally-managed, and always
had issues with shared __init__.py (which has only that one line to
declare the namespace). And I still see this behavior for the
namespace packages I am using, so I need to look further to understand
what cause this discrepancy.

> I'd be interested in knowing under what conditions that's the case (e.g. how
> many .egg zipfiles vs. how many .egg subdirs); it might be possible to
> improve it.

In my case, it is not even the issue of many eggs (I always install
things with --single-version-externally-managed and I forbid any code
to write into  easy_install.pth). Importing pkg_resources alone
(python -c "import pkg_resources") takes half a second on my netbook.
As a reference, importing pkg_resources is slower than importing
numpy.

cheers,

David


More information about the Distutils-SIG mailing list