Lc @ sT d Z d d k Z d d k Z d d k Z e i e i g Z d a d a d a
d Z d Z d Z
d Z d Z d Z d d Z d
Z d Z d Z d
Z d Z d e f d YZ d Z d e f d YZ d Z d Z d Z d Z d Z d Z e d Z! e" d j o e! n d S( sN Append module search paths for third-party packages to sys.path.
****************************************************************
* This module is automatically imported during initialization. *
****************************************************************
In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code. Because of the automatic
import, this is no longer necessary (but code that does it still
works).
This will append site-specific paths to the module search path. On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended. The
resulting directories, if they exist, are appended to sys.path, and
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.
For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory /usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth. Assume foo.pth contains the
following:
# foo package configuration
foo
bar
bletch
and bar.pth contains:
# bar package configuration
bar
Then the following directories are added to sys.path, in this order:
/usr/local/lib/python2.5/site-packages/bar
/usr/local/lib/python2.5/site-packages/foo
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.
After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations. If this import fails with an
ImportError exception, it is silently ignored.
iNc G s4 t i i t i i | } | t i i | f S( N( t ost patht abspatht joint normcase( t pathst dir( ( s /usr/lib64/python2.6/site.pyt makepathK s c C sj xc t i i D]R } t | d o q n y t i i | i | _ Wq t j
o
q q Xq Wd S( s6 Set all module' __file__ attribute to an absolute patht
__loader__N( t syst modulest valuest hasattrR R R t __file__t AttributeError( t m( ( s /usr/lib64/python2.6/site.pyt abs__file__P s c C sn g } t } xN t i D]C } t | \ } } | | j o | i | | i | q q W| t i (| S( sK Remove duplicate entries from sys.path along with making them
absolute( t setR R R t appendt add( t Lt known_pathsR t dircase( ( s /usr/lib64/python2.6/site.pyt removeduppaths[ s
c C s d d k l } d | t i f } t t d o | d 7} n t i i t i i t i d | } t i i | d S( sb Append ./build/lib. in case we're running in the build dir
(especially for Guido :-)i( t get_platforms build/lib.%s-%.3st gettotalrefcounts -pydebugN(
t distutils.utilR R t versionR R R R t dirnameR ( R t s( ( s /usr/lib64/python2.6/site.pyt addbuilddiro s (c C st t } xd t i D]Y } y: t i i | o# t | \ } } | i | n Wq t j
o
q q Xq W| S( sD Return a set containing all existing directory entries from sys.path( R R R R t isdirR R t TypeError( t dR R ( ( s /usr/lib64/python2.6/site.pyt _init_pathinfoz s
c B s9 | d j o e d } n d } e i i | | } y e | d } Wn e j
o d SX| i i z x | D] } | i d o q| n | i d o | d Uq| n | i
} e | | \ } } | | j o4 e i i | o! e
i i | | i | q| q| WWd QX| o
d } n | S( s Process a .pth file within the site-packages directory:
For each line in the file, either combine it with sitedir to a path
and add that to known_paths, or execute it if it starts with 'import '.
i i t rUNt #s import s import ( s import s import ( t NoneR" R R R t opent IOErrort __exit__t __enter__t
startswitht rstripR t existsR R R ( t sitedirt nameR t resett fullnamet ft lineR R ( ( s /usr/lib64/python2.6/site.pyt
addpackage s2
c
C s | d j o t } d } n d } t | \ } } | | j o t i i | n y t i | } Wn t i j
o d SXt i d } g } | D]! } | i
| o | | q q ~ } x$ t | D] } t | | | q W| o
d } n | S( sT Add 'sitedir' argument to sys.path if missing and handle .pth files in
'sitedir'i i Nt pth(
R% R" R R R R R t listdirt errort extsept endswitht sortedR3 ( R- R R/ t sitedircaset namest dotptht _[1]R. ( ( s /usr/lib64/python2.6/site.pyt
addsitedir s&