[Patches] [ python-Patches-1174614 ] site enhancements
SourceForge.net
noreply at sourceforge.net
Fri Jun 3 02:21:56 CEST 2005
Patches item #1174614, was opened at 2005-04-01 00:24
Message generated for change (Comment added) made by etrepum
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1174614&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob Ippolito (etrepum)
Assigned to: Nobody/Anonymous (nobody)
Summary: site enhancements
Initial Comment:
The current site.py has 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.
Attached is a patch to CVS HEAD that:
(1) Removes the os.path.exists() / os.path.isdir() restrictions
(2) Changes the .pth reader to use addsitedir() (top down) rather than
sys.path.append()
(3) makepath() uses os.path.expanduser() after the os.path.join().
----------------------------------------------------------------------
>Comment By: Bob Ippolito (etrepum)
Date: 2005-06-02 20:21
Message:
Logged In: YES
user_id=139309
If you read closer, it only scans directories added by .pth files, not all
directories on sys.path. This is to facilitate better encapsulation, so an
admin user can create a .pth file that says "~/lib/python2.4/site-
packages" and any user that starts Python will have their own site-
packages dir, where .pth files work, without resorting to PYTHONPATH.
This way you can use distutils to install packages into your homedir,
and they will actually work as expected.
PYTHONPATH is utterly disastrous if you regularly deal with several
different Python interpreters.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2005-06-02 20:14
Message:
Logged In: YES
user_id=6380
Hm. Looking for .pth files only in site-packages was
intentional; it will slow down startup considerably if you
have to do an os.listdir() of every directory on sys.path
(even worse if some are on NFS!). I'd recommend against that
part.
----------------------------------------------------------------------
Comment By: Just van Rossum (jvr)
Date: 2005-04-07 04:33
Message:
Logged In: YES
user_id=92689
Patch looks good, the new functionality is great to have, recommend apply.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1174614&group_id=5470
More information about the Patches
mailing list