bgDdZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZddlmZddlmZmZdd lmZd Zd Ze jd krdad ZdZdZdZdZ ed&dZ!dZ"ej#dZ$dZ%dZ&d'dZ'dxa(xa)a*dZ+dZ,d(d Z-d!Z. d)d#Z/d$Z0d%Z1dS)*zudistutils.util Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. ) annotationsN) pass_none)log)newer)DistutilsByteCompileErrorDistutilsPlatformError)spawnctjdkr_tjdkrOt tdr:tj\}}}}}|dddkrddlm}||||Stj S) z Return a string that identifies the current platform. Use this function to distinguish platform-specific build directories and platform-specific built distributions. ) posixunameNr aixr) aix_platform) sys version_infoosnamehasattrr compat.py38r sysconfig get_platform)osnamehostreleaseversionmachiners Q/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/util.pyget_host_platformr s &  7g  '"g"6"6 68hjj 3FD'7GbqbzU""555555#|FGW===  ! # ##ctjdkrIddddd}tjd}||p t St S)Nntwin32z win-amd64z win-arm32z win-arm64)x86x64armarm64VSCMD_ARG_TGT_ARCH)rrenvirongetr )TARGET_TO_PLATtargets rrr2sg w$     455!!&))@->-@-@@   r!darwinMACOSX_DEPLOYMENT_TARGETc dadS)zFor testing only. Do not call.N)_syscfg_macosx_verr!r_clear_cached_macosx_verr3Dsr!c`t!ddlm}|jtpd}|r|atS)zGet the version of macOS latched in the Python interpreter configuration. Returns the version as a string or None if can't obtain one. Cached.Nr)r)r1 distutilsrget_config_varMACOSX_VERSION_VAR)rvers r!get_macosx_target_ver_from_syscfgr:JsH!''''''&i&'9::@b  %!$  r!ct}tjt}|rQ|rMt |ddgkr8t |ddgkr#dtzd|d|dz}t ||S|S)aReturn the version of macOS for which we are building. The target version defaults to the version in sysconfig latched at time the Python interpreter was built, unless overridden by an environment variable. If neither source has a value, then None is returned r $z mismatch: now "z" but "z*" during configure; must use 10.3 or later)r:rr*r+r8 split_versionr ) syscfg_verenv_vermy_msgs rget_macosx_target_verrBWs344Jjnn/00G  1j))b!W44g&&"a00((,),),)(2,),),))  )00 0 r!c@d|dDS)zEConvert a dot-separated string into a list of numbers for comparisonsc,g|]}t|Sr2)int).0ns r z!split_version..ys ) ) )qCFF ) ) )r!.)split)ss rr>r>ws ) )AGGCLL ) ) ))r!pathnamestr | os.PathLikereturnstrcNtjtj|S)a. Allow for pathlib.Path inputs, coax to a native path string. If None is passed, will just pass it through as Setuptools relies on this behavior. >>> convert_path(None) is None True Removes empty paths. >>> convert_path('foo/./bar').replace('\\', '/') 'foo/bar' )rfspathpathlibPurePath)rLs r convert_pathrT|s 9W%h// 0 00r!ctjdkrgtj|s tj||Stj||ddStjdkrbtj|\}}|dtjkr |dd}tj||Stdtjd)a Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. rrNr#rznothing known about platform '')rrpathisabsjoin splitdrivesepr )new_rootrLdriverWs r change_rootr^s  w'w}}X&& 87<<(33 37<<(122,77 7 D**844  7bf  8Dw||Hd+++ !L"'!L!L!L M MMr!cDtjdkrddtjvrV ddl}|tjdtjd<n#t tf$rYnwxYwdtjvrttjd<dSdS)aLEnsure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platform()') rHOMErNPLAT) rrr*pwdgetpwuidgetuid ImportErrorKeyErrorr)rcs r check_environrhs w'fBJ66  JJJ!$bikk!:!:1!=BJv  X&    D  RZ)^^ 6 s=AA21A2c@tttj}|d|D t ||S#t$r}td|d}~wwxYw)a Perform variable substitution on 'string'. Variables are indicated by format-style braces ("{var}"). Variable is substituted by the value found in the 'local_vars' dictionary or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guarantee that it contains certain values: see 'check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'. c3>K|]\}}|t|fVdSNrO)rFrvalues r zsubst_vars..s1KKu4U$KKKKKKr!zinvalid variable N) rhdictrr*updateitems _subst_compat format_maprg ValueError)rK local_varslookupvars r subst_varsrxsOOO "*  F MMKK 8H8H8J8JKKKKKK4Q**6222 4442S223334s!A<< BBBcd}tjd||}||krddl}|dt|S)zb Replace shell/Perl-style variable substitution with format-style. For compatibility. c4d|ddS)N{r})group)matchs r_substz_subst_compat.._substs&EKKNN&&&&r!z\$([a-zA-Z_][a-zA-Z_0-9]*)rNz-shell/Perl-style substitutions are deprecated)resubwarningswarnDeprecationWarning)rKrreplrs rrrrrs\ ''' 6/ ; ;D qyy ;     Kr!error: c&|t|zSrkrl)excprefixs rgrok_environment_errorrs CHH r!ctjdtjdatjdatjdadS)Nz[^\\\'\"z ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")rcompilestring whitespace _wordchars_re _squote_re _dquote_rer2r!r _init_regexrsDJA6+<AAABBM011J011JJJr!c$tt|}g}d}|rt||}|}|t |kr||d|n~||tjvr=||d|||d }d}n||dkr|d|||dzdz}|dz}n||dkrt||}n@||dkrt||}ntd||z|td||d |\}}|d|||dz|dz z||dz}|d z }|t |kr||n||S) aSplit a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The backslash is stripped from any two-character escape sequence, leaving only the escaped character. The quote characters are stripped from any quoted string. Returns a list of words. Nr\rrV"z!this can't happen (bad char '%c')zbad string (mismatched z quotes?))rrstripr~endlenappendrrlstriprr RuntimeErrorrtspan)rKwordsposmrbegs r split_quotedrs   A E C %   3 ' 'eegg #a&&== LL4C4 ! ! !  S6V& & & LL4C4 ! ! !#$$  ACC sVt^^$3$!C!GII,&A'CCv}}$$Q,,33$$Q,,"#F3#OPPPy !L1S6!L!L!LMMMJS#$3$!C!GcAg-..3448A%%''A+C #a&&== LLOOO K %N Lr!Fc|&|j|}|dddkr |dddz}tj||s||dSdS)aPerform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to embody the "external action" being performed), and an optional message to print. Nz,)r))__name__rinfo)funcargsmsgverbosedry_runs rexecuter6sm {((( rss8t  ad)c/CHSMMM  d r!cf|}|dvrdS|dvrdStd|)zConvert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. )yyesttrueon1r)rGnoffalseoff0rzinvalid truth value )lowerrt)vals r strtoboolrIsJ ))++C 222q 5 5 5q777888r!Tctjrtd||dk}|sStjd\}} t jd| |stj|dd } | 5| d | d tt|d z| d |d|d|d|d|d dddn #1swxYwYtj g} | tj| | t%| |t'tj| fd| |dSddlm} |D]@} | dddkr|dkr,|dkrdn|}t.j| |}nt.j| }| }|rG| dt5||krt7d| d||t5|d}|r tj ||}tj|}|rO|st=| |r't jd| ||s | | ||*t jd| |BdS)a~Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O") 2 - extra optimization (like "python -OO") If 'force' is true, all files are recompiled regardless of timestamps. The source filename encoded in each bytecode file defaults to the filenames listed in 'py_files'; you can modify these with 'prefix' and 'basedir'. 'prefix' is a string that will be stripped off of each source filename, and 'base_dir' is a directory name that will be prepended (after 'prefix' is stripped). You can supply either or both (or neither) of 'prefix' and 'base_dir', as you wish. If 'dry_run' is true, doesn't actually do anything that would affect the filesystem. Byte-compilation is either done directly in this interpreter process with the standard py_compile module, or indirectly by writing a temporary script and executing it. Normally, you should let 'byte_compile()' figure out to use direct compilation or not (see the source for details). The 'direct' flag is used by the script generated in indirect mode; unless you know what you're doing, leave it set to None. zbyte-compiling is disabled.NTrz.pyz$writing byte-compilation script '%s'wzutf-8)encodingz2from distutils.util import byte_compile files = [ z, z] z byte_compile(files, optimize=z, force=z, prefix=z , base_dir=z, verbose=z+, dry_run=False, direct=True) )rz removing )rr5) optimizationzinvalid prefix: filename z doesn't start with zbyte-compiling %s to %sz%skipping byte-compilation of %s to %s) rdont_write_bytecodertempfilemkstemprrrfdopenwriterYmaprepr executableextend subprocess"_optim_args_from_interpreter_flagsrr rremove py_compiler importlibutilcache_from_sourcerrtrWbasenamerdebug)py_filesoptimizeforcerbase_dirrrdirect script_fd script_namescriptcmdrfileoptcfiledfile cfile_bases r byte_compilerYsP G'(EFFF~'1} NY#+#3E#:#: K 7EEE Yy#@@@F   " UZZD((;(;<+D{+D+DgVVVVVV '&&&&& Y YDBCCyE!! 1}}$MMbbx!88C8PP!88>>E - #f++ &&00$ZDZZPVZZc&kkmm, 6 Xu55))%00J YYE$..YH6jIII"4eU333IEtZXXX? Y Ys.A9C33C7:C7cd}|d}|o)|dd|dk}|r|nd}|||zS)zReturn a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. z T)keependsrr5) splitlinesrY)headerindentlinesends_in_newlinesuffixs r rfc822_escapersnF   t  , ,EFb 4 4 6 6q 9U2Y FO& .VVBF ;;u   &&r!cdtjdko tdS)zReturns True if the current platform is mingw. Python compiled with Mingw-w64 has sys.platform == 'win32' and get_platform() starts with 'mingw'. r$mingw)rplatformr startswithr2r!ris_mingwrs( <7 " I|~~'@'@'I'IIr!)rLrMrNrO)r)NFF)rFNNTFN)2__doc__ __future__r functoolsimportlib.utilrrrRrrrrrrjaraco.functoolsr_logr _modifiedrerrorsrr r r rrr1r8r3r:rBr>rTr^ lru_cacherhrxrrrrrrrrrrrrrr2r!rrs #"""""   &&&&&&EEEEEEEE$$$,   <8/   @***  111 1$NNN* ,,,,444&(+/. . Z222<<<D& 9 9 9$      HYHYHYHYV ' ' 'JJJJJr!