Issue 31280: Namespace packages in directories added to path aren't importable if packages from the same namespace are in site-packages (original) (raw)

Created on 2017-08-25 21:53 by j1m, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
z.py j1m,2017-08-25 22:41
Messages (7)
msg300856 - (view) Author: Jim Fulton (j1m) * (Python committer) Date: 2017-08-25 21:53
I'm having an issue importing from namespaces packages whose directories are added to sys.path and have other packages from the same namespace in site-packages. To reproduce: - Create a virtualenv and install zc.buildout in it (``envdir/bin/pip install zc.buildout``). - Run the attached script with the virtual environment (``envdir/bin/python z.py``). Note that scenarios like https://www.python.org/dev/peps/pep-0420/#id3 work fine. This seems to related to having namespace packages in site-packages, or, presumably anywhere on the default path. I've verified this with Python 3.4, 3.5, and 3.6. If y'all agree that this is a bug, then I'll attempt debug it and come up with a PR.
msg300857 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-08-25 22:29
Jim: did you forget to attach the z.py script?
msg300858 - (view) Author: Jim Fulton (j1m) * (Python committer) Date: 2017-08-25 22:41
No, but I managed to unattach it, because "Choose File" always feels like a submit button to me. Sorry. Attached.
msg300859 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-08-26 00:20
I think this is a function of the .pth file causing 'zc' to be in sys.modules. If I delete the .pth file, the first import of zc.m succeeds. Note that if the .pth file is in place, then: % bin/python3 Python 3.6.1 (default, Mar 24 2017, 12:50:34) [GCC 5.4.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> 'zc' in sys.modules True >>>
msg300876 - (view) Author: Jim Fulton (j1m) * (Python committer) Date: 2017-08-26 13:18
Wow, OK. It didn't occur to me to look for .pth files. (Buildout doesn't use them.) I guess this is a pip bug or misfeature. I'll head over to pypa. Thanks!
msg300877 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-08-26 13:25
No problem. If you open a pypa issue, can you post a link here? Thanks.
msg300889 - (view) Author: Jim Fulton (j1m) * (Python committer) Date: 2017-08-26 18:04
See: https://github.com/pypa/pip/issues/4695
History
Date User Action Args
2022-04-11 14:58:51 admin set github: 75461
2017-08-26 18:04:55 j1m set messages: +
2017-08-26 13:25:06 eric.smith set type: behaviorresolution: not a bugmessages: +
2017-08-26 13🔞55 j1m set status: open -> closedmessages: + stage: resolved
2017-08-26 00:20:40 eric.smith set messages: +
2017-08-25 22:41:31 j1m set files: + z.pymessages: +
2017-08-25 22:29:42 eric.smith set nosy: + eric.smithmessages: +
2017-08-25 21:59:14 barry set nosy: + barry
2017-08-25 21:53:30 j1m create