efFRdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZddlmZddlmZdZd Zejd krdad Zd Zd ZdZdZdZdZe jdZdZdZ ddZ!dxa"xa#a$dZ%dZ&ddZ'dZ( ddZ)dZ*dS) zudistutils.util Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. N)DistutilsPlatformErrorDistutilsByteCompileError)newer)spawn)logctjdkrTtjdkrDdtjvrdSdtjvrdStjdkr_tjdkrOt td r:tj\}}}}}|d d d krd dlm }||||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. )ntz(arm) win-arm32z(arm64) win-arm64)r posixunameNr aixr) aix_platform) sys version_infoosnameversionlowerhasattrr py38compatr sysconfig get_platform)osnamehostreleasermachiners z/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/util.pyget_host_platformr#s &  7d??#+++----"{CK--////"{ &  7g  '"g"6"6 68hjj 3FD'7GbqbzU""444444#|FGW===  ! # ##ctjdkrIddddd}tjd}||p t St S)Nr win32z win-amd64r r)x86x64armarm64VSCMD_ARG_TGT_ARCH)rrenvirongetr#)TARGET_TO_PLATtargets r"rr3sg w$     455!!&))@->-@-@@   r$darwinMACOSX_DEPLOYMENT_TARGETc dadS)zFor testing only. Do not call.N)_syscfg_macosx_verr$r"_clear_cached_macosx_verr5Esr$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)r3 distutilsrget_config_varMACOSX_VERSION_VAR)rvers r"!get_macosx_target_ver_from_syscfgr<KsH!''''''&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-r: split_versionr) syscfg_verenv_vermy_msgs r"get_macosx_target_verrDXs344Jjnn/00G  1j))b!W44g&&"a00(((,3GGZZZ,AA  )00 0 r$c@d|dDS)zEConvert a dot-separated string into a list of numbers for comparisonsc,g|]}t|Sr4)int).0ns r" z!split_version..zs ) ) )qCFF ) ) )r$.)split)ss r"r@r@xs ) )AGGCLL ) ) ))r$cLtjdkr|S|s|S|ddkrtd|z|ddkrtd|z|d}d|vr|dd|v|s tjStjj|S)aReturn 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. /rzpath '%s' cannot be absolutezpath '%s' cannot end with '/'rK)rsep ValueErrorrLremovecurdirpathjoin)pathnamepathss r" convert_pathrY}s v}} {c7(BCCC|s88CDDD NN3  E ,, S ,, y 7< r$ctjdkrgtj|s tj||Stj||ddStjdkrXtj|\}}|ddkr |dd}tj||St dtjd) 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 r\znothing known about platform '')rrrUisabsrV splitdriver)new_rootrWdriverUs r" change_rootras  w'w}}X&& 87<<(33 37<<(122,77 7 D**844  7d??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)rfs r" check_environrks 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|fVdSNstr)rHrvalues r" zsubst_vars..s1KKu4U$KKKKKKr$zinvalid variable N) rkdictrr,updateitems _subst_compat format_maprjrR)rM local_varslookupvars r" subst_varsr{sOOO "*  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)rMrreplrs r"rvrvs\ ''' 6/ ; ;D qyy ;     Kr$error: c&|t|zSrnro)excprefixs r"grok_environment_errorrs CHH r$ctjdtjzatjdatjdadS)Nz [^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")rcompilestring whitespace _wordchars_re _squote_re _dquote_rer4r$r" _init_regexrs>J/&2CCDDM011J011JJJr$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||z|\}}|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. Nrr[rr\"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?))rrstriprendlenappendrrlstriprr RuntimeErrorrRspan)rMwordsposmrbegs r" split_quotedrs    A E C %   3 ' 'eegg #a&&== LL4C4 ! ! !  S6V& & & LL4C4 ! ! !#$$  ACC sVt^^$3$!C!GII,&A'CCv}}$$Q,,33$$Q,,"#F3#OPPPy !E#!NOOOJS#$3$!C!GcAg-..3448A%%''A+C #a&&== LLOOO K %N Lr$c|6d|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}z,)r))format__name__rinfo)funcargsmsgverbosedry_runs r"executerAsp {oodmT22 rss8t  ad)c/CHSMMM  d r$c|}|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)rInoffalseoff0rzinvalid truth value {!r})rrRr)vals r" strtoboolrTsP ))++C 222q 5 5 5q3::3??@@@r$ctjrtd||dk}|s ddlm}|d\} } n##t $rddlm} d| d} } YnwxYwtjd| |s| tj | d } nt| d } | 5| d | d tt|d z| d |d|d|d|d|d dddn #1swxYwYtjg} | t%j| | t+| |t-tj| fd| z|dSddlm}|D]@}|dddkr|dkr,|dkrdn|}t4j||}nt4j|}|}|rG|dt;||krt=d|d||t;|d}|r tj ||}tj |}|rO|stC||r'tjd|||s ||||*tj"d||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.NTr)mkstempz.py)mktempz$writing byte-compilation script '%s'wz2from 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=0, direct=1) )rz removing %s)rr7) optimizationzinvalid prefix: filename z doesn't start with zbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)#rdont_write_bytecodertempfilerrirrrrfdopenopenwriterVmaprepr executableextend subprocess"_optim_args_from_interpreter_flagsrrrrS py_compiler importlibutilcache_from_sourcerrRrUbasenamerdebug)py_filesoptimizeforcerbase_dirrrdirectr script_fd script_namerscriptcmdrfileoptcfiledfile cfile_bases r" byte_compilerdsP G'(EFFF~'1} ZY ; ( ( ( ( ( ('.wu~~ $Y  ; ; ; ' ' ' ' ' ''+VVE]] YYY ; 7EEE! $9c22k3//   " UZZD((;(;<=;+FPWXXXXXX '&&&&& Y YDBCCyE!! 1}}$MMbbx!88C8PP!88>>E - #f++ &&00$*44)c&kkmm, 6 Xu55))%00J YYE$..YH6jIII"4eU333IEtZXXXA Y Ys"=AA!A9D&&D*-D*cZ|d}d}||S)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 )rLrV)headerlinesrQs r" rfc822_escapers* LL  E C 88E??r$)r)Nrr)rrNNrrN)+__doc__importlib.utilrrrrrrr functoolserrorsrr _modifiedrr_logrr#rplatformr3r:r5r<rDr@rYra lru_cacherkr{rvrrrrrrrrrrr4r$r"rsF   EEEEEEEE$$$:   <8/   @***    :NNN*,,,,444&(+/. . Z222<<<D& A A A$   TYTYTYTYnr$