3 fS@sddlZddlZddlZddlZejejgadadada ddZ ddZ ddZ dd Z d d Zd-d d ZddZddZddZddZd.ddZd/ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zejjsed*d+Z e!d,kre dS)0Nc GsBtjj|}ytjj|}Wntk r0YnX|tjj|fS)N)ospathjoinabspathOSErrornormcase)pathsdirr /usr/lib64/python3.6/site.pymakepathZs  r cCsxttjjD]~}tt|dddddkr.qytjj|j|_Wnt t t fk r\YnXytjj|j |_ Wqt t t fk rYqXqWdS)N __loader__ __module___frozen_importlib_frozen_importlib_external)rr) setsysmodulesvaluesgetattrrrr__file__AttributeErrorr TypeError __cached__)mr r r abs_pathscsrcCsTg}t}x6tjD],}t|\}}||kr|j||j|qW|tjdd<|S)N)rrrr appendadd)L known_pathsr dircaser r r removeduppathsss   r!c CsXt}xLtjD]B}y&tjj|r6t|\}}|j|Wqtk rNwYqXqW|S)N)rrrrexistsr rr)ditem_itemcaser r r _init_pathinfos    r'c Csp|dkrt}d}nd}tjj||}yt|d}Wntk rHdSX| xt|D]\}}|jdrrq^yX|jd rt|w^|j }t ||\}} | |krtjj |rt jj ||j| Wq^tk rRtdj|d|t jd d dl} x>| jt jD],} x$| jD]}td |t jd qWqWtd t jd PYq^Xq^WWdQRX|rld}|S)NTFr#import import z"Error processing line {:d} of {}: )filerz z Remainder of file ignored)r*r+)r'rrropenr enumerate startswithexecrstripr r"rrr Exceptionprintformatstderr tracebackformat_exceptionexc_info splitlines) sitedirnamerresetfullnamefnliner r r7recordr r r addpackagesD    rCc Cs|dkrt}d}nd}t|\}}||krBtjj||j|ytj|}Wntk rddSXdd|D}xt |D]}t |||q~W|rd}|S)NTFcSsg|]}|jdr|qS)z.pth)endswith).0r<r r r szaddsitedir..) r'r rrrrrlistdirrsortedrC)r;rr= sitedircasenamesr<r r r addsitedirs$   rKcCs`tjjr dSttdr4ttdr4tjtjkr4dSttdr\ttdr\tjtjkr\dSdS)NFgetuidgeteuidgetgidgetegidT) rflags no_user_sitehasattrrrMrLrOrNr r r r check_enableusersites rScCs$tdk r tSddlm}|datS)Nr)get_config_varuserbase) USER_BASE sysconfigrT)rTr r r getuserbases  rXcCs^t}tdk rtSddlm}tjdkrJddlm}|drJ|ddatS|ddtjatS) Nr)get_pathdarwin)rTPYTHONFRAMEWORKpurelibosx_framework_userz%s_user) rX USER_SITErWrYrplatformrTrr<) user_baserYrTr r r getusersitepackagess    racCs$t}tr tjj|r t|||S)N)raENABLE_USER_SITErrisdirrK)r user_siter r r addusersitepackagess rec Csg}t}|dkrt}x|D]}| s||kr2q|j|tjdkr|jtjj|ddtj ddd|jtjj|ddtj dddn6|j||jtjj|dd|jtjj|ddtj d krd d l m }|d }|r|jtjjd |dtj dddqW|S)N/lib64pythonz site-packageslibz python%d.%drZr)rTr[z/Libraryz%d.%d)rPREFIXESrrseprrrrversion version_infor_rWrT)prefixes sitepackagesseenprefixrT frameworkr r r getsitepackages s4        rucCsFtrdtjkrtjddx&t|D]}tjj|r$t||q$W|S)NRPM_BUILD_ROOTrz /usr/local) rbrenvironrlinsertrurrcrK)rrpr;r r r addsitepackagesHs   rycCs4tjdkrd}nd}tjd|t_tjd|t_dS)N\zCtrl-Z plus ReturnzCtrl-D (i.e. EOF)quitexit)rrm _sitebuiltinsQuitterbuiltinsr{r|)eofr r r setquitWs  rcCstjdtjt_tjdddkr2tjddt_ntjddt_gg}}ttdrtj j tj }|j dd g|j tj j |tj|tjgtjd d ||t_dS) N copyrightjavacreditsz?Jython is maintained by the Jython developers (www.jython.org).z Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.rz LICENSE.txtLICENSElicensez'See https://www.python.org/psf/license/)r}_Printerrrrr_rrRrrdirnamerextendrpardircurdirr)filesdirsherer r r setcopyrightgs    rcCstjt_dS)N)r}_Helperrhelpr r r r sethelpersrcCsdd}|t_dS)Ncsddl}yddlddl}Wntk r0dSXtdd}|dk rZd|krZjdn jdy jWntk rYnXjdkrt j j t j j ddyj Wntk rYnXfd d }|j|dS) Nr__doc__libeditzbind ^I rl_completez tab: complete~z.python_historyc s,yjWnttfk r&YnXdS)N)write_history_fileFileNotFoundErrorPermissionErrorr )historyreadliner r write_historyszCenablerlcompleter..register_readline..write_history)atexitr rlcompleter ImportErrorrparse_and_bindread_init_filerget_current_history_lengthrrr expanduserread_history_fileIOErrorregister)rr readline_docrr )rrr register_readlines.      z,enablerlcompleter..register_readline)r__interactivehook__)rr r r enablerlcompleters 0rc CsFtj}tjdkr$d|kr$tjd}ntj}tjjtjj|\}}tjj|}dt_ d}ddtjj ||tjj ||fD}|rB|d}d} t |dd `} xX| D]P} d | kr| j d \} }} | j j} | j } | d kr| j} q| d kr| t_ qWWdQRX|t_t_t|tjg| dkr6tjdtjn tjgad a|S)NrZ__PYVENV_LAUNCHER__z pyvenv.cfgcSsg|]}tjj|r|qSr )rrisfile)rEconffiler r r rFszvenv..rtruezutf-8)encoding=zinclude-system-site-packageshomeF)rrwrr_ executablersplitrr_homerr. partitionstriplowerrs exec_prefixryrlrxrb)renvrexe_dirr% site_prefix conf_basenamecandidate_confs virtual_conf system_siter?rAkeyvaluer r r venvs>        rcCsyBy ddl}Wn0tk r>}z|jdkr,nWYdd}~XnXWnRtk r}z6tjjrltjtjntj j d|j j |fWYdd}~XnXdS)Nr sitecustomizez@Error in sitecustomize; set PYTHONVERBOSE for traceback: %s: %s ) rrr<r3rrPverbose excepthookr9r6write __class____name__)rexcerrr r r execsitecustomizes  rcCsyBy ddl}Wn0tk r>}z|jdkr,nWYdd}~XnXWnRtk r}z6tjjrltjtjntj j d|j j |fWYdd}~XnXdS)Nr usercustomizez@Error in usercustomize; set PYTHONVERBOSE for traceback: %s: %s ) rrr<r3rrPrrr9r6rrr)rrrr r r execusercustomizes  rcCsftt}t|}tdkr"tat|}t|}ttt t j j sRt ttrbtdS)N)rr!rrbrSreryrrrrrPisolatedrrr)rr r r mainsrcCs`d}tjdd}|st}t}tdxtjD]}td|fq2Wtdtd|tjj|rfdndftd |tjj|rdndftd ttj d g}d |kr|j t d |kr|j t |r,ttj j|trtj d n6tdkr tj dn tdkr tj dn tj dn0d dl}t|j|tjd tj ftj ddS)Na %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 r,z sys.path = [z %r,]zUSER_BASE: %r (%s)r"z doesn't existzUSER_SITE: %r (%s)zENABLE_USER_SITE: %rrz --user-basez --user-siteFrkri )rargvrXrar4rrrcrbr|rrVr^pathseprtextwrapdedent)rargsr`rdr bufferrr r r _script6s@           r__main__)N)N)N)"rrrr}rsrrlrbr^rVr rr!r'rCrKrSrXrareruryrrrrrrrrrPno_siterrr r r r Hs@   *  ( ;43