This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pkgutil.extend_path fails with zipped eggs if not at first place
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: htgoebel, lkollar
Priority: normal Keywords:

Created on 2019-10-31 11:28 by htgoebel, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg355745 - (view) Author: Hartmut Goebel (htgoebel) Date: 2019-10-31 11:28
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
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82834
2019-11-02 22:15:31lkollarsetnosy: + lkollar
2019-10-31 11:28:28htgoebelcreate