Handle *-nspkg.pth files


Some packages on Python <3.3 create .pth files to emulate namespace packages. These files typically look like:
import sys,types,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('$(NAME)',)); ie = os.path.exists(os.path.join(p,'__init__.py')); m = not ie and sys.modules.setdefault('paste',types.ModuleType('$(NAME)')); mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and mp.append(p)
The result is that the folder $(NAME) should be treated as if it includes an empty __init__.py file.

Because we don't handle arbitrary code in pth files, we will ignore the packages. We should attempt to detect this pattern and include the path(s) it references.


Zooba wrote Nov 27, 2013 at 7:05 PM

The format of this string comes from setuptools, so it is going to be consistent enough that we can parse it.