rb-site fails to detect memcache when installed from an egg

Review Request #843 — Created April 28, 2009 and submitted

Information

Review Board SVN (deprecated)

Reviewers

rb-site fails to detect the "memcache" module when memcache is installed as an egg.  Something about imp.find_module does not honor sys.path_hooks and doesn't use the zipimporter.  This appears to be true in 2.4, 2.5, and 2.6.
Ran "rb-site install", now properly detects memcache installation.
EH
  1. BTW, pkgutil.find_loader() seems to do the right thing in terms of examining sys.path_hooks, but it's not documented in the official Python docs, so I don't know if you'd rather use that (I'm not sure if the original intent was to avoid __import__ to avoid any side effects of actually importing the module).
    1. Python 2.4 doesn't seem to have pkgutil.find_loader. The import should be fine for our needs here.
  2. 
      
chipx86
  1. That's good to know, and really annoying. We do a bunch of these checks in reviewboard/admin/checks.py, too, and I haven't seen anyone hit these issues... Hmm...
    
    
    I think doing an import is fine. I was just going to avoid actually importing, but if we need to, that's fine.
  2. Python 2.4, I believe, will grumble loudly about this, because it doesn't provide default arguments. This should be more like:
    
       __import__(name, {}, {}, [])
    1. 2.4 seems to be optional, too.  From the source: PyArg_ParseTuple(args, "s|OOO:__import__",
      
      As for not running into the problem very often, it is somewhat rare to have a Zipped egg (this is only a problem for zipped ones -- unzipped eggs work okay because find_module honors .pth files).  For one reason or another, eggs tend not to be zip-safe (with extension Modules, for example), so that's why it probably hasn't shown up much.  I see in checks.py that you ran into a problem with importing DNS, for example, but Pygments works because it installs in unzipped format.
    2. You're right. I was thinking back to a problem I hit before, and it wasn't default arguments, it was using keyword arguments. I wanted to specify the last argument as a keyword argument instead of providing the other defaults, and couldn't in 2.4. Defaults work fine.
  3. 
      
chipx86
  1. Committed as r1944.
  2. 
      
Loading...