[Python-Dev] Re: [Zope3-dev] Zip import and sys.path manipulation (was Re: directory
hierarchy proposal)
Barry A. Warsaw
barry@zope.com
Mon, 16 Dec 2002 11:02:47 -0500
>>>>> "PJE" == Phillip J Eby <pje@telecommunity.com> writes:
PJE> That should probably read:
| __path__ = [os.path.join(p, 'zope') for p in sys.path if
| isinstance(p,StringTypes)]
PJE> or else it could break in 2.3 if somebody's putting
PJE> non-strings on sys.path. I don't remember exactly how the
PJE> python-dev discussion turned out, but I kind of got the
PJE> impression that it was going to be allowable in 2.3. Also,
PJE> I'm pretty sure it will not give the expected/desired results
PJE> in conjunction with zipfile imports.
PJE> For these and related reasons, I would suggest that a
PJE> slightly different snippet be used instead (the names are
PJE> lousy, improvements welcome):
| from namespace_packages import makeNamespacePath
| __path__ = makeNamespacePath('zope')
Random, harried thought: maybe we can use .pth files to extend the
__path__? IOW, something like the above would search sys.path for
zope.pth files, and do the equivalent to what site.py already does.
-Barry