problems with namespace package
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I have a package named A, with a subpackage B, and I want to create a namespace package A.B.C. In the namespace package setup file I set namespace_packages=['A', 'A.B'], and I use declare_namespace in both A/__init__.py and A/B/__init__.py modules. However if I: 1) install A package 2) install A.B.C package importing A.B.C will raise an ImportError exception. If I reinstall A package, then it seems to work. Where is the problem? Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkvcFS0ACgkQscQJ24LbaURdmACgiPqNL/czwKoiFsFIv+41WWQI emEAnjp/a6ZtVB92GkpcONNtOaVFkeir =gKzt -----END PGP SIGNATURE-----
On Sat, May 1, 2010 at 14:41, Manlio Perillo <manlio.perillo@gmail.com> wrote:
I have a package named A, with a subpackage B, and I want to create a namespace package A.B.C.
You can't, afaik, not easily at least. You can however make a package that monkeypatches in C into A.B. But that's not really namespace packages. -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Manlio Perillo wrote:
Hi.
I have a package named A, with a subpackage B, and I want to create a namespace package A.B.C.
In your examples, it seems as though you want 'A' and 'A.B' to be namespace packages, but 'A.B.C' is a "normal" package.
In the namespace package setup file I set namespace_packages=['A', 'A.B'],
and I use declare_namespace in both A/__init__.py and A/B/__init__.py modules.
Are you sure there is no other code in 'A/__init__.py' and 'A/B/__init__.py' of either package? See: http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
However if I: 1) install A package 2) install A.B.C package
importing A.B.C will raise an ImportError exception.
If I reinstall A package, then it seems to work.
Where is the problem?
You might compare your setup.py and __init__.py with those in one of the 'zope.app' packages, which successfully use nested namespace packages. E.g. for zope.app.annotation: http://svn.zope.org/repos/main/zope.app.annotation/trunk/setup.py http://svn.zope.org/repos/main/zope.app.annotation/trunk/src/zope/__init__.p... http://svn.zope.org/repos/main/zope.app.annotation/trunk/src/zope/app/__init... Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkvcY7kACgkQ+gerLs4ltQ7c7wCgp3P40zxnfYDK4p+if1FaP9Fo wgsAn0ud53So7Xkk7U/BbDphYergXNjy =+0mW -----END PGP SIGNATURE-----
participants (3)
-
Lennart Regebro -
Manlio Perillo -
Tres Seaver