Index: dist/src/Lib/site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.64 diff -u -r1.64 site.py --- dist/src/Lib/site.py 20 Jul 2004 02:28:28 -0000 1.64 +++ dist/src/Lib/site.py 1 Apr 2005 05:13:49 -0000 @@ -19,11 +19,12 @@ also inspected for path configuration files. A path configuration file is a file whose name has the form -.pth; its contents are additional directories (one per line) -to be added to sys.path. Non-existing directories (or -non-directories) are never added to sys.path; no directory is added to -sys.path more than once. Blank lines and lines beginning with -'#' are skipped. Lines starting with 'import' are executed. +.pth; its contents are additional paths (one per line) +to be added to sys.path. If a path begins with ~, it will be +expanded using os.path.expanduser. These additional paths will also be +searched for additional .pth files in top down order. +No path is added to sys.path more than once. Blank lines and lines +beginning with '#' are skipped. Lines starting with 'import' are executed. For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local and there is a directory /usr/local/lib/python1.5/site-packages @@ -45,10 +46,11 @@ /usr/local/lib/python1.5/site-packages/bar /usr/local/lib/python1.5/site-packages/foo + /usr/local/lib/python1.5/site-packages/bletch -Note that bletch is omitted because it doesn't exist; bar precedes foo -because bar.pth comes alphabetically before foo.pth; and spam is -omitted because it is not mentioned in either path configuration file. +bar precedes foo because bar.pth comes alphabetically before foo.pth; +and spam is omitted because it is not mentioned in either path +configuration file. After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional @@ -63,7 +65,7 @@ def makepath(*paths): - dir = os.path.abspath(os.path.join(*paths)) + dir = os.path.abspath(os.path.expanduser(os.path.join(*paths))) return dir, os.path.normcase(dir) def abs__file__(): @@ -135,10 +137,7 @@ exec line continue line = line.rstrip() - dir, dircase = makepath(sitedir, line) - if not dircase in known_paths and os.path.exists(dir): - sys.path.append(dir) - known_paths.add(dircase) + addsitedir(os.path.join(sitedir, line), known_paths) finally: f.close() if reset: @@ -199,8 +198,7 @@ sys.version[:3], 'site-packages')) for sitedir in sitedirs: - if os.path.isdir(sitedir): - addsitedir(sitedir, known_paths) + addsitedir(sitedir, known_paths) return None