_8(Zc@sldZddlZddlZyddlZWnek rMddlZnXyeWn!ek ryddlm ZnXej ej gZ dadadaeeddpeedd.kZeedZejd d kZereeZnd Zd Zd ZdZdZdZddZej ej dZ dZ!dZ"dZ#dZ$de%fdYZ&dZ'de%fdYZ(dZ)dZ*dZ+dZ,d Z-dd!Z.dd"Z/d#Z0d$Z1d%Z2d&Z3d'Z4d(Z5d)Z6d*Z7d+Z8e8d,Z9e:d-krhe9ndS(/s 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, it starts with sys.prefix and sys.exec_prefix (if different) and appends lib/python/site-packages as well as lib/site-python. It also supports the Debian convention of lib/python/dist-packages. On other platforms (mainly Mac and Windows), it uses just sys.prefix (and sys.exec_prefix, if different, but this is unlikely). The resulting directories, if they exist, are appended to sys.path, and also inspected for path configuration files. FOR DEBIAN, this sys.path is augmented with directories in /usr/local. Local addons go into /usr/local/lib/python/site-packages (resp. /usr/local/lib/site-python), Debian addons install into /usr/{lib,share}/python/dist-packages. 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.X/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.X/site-packages/bar /usr/local/lib/python2.X/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. iN(tSettmaxsizetmaxintii tpypy_version_infoitjavacGsetjj|}tr=|dks3|jdr=||fStjj|}|tjj|fS(Nt __classpath__t__pyclasspath__(tostpathtjoint _is_jythont startswithtabspathtnormcase(tpathstdir((s+/home/ec2-user/fle2/lib64/python2.7/site.pytmakepath\s  cCsx{tjjD]j}tr,t|t st|drAqnt|dd}|dkreqnt j j ||_ qWdS(s6Set all module' __file__ attribute to an absolute patht __loader__t__file__N( tsystmodulestvaluesR t isinstancet ModuleTypethasattrtgetattrtNoneRRR R(tmtf((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt abs__file__ds cCslg}t}xLtjD]A}t|\}}||kr|j||j|qqW|tj(|S(sK Remove duplicate entries from sys.path along with making them absolute(tsetRRRtappendtadd(tLt known_pathsRtdircase((s+/home/ec2-user/fle2/lib64/python2.7/site.pytremoveduppathsqs    cCs~ddlm}d|tjf}ttdrB|d7}ntjjtjjtjd|}tjj |dS(sbAppend ./build/lib. in case we're running in the build dir (especially for Guido :-)i(t get_platformsbuild/lib.%s-%.3stgettotalrefcounts-pydebugN( tdistutils.utilR%RtversionRRRR tdirnameR(R%ts((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt addbuilddirs  (cCspt}x`tjD]U}y8tjj|rPt|\}}|j|nWqtk rgqqXqW|S(sDReturn a set containing all existing directory entries from sys.path(RRRRtisdirRR t TypeError(tdRR#((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt_init_pathinfos   c Bs&|dkred}nd}ejj||}ye|d}Wnek r^dSXzx|D]}|jdrqin|jdr|dUqin|j}e ||\}}||kriejj |rie jj ||j |qiqiWWd|jX|r"d}n|S(soAdd a new path to known_paths by combining sitedir and 'name' or execute sitedir if it starts with 'import'iitrUNt#timport(RR/RRR topentIOErrorR trstripRtexistsRRR tclose( tsitedirtnameR"tresettfullnameRtlineRR#((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt addpackages2       cCs|dkrt}d}nd}t|\}}||krUtjj|nytj|}Wntjk rdSX|j x7|D]/}|j tj drt |||qqW|rd}n|S(sTAdd 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'iiNtpth( RR/RRRRRtlistdirterrortsorttendswithtextsepR=(R8R"R:t sitedircasetnamesR9((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt addsitedirs$       c Cs tjj|d|g}||krF|jtjj|dnx|D]}|rMtjdksntrtjj|ddg}ntrtjj|dg}ntjdkr@||kr@|jdrtjjdtj d dtjj|d d d g}qdtjj|d d tj d dg}n$tj d krFtjj|d d tj d dtjj|d dtjj|d tj d dg}tjj|dd tj d d}tjj |rEtjj |g|D]}tjj |^qkrEt r5|jd|qE|j|ny.tj|jdtjj|ddWntk rnX|jtjj|dd tj d dtj ddkr|jtjj|d d tj d dn-|jtjj|d d tj dd|jtjj|d dn|tjj|d dg}tjdkrd|krtjjd}|r|jtjj|ddtj d dqqnx3|D](} tjj| rt| |qqWqMqMWdS(s8Add site-packages (and possibly site-python) to sys.pathtlocaltos2emxtriscostLibs site-packagestdarwins/System/Library/Frameworks/s/Library/PythonitExtrastlibtpythont/s site-pythons lib-dynloadtlib64itdebugs local/libs dist-packagest2s dist-pythonsPython.frameworktHOMEtLibrarytPython(RHRIN(RRR RRtplatformR t_is_pypyR R(tsepR6trealpatht _is_64bittinsertt getobjectstAttributeErrortenvirontgetR,RFR( R"t sys_prefixt exec_prefixtprefixestprefixtsitedirst lib64_dirtpthomeR8((s+/home/ec2-user/fle2/lib64/python2.7/site.pytaddsitepackagessv  ! &&7'    "    cCsttdr(ttjdtr(tSttdrettdretjtjkredSnttdrttdrtj tj krdSnt S(s,Check if user site directory is safe for inclusion The function tests for the command line flag (including environment var), process uid/gid equal to effective uid/gid. None: Disabled for security reasons False: Disabled by user (command line option) True: Safe and enabled tflagst no_user_sitetgetuidtgeteuidtgetgidtgetegidN( RRRRitFalseRRlRkRRnRmtTrue(((s+/home/ec2-user/fle2/lib64/python2.7/site.pytcheck_enableusersites $cCsftjjdd}d}tjdkrtjjdpBd}|rT|an||datjjtdtj dtj dd a nD|r|an|dd atjjtd d tj d d a t rtjj t rt t |nt rbxYdD]N}tjjt|d tj d d}tjj |r t ||q q Wn|S(s'Add a per user site-package to sys.path Each user has its own python directory with site-packages in the home directory. USER_BASE is the root directory for all Python versions USER_SITE is the user specific site-packages directory USER_SITE/.. can be used for data. tPYTHONUSERBASEcWstjjtjj|S(N(RRt expanduserR (targs((s+/home/ec2-user/fle2/lib64/python2.7/site.pytjoinuserDstnttAPPDATAt~RUiis site-packagess.localRMRNis local/libs dist-packagesN(slibs local/lib(RR^R_RR9t USER_BASERR RR(t USER_SITEtENABLE_USER_SITER,RF(R"tenv_baseRutbaset dist_libdirt user_site((s+/home/ec2-user/fle2/lib64/python2.7/site.pytaddusersitepackages5s4         cCsotjjtjdd}tjdjd}|drK|j|n ||deZdZdZdddZdZdZdZRS(sninteractive prompt objects for printing the license text, a list of contributors and the copyright notice.icCs1||_||_||_||_d|_dS(N(t_Printer__namet_Printer__datat_Printer__filest_Printer__dirsRt_Printer__lines(RR9tdatatfilestdirs((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs     cCs|jr dSd}x|jD]w}xd|jD]Y}tjj||}y*t|d}|j}|j PWq-t k rq-Xq-W|rPqqW|s|j }n|j d|_t |j|_dS(NR0s (RRRRRRR R3treadR7R4RRtlent_Printer__linecnt(RRRtfilenametfp((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt__setups&     cCsH|jt|j|jkr2dj|jSd|jfdSdS(Ns s!Type %s() to see the full %s texti(t_Printer__setupRRtMAXLINESR R(R((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs cCs|jd}d}xy1x*t|||jD]}|j|GHq3WWntk r^PqX||j7}d}xU|dkryt|}Wntk rt|}nX|dkrud}ququW|dkrPqqWdS(Ns0Hit Return for more, or q (and Return) to quit: ittq(RR( RtrangeRRt IndexErrorRt raw_inputt NameErrortinput(Rtprompttlinenotitkey((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs(       (((RRt__doc__RRRRR(((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs   cCstdtjt_tr0tddt_n-trKtddt_ntddt_tjj tj }tddtj dd gtjj |tj |tjgt_d S( s,Set 'copyright' and 'credits' in __builtin__t copyrighttcreditss?Jython is maintained by the Jython developers (www.jython.org).s;PyPy is maintained by the PyPy developers: http://pypy.org/s Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.tlicenses+See http://www.python.org/%.3s/license.htmls LICENSE.txttLICENSEN(RRRRR RRWRRR)RR(R tpardirtcurdirR(there((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt setcopyrights    t_HelpercBs eZdZdZdZRS(sYDefine the built-in 'help'. This is a wrapper around pydoc.help (with a twist). cCsdS(NsHType help() for interactive help, or help(object) for help about object.((R((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRscOsddl}|j||S(Ni(tpydocthelp(RRttkwdsR((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs (RRRRR(((s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs cCstt_dS(N(RRR(((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt sethelperscCstjdkrddl}ddl}|jd}|jdry|j|Wqtk rddl}|j |j | Build sys.path correctly. $VENV/local/lib64/python3.4/site-packages $VENV/local/lib/python3.4/site-packages $VENV/lib64/python3.4 $VENV/lib/python3.4 $VENV/lib64/python3.4/site-packages $VENV/lib/python3.4/site-packages $VENV/lib64/python3.4/lib-dynload $VENV/lib/python3.4/lib-dynload /usr/local/lib64/python3.4/site-packages /usr/local/lib/python3.4/site-packages /usr/lib64/python3.4 /usr/lib/python3.4 /usr/lib64/python3.4/plat-linux /usr/lib64/python3.4/dist-packages /usr/lib/python3.4/dist-packages /usr/lib64/python3.4/lib-dynload This is called once with sys_prefix=$VENV (sys_prefix=sys.prefix). If the virtualenv is created with the --system-site-packages option, this is also called with sys_prefix=/usr (sys_prefix=sys.real_prefix). RGRNis site-packagessplat-{platform}RVs dist-packagess lib-dynloadN( RRRRR RR(RtformatRVt real_prefixR,RF(R`R"t local_prefixRbRNRdRcR8((s+/home/ec2-user/fle2/lib64/python2.7/site.pytvirtualenv_search_pathsGs&      %  c Csttjjtjjtd}|jjt_ |j d}g}tjddkrr|d7}nt rtjjtj dg}n}t rtj dkrdtj d}n4tjdkrd tj d }nd tj d }tjjtj d tjjtj d |g}tjdkra|jdtjjtj d d|n|}x|D]D}tjj|dtj}tjj|rp|j|qpqpWnXtjdkrtjjtj dtjjtj dg}ntjjtj ddtjd g}|}tjjtj ddtjd }tjj|rtr~|jd|q|j|nyttdtj}Wntk rtj}nXtjjtj ddtjd d|}tjj|r|j|nxKt|D]=}tjj|d} tjj| r |j| q q Wtjdkrg|D](} dD]} tjj| | ^qqw} x3| D](}tjj|r|j|qqWntjj|dS( Nsorig-prefix.txtiiRiRJis%dis%d.%ds%d.%d.%dtlib_pypys lib-pythoni s modified-%ssplat-%sRtDLLsRMRNRPtimplementationslib-tkRKs plat-darwinsplat-macsplat-mac/lib-scriptpackages(ii(ii(ii (s plat-darwinsplat-macsplat-mac/lib-scriptpackages(R3RRR R)RRtstripRRR7R RWt version_infoRR[RVR6RR(RZRt _multiarchR]tlisttextend( Rtposthardcoded_relative_dirsRtcpyverRt plat_patht lib64_pathtarchttk_dirt relative_dirtmodulethardcoded_paths((s+/home/ec2-user/fle2/lib64/python2.7/site.pytvirtual_install_main_packagessn'  3)&    ( cCsjttdd}xDttjD]3\}}||kr"|jtjr"|}q"q"W|dt_dS(s Force easy_installed eggs in the global environment to get placed in sys.path after all packages inside the virtualenv. This maintains the "least surprise" result that packages in the virtualenv always mask global packages, never the other way around. t __egginsertiiN(RRt enumerateRR RcR(t egginsertRR((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt+force_global_eggs_after_local_site_packagess  cCstt|dtjS(NR`(RRhRR(R"((s+/home/ec2-user/fle2/lib64/python2.7/site.pytvirtual_addsitepackagesscCsug}g}xItjD]>}|dks7|jdrG|j|q|j|qW|t_tjj|dS(sAdjust the special classpath sys.path entries for Jython. These entries should follow the base virtualenv lib directories. RRN(RRR RR(Rt classpathsR((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt fixclasspaths cCs(yddl}Wntk r#nXdS(s,Run custom user specific code, if available.iN(t usercustomizeR(R((s+/home/ec2-user/fle2/lib64/python2.7/site.pytexecusercustomizes cs;ttjfd}g|D]}||^q%S(Ncs7x0|jtjr2|tjkr2| }qW|S(N(RBRRX(R(t slash_len(s+/home/ec2-user/fle2/lib64/python2.7/site.pyRs$(RRRX(RRR((Rs+/home/ec2-user/fle2/lib64/python2.7/site.pytstrip_trailing_slashessc CsNitjdd6tjdd6}dj|}dj|}t}xdD]}xtj|d jd |ftj||d ftj||d ftj||d jdtjffD]}|jtjj |qWqPWg}xTt tjD]C\} } | |kr0| |kr0| |kr0qn|j | qW|t_dS(s| Remove irrelevant paths from sys.path, e.g. $VENV/lib64/pythonXY.zip $VENV/lib64/pythonX.Y/lib-old These are artifacts of python 2.4 and are no longer needed. Only touch paths added by the virtual_install_main_packages function. If these paths are at the end of sys.path because they were added by a .pth file or some other means, don't touch them. itmajoritminorspython{major}.{minor}spython{major}{minor}RPRMs {python}.zipRNslib-tkslib-oldsplat-{platform}RVN(slib64slib( RRRRRcRVR RRR RR( toriginal_pathstcount_paths_to_toucht format_varsRNt python_no_dott to_removetlib_dirtpath_componentst new_pathsRR((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt prune_pathss*   +!   cCsg}xgttjD]V\}}|t|kr_||kr_|tjt|kr_qn|j|qWttjt|}|t_|S(s1 Re-order paths in sys.path With virtualenv_search_paths, we've added to sys.path all the right search paths in the right order. Before these calls, there are a few paths already in sys.path that are necessary to create the virtualenv, e.g. $VENV/lib64/python3.4 $VENV/lib64/python3.4/plat-linux $VENV/lib64/python3.4/lib-dynload /usr/lib64/python3.4 /usr/lib/python3.4 This function prunes out the paths originially used to construct the virtualenv if they are somewhere later in sys.path. (RRRRR(RRRRtcount_paths_removed((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt reorder_paths(s  cCsttttj}ttjtjdkrktjrktjj tjddkrkt nt r{t ntjj tjjtjjtd }|stantdkrtanttj}t|}t|}|r ttjn ttjtjdkr3tnttttt t!trmt"nt#tdrt`$nttjt_t%|}t&|t'||dS(NtposixitModulessno-global-site-packages.txtRHR((RRRRRRRcRR9tbasenameR+R RR6R R)RRoR{RRqRRhRRRRVRRRRRRRRRRRRR(RtGLOBAL_SITE_PACKAGESt paths_in_sysR((s+/home/ec2-user/fle2/lib64/python2.7/site.pytmainFsF   .          cCsd}tjd}|sdGHxtjD]}d|fGHq(WdGHd}dt|tfGHdt|tfGHd tGHtjd ng}d |kr|jtnd |kr|jtn|rBtj j |GHtrtjd q}tt krtjdq}tdkr2tjd q}tjdn;ddl }|j|tjd tj fGHtjddS(Ns %s [--user-base] [--user-site] Without arguments print some useful information With arguments print the value of USER_BASE and/or USER_SITE separated by '%s'. Exit codes with --user-base or --user-site: 0 - user site directory is enabled 1 - user site directory is disabled by user 2 - uses site directory is disabled by super user or for security reasons >2 - unknown error is sys.path = [s %r,t]cSstjj|rdSdSdS(NR6s doesn't exist(RRR,(R((s+/home/ec2-user/fle2/lib64/python2.7/site.pyR6ssUSER_BASE: %r (%s)sUSER_SITE: %r (%s)sENABLE_USER_SITE: %ris --user-bases --user-siteiiii (RtargvRRyRzR{RRRtpathsepR RoRttextwraptdedent(RRtRR6tbufferR((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt_script|s:        "t__main__I(;RRRt __builtin__RRRRtsetsRRcRatPREFIXESRR{RzRyRRZRRWRVR ttypeRRRR$R+R/R=RFRhRqRRRRRRRRRRRRRRRRRRRRRRRRR(((s+/home/ec2-user/fle2/lib64/python2.7/site.pyt@sl    '    L  5  @       : K     *  4 4