[Distutils] namespace_package

Marius Gedminas marius at gedmin.as
Tue Dec 1 01:38:02 EST 2015


On Mon, Nov 30, 2015 at 06:59:31PM -0500, KP wrote:
> I'm not sure where the issue is, but when I specify a namespace_package in
> the setup.py file, I can indeed have multiple packages with the same base
> (foo.bar, foo.blah, etc...). The files all install in to the same
> directory. It drops  the foo/__init__.py that would be doing the
> extend_path, and instead adds a ".pth" file that is a bit over my head.
> 
> The problem is that it does not seem to traverse the entire sys.path to
> find multiple foo packages.

Does every foo.x package specify namespace_packages=['foo']?

Do they all ship an identical foo/__init__.py with

    import pkg_resources
    pkg_resources.declare_namespace(__name__)

?

AFAIU you need both things in every package, if you want to use
namespace packages.

> If I do not specify namespace_packages and instead just use the
> pkgutil.extend_path, then this seems to allow the packages to be in
> multiple places in the sys.path.
> 
> Is there something additional for the namespace_package that i need to
> specify in order for all of the sys.path to be checked?
> 
> I'm using 18.5 setuptools....but I am not sure if this somehow ties in to
> wheel/pip, since I'm using that for the actual install.

Marius Gedminas
-- 
Give a man a computer program and you give him a headache, but teach him to
program computers and you give him the power to create headaches for others for
the rest of his life...
        -- R. B. Forest
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 173 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20151201/a7f913a7/attachment.sig>


More information about the Distutils-SIG mailing list