a ? ^6U@s&dZddlZddlZddlZddlZddlZejejgada da da ddZ ddZ ddZd d Zd d Zd2d dZddZddZddZddZddZddZd3ddZd4ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Z d-d.Z!ej"j#s e!d/d0Z$e%d1kr"e$dS)5a Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** 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. 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. If a file named "pyvenv.cfg" exists one directory above sys.executable, sys.prefix and sys.exec_prefix are set to that directory and it is also checked for site-packages (sys.base_prefix and sys.base_exec_prefix will always be the "real" prefixes of the Python installation). If "pyvenv.cfg" (a bootstrap configuration file) contains the key "include-system-site-packages" set to anything other than "false" (case-insensitive), the system-level prefixes will still also be searched for site-packages; otherwise they won't. All of the resulting site-specific 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. The readline module is also automatically configured to enable completion for systems that support it. This can be overridden in sitecustomize, usercustomize or PYTHONSTARTUP. Starting Python in isolated mode (-I) disables automatic readline configuration. After these operations, 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. NcGs@tjj|}ztj|}Wnty.Yn0|tj|fSN)ospathjoinabspathOSErrornormcase)pathsdirr /usr/lib64/python3.9/site.pymakepath[s   r c CsttjD]z}tt|dddddvr,qztj|j|_Wnt t t fyXYn0ztj|j |_ Wqt t t fyYq0qdS)zESet all module __file__ and __cached__ attributes to an absolute path __loader__N __module__)_frozen_importlib_frozen_importlib_external) setsysmodulesvaluesgetattrrrr__file__AttributeErrorr TypeError __cached__)mr r r abs_pathsdsrcCsPg}t}tjD],}t|\}}||vr||||q|tjdd<|S)zK Remove duplicate entries from sys.path along with making them absoluteN)rrrr appendadd)L known_pathsr dircaser r r removeduppathsts    r"c CsTt}tjD]B}z&tj|r4t|\}}||Wq tyLYq Yq 0q |S)zEReturn a set containing all existing file system items from sys.path.)rrrrexistsr rr)ditem_itemcaser r r _init_pathinfos     r(c Cs|durt}d}nd}tj||}ztt|}WntyNYdS0|t|D]\}}| drtq`zZ| drt |Wq`| }t ||\}} | |vrtj |rtj||| Wq`tyRtd|d|tjdd dl} | jtD](} | D]}td |tjdqqtd tjdYqVYq`0q`Wdn1sl0Y|rd}|S) zProcess 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 '. NTF#)zimport zimport z"Error processing line {:d} of {}: )filerz z Remainder of file ignored)r(rrrio TextIOWrapper open_coder enumerate startswithexecrstripr r#rrr Exceptionprintformatstderr tracebackformat_exceptionexc_info splitlines) sitedirnamer resetfullnamefnliner r!r7recordr r r addpackagesF     0rCcCs|durt}d}nd}t|\}}||vrBtj|||zt|}WntydYdS0dd|D}t |D]}t |||q||rd}|S)zTAdd 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'NTFcSsg|]}|dr|qS)z.pth)endswith).0r<r r r zaddsitedir..) r(r rrrrrlistdirrsortedrC)r;r r= sitedircasenamesr<r r r addsitedirs$     rLcCs`tjjr dSttdr4ttdr4ttkr4dSttdr\ttdr\ttkr\dSdS)a,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 FgetuidgeteuidNgetgidgetegidT) rflags no_user_sitehasattrrrNrMrPrOr r r r check_enableusersites rTcCsztjdd}|r|Sdd}tjdkrBtjdp6d}||dStjdkrptjrp|dd tjd tjdd S|dd S) NPYTHONUSERBASEcWstjtjj|Sr)rr expanduserr)argsr r r joinusersz_getuserbase..joinuserntAPPDATA~PythondarwinLibraryz%d.%dz.local)renvirongetr<rplatform _framework version_info)env_baserXbaser r r _getuserbases   rgcCsdtj}tjdkr,|d|d|ddStjdkrFtjrF|dS|d|dd |dd S) NrYz\Pythonrr*z\site-packagesr]z/lib/python/site-packagesz /lib/python.z/site-packages)rrdrr<rbrc)userbaseversionr r r _get_path s   rkcCstdurtatS)zReturns the `user base` directory path. The `user base` directory can be used to store data. If the global variable ``USER_BASE`` is not initialized yet, this function will also set it. N) USER_BASErgr r r r getuserbasesrmcCst}tdurt|atS)zReturns the user-specific site-packages directory path. If the global variable ``USER_SITE`` is not initialized yet, this function will also set it. N)rm USER_SITErk)rir r r getusersitepackages#srocCs$t}tr tj|r t|||S)zAdd a per user site-package to sys.path Each user has its own python directory with site-packages in the home directory. )roENABLE_USER_SITErrisdirrL)r user_siter r r addusersitepackages1s rsc Csg}t}|durt}|D]}|r||vr,q||tjg}tjdkrR|dtjdkr|D].}tj ||dtj ddd}||q`q|||D]}tj ||d}||qq|S)aReturns a list containing all global site-packages directories. For each directory present in ``prefixes`` (or the global ``PREFIXES``), this function will find its `site-packages` subdirectory depending on the system environment, and will return a list of full paths. Nlib/z python%d.%dr_z site-packages) rPREFIXESrr platlibdirrrseprrrd)prefixes sitepackagesseenprefixlibdirslibdirrr r r getsitepackages?s.       rcCsBtrdtjvrtddt|D]}tj|r"t||q"|S)zAdd site-packages to sys.path '/usr/local' is included in PREFIXES if RPM build is not detected to make packages installed into this location visible. RPM_BUILD_ROOTrz /usr/local) rprr`rvinsertrrrqrL)r ryr;r r r addsitepackagescs     rcCs4tjdkrd}nd}td|t_td|t_dS)zDefine new builtins 'quit' and 'exit'. These are objects which make the interpreter exit when called. The repr of each object contains a hint at how it works. \zCtrl-Z plus ReturnzCtrl-D (i.e. EOF)quitexitN)rrx _sitebuiltinsQuitterbuiltinsrr)eofr r r setquitrs  rcCstdtjt_tjdddkr2tddt_ntddt_gg}}ttdrtj tj }| d d g| tj |tj|tjgtd d ||t_dS) z)Set 'copyright' and 'credits' in builtins copyrightNjavacreditsz?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_PrinterrrrrbrrSrrdirnamerextendrpardircurdirr)filesdirsherer r r setcopyrights"  rcCstt_dSr)r_Helperrhelpr r r r sethelpersrcCsdd}|t_dS)ajEnable default readline configuration on interactive prompts, by registering a sys.__interactivehook__. If the readline module can be imported, the hook will set the Tab key as completion key and register ~/.python_history as history file. This can be overridden in the sitecustomize or usercustomize module, or in a PYTHONSTARTUP file. csddl}zddlddl}Wnty0YdS0tdd}|durZd|vrZdn dz WntyYn0dkrt j t j ddz WntyYn0fd d }||dS) Nr__doc__libeditzbind ^I rl_completez tab: completer[z.python_historyc s*zWnttfy$Yn0dSr)write_history_fileFileNotFoundErrorPermissionErrorr historyreadliner r write_historyszCenablerlcompleter..register_readline..write_history)atexitr rlcompleter ImportErrorrparse_and_bindread_init_filerget_current_history_lengthrrrrVread_history_fileregister)rr readline_docrr rr register_readlines0         z,enablerlcompleter..register_readlineN)r__interactivehook__)rr r r enablerlcompleters 0rcCs^tj}tjdkr*d|vr*tjd}t_ntj}tjtj|\}}tj |}dt_ d}ddtj ||tj ||fD}|rZ|d}d} t |dd f} | D]P} d | vr| d \} }} | } | } | d kr| } q| d kr| t_ qWdn1s0Y|t_t_t|tjg| dkrNtdtjn tjgad a|S)Nr]__PYVENV_LAUNCHER__z pyvenv.cfgcSsg|]}tj|r|qSr )rrisfile)rEconffiler r r rFs zvenv..rtruezutf-8)encoding=zinclude-system-site-packageshomeF)rr`rrb_base_executable executablersplitrr_homeropen partitionstriplowerr| exec_prefixrrvrrp)r envrexe_dirr& site_prefix conf_basenamecandidate_confs virtual_conf system_siter?rAkeyvaluer r r venvsB     (  rc CszDz ddl}Wn2ty@}z|jdkr*nWYd}~n d}~00WnTty}z2 - 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-siteFr_ )rargvrmror4rrrqrprrrlrnpathseprtextwrapdedent)rrW user_baserrr bufferrr r r _scriptVsD           r__main__)N)N)N)&rrrrrr,r|rrvrprnrlr rr"r(rCrLrTrgrkrmrorsrrrrrrrrrrrQno_siterrr r r r sHG   *     $ ;4 3