On Wed, 31 Mar 2010, Josselin Mouette wrote: > Don’t they work correctly if you ship an empty __init__.py file instead? I dunno what I did wrong originally but I was sure that it doesn't work then... well -- I was wrong seems. tested -- works just fine
> (I have no idea what declare_namespace does.) allows modules under the same namespace be loaded from different paths. here is a dummy bash script to demonstrate: mkdir -p p1/{,n}s/m1 p2/{,n}s/m2 echo "Just modules -- plane __init__" touch {p1/s{,/m1},p2/s{,/m2}}/__init__.py PYTHONPATH=p1:p2 python -c 'import s.m1; print s.m1.__file__; import s.m2; print s.m2.__file__' echo "Namespaces" touch {p1/ns/m1,p2/ns/m2}/__init__.py for d in p*/ns; do echo -e 'import pkg_resources\npkg_resources.declare_namespace(__name__)' > $d/__init__.py > $d/__init__.py done PYTHONPATH=p1:p2 python -c 'import ns.m1; print ns.m1.__file__; import ns.m2; print ns.m2.__file__' should output smth like Just modules -- plane __init__ /home/yoh/trash/pnamespaces/p1/s/m1/__init__.py Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named m2 Namespaces /home/yoh/trash/pnamespaces/p1/ns/m1/__init__.py /home/yoh/trash/pnamespaces/p2/ns/m2/__init__.py > If so, you can rely on python-support creating that file automatically. yeap -- does it fine ;) So I will proceed this way -- .-. =------------------------------ /v\ ----------------------------= Keep in touch // \\ (yoh@|www.)onerussian.com Yaroslav Halchenko /( )\ ICQ#: 60653192 Linux User ^^-^^ [175555] -- To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100401172500.gu8...@onerussian.com