At 02:06 PM 2/19/2009 +0000, Karsten Petersen wrote:
Hi,

I'm trying to make Google App Engine work smoothly with setuptools and I'm struggling to understand one specific piece of what pkg_resources does. Would you mind giving me a hint?

The question is basically: Why does _handle_ns() in pkg_resources import other modules that implement the same namespace. It's not using the module handle that is returned. I looked for side effects but the only ones I found was that exceptions are raised if the other modules are broken and that the modules __file__ var is changed to point to the last found module that implements the namespace in question.

What am I missing?

In the unlikely event that one of the __init__.py's contains anything other than namespace setup code, loading the module ensures that it will be run. This was done for compatibility with older packages that use distutils hacks to create a namespace package. (i.e., shipping one package with the __init__.py, and the rest without it). Such packages need to have their __init__.py code run.

It probably won't hurt anything too badly to leave it out, since it's strictly for compatibility with a configuration that's deprecated anyway. (At least, it's deprecated for setuptools.)

_______________________________________________
Distutils-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to