[Python-Dev] site enhancements (request for review)

Bob Ippolito bob at redivi.com
Mon Apr 25 04:16:28 CEST 2005


A few weeks ago I put together a patch to site.py for Python 2.5 
<http://python.org/sf/1174614> that solves three major deficiencies:

(1) All site dirs must exist on the filesystem: Since PEP 302 (New
Import Hooks) was adopted, this is not necessarily true.
sys.meta_path and sys.path_hooks can have valid uses for non-
existent paths. Even the standard zipimport hook supports in-zip-
file paths (i.e. foo.zip/bar).

(2) The directories added to sys.path by .pth files are not scanned
for further .pth files. If they were, you could make life much easier
on developers and users of multi-user systems. For example, it
would be possible for an administrator to drop in a .pth file into the
system-wide site-packages to allow users to have their own local
site-packages folder. Currently, you could try this, but it wouldn't
work because many packages such as PIL, Numeric, and PyObjC
take advantage of .pth files during their installation.

(3) To support the above use case, .pth files should be allowed to
use os.path.expanduser(), so you can toss a tilde in front and do the
right thing. Currently, the only way to support (2) is to use an ugly
"import" pth hook.

So far, it seem that only JvR has reviewed the patch, and recommends 
apply.  I'd like to apply it, but it should probably have a bit more 
review first.  If no negative comments show up for a week or two, I'll 
assume that people like it or don't care, and apply.

-bob



More information about the Python-Dev mailing list