I have a test site containing nested namespace packages in zipped and unzipped eggs_
- nspkg3_aaa.egg - unzipped egg, namespaces: nspkg3
- nspkg3_bbb.egg - zipped egg , namespaces: nspkg3, nspkg3.bbb
- nspkg3_ccc.egg - unzipped egg, namespaces: nspkg3
When using order "aaa, bbb, ccc" in PYTHONPATH, importing "nspkg3.bbb" FAILS,
whereas
when using order "bbb, aaa, ccc" in PYTHONPATH, importing "nspkg3.bbb" PASSES,
I would expect "nspk3.bbb" to ba importable 8as a namespace package) no matter which possition it has in PYTHONPATH.
How to reproduce
Preperation: get hands on the eggs in question:
$ wget https://github.com/pyinstaller/pyinstaller/archive/v3.5.zip
$ unzip v3.5.zip
$ cd pyinstaller-3.5/tests/functional/modules/nspkg3-pkg/
Order "aaa, bbb, ccc": fails
$ PYTHONPATH=nspkg3_aaa.egg:nspkg3_bbb.egg:nspkg3_ccc.egg python3.7 -c "import nspkg3.bbb.zzz"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'nspkg3.bbb'
Order "bbb, aaa, ccc": passes:
$ PYTHONPATH=nspkg3_bbb.egg:nspkg3_aaa.egg:nspkg3_ccc.egg python3.7 -c "import nspkg3.bbb.zzz"
this is module nspkg3.bbb.zzz
Further information
I did some research and found that the zipped egg (bbb) is *not added* to the package path when using order "aaa, bbb, ccc":
Order "aaa, bbb, ccc": bbb is missing here
$ PYTHONPATH=nspkg3_aaa.egg:nspkg3_bbb.egg:nspkg3_ccc.egg \
python3.7 -c "import nspkg3 ; print(nspkg3.__path__)"
['…/nspkg3_aaa.egg/nspkg3', '…/nspkg3_ccc.egg/nspkg3']
Order "bbb, aaa, ccc": bbb is included
$ PYTHONPATH=nspkg3_bbb.egg:nspkg3_aaa.egg:nspkg3_ccc.egg \
python3.7 -c "import nspkg3 ; print(nspkg3.__path__)"
['…/nspkg3_bbb.egg/nspkg3', '…/nspkg3_aaa.egg/nspkg3', '…/nspkg3_ccc.egg/nspkg3']
Also tested with Python 2.7: Same results
|