foundit/Piped — Issue #12: "pip install piped" creates a bad installation
Author: nkvoll
Created: 2011-10-17 22:45:44+00:00
State: open

pip uses --single-version-externally-managed to install packages, which creates a nspkg.pth file like this:

$ cat /Users/njal/.virtualenvs/Throwaway/lib/python2.6/site-packages/piped-0.2.0-py2.6-nspkg.pth
import sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('piped',)); ie = os.path.exists(os.path.join(p,'__init__.py')); m = not ie and sys.modules.setdefault('piped',new.module('piped')); mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and mp.append(p)
import sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('piped', 'contrib')); ie = os.path.exists(os.path.join(p,'__init__.py')); m = not ie and sys.modules.setdefault('piped.contrib',new.module('piped.contrib')); mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and mp.append(p); m and setattr(sys.modules['piped'], 'contrib', m)

This breaks both twisted.python.modules and the (potentially misplaced) versioning info in piped/__init__.py

**The current workaround is to use easy_install when installing Piped**. In the longer run we should probably look into structuring the plugin loading a little bit different, to avoid this situation. Taking inspiration from twisteds __path__ extending in a plugin-package is probably a good start.

See http://twistedmatrix.com/trac/ticket/5318