a  zeO@s(dZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZd d Zd d ZejdkrdadZddZddZddZddZddZddZdaddZddZd/d!d"Z da!a"a#d#d$Z$d%d&Z%d0d'd(Z&d)d*Z'd1d+d,Z(d-d.Z)dS)2zudistutils.util Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. N)DistutilsPlatformError)newer)spawn)log)DistutilsByteCompileError)"_optim_args_from_interpreter_flagsc CstjdkrFdtjvrdSdtjvr.dSdtjvr@dStjSdtjvrZtjdStjd ksnttd sttjSt\}}}}}| d d }| d d}| d d}|dddkrd||fS|dddkr,|ddkrd}dt |dd|ddf}ddd}|d|tj 7}n|dddkrVd d!l m }||||S|dd"d#krd#}td$tj}||}|r|}n>|dd"d%krddl} ddl} | | j|||\}}}d&|||fS)'aReturn a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. on Linux, the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. ntamd64 win-amd64z(arm) win-arm32z(arm64) win-arm64_PYTHON_HOST_PLATFORMposixuname/ _-Nlinuxz%s-%ssunosr5solarisz%d.%s32bit64bit)ilz.%saixr) aix_platformcygwinz[\d.]+darwinz%s-%s-%s)osnamesysversionlowerplatformenvironhasattrrreplaceintmaxsizeZ py38compatr recompileASCIImatchgroup _osx_supportdistutils.sysconfigget_platform_osx sysconfigget_config_vars) osnamehostreleaser'machinebitnessr rel_remr4 distutilsrA\/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/setuptools/_distutils/util.pyget_host_platformsP             rCcCs:tjdkr0ddddd}|tjdp.tStSdS)Nr win32r r r )x86x64armarm64VSCMD_ARG_TGT_ARCH)r$r%getr*rC)TARGET_TO_PLATrArArB get_platformds rLr#MACOSX_DEPLOYMENT_TARGETcCsdadS)zFor testing only. Do not call.N)_syscfg_macosx_verrArArArB_clear_cached_macosx_verusrOcCs.tdur*ddlm}|tp d}|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)r7r)rNr@r7get_config_varMACOSX_VERSION_VAR)r7verrArArB!get_macosx_target_ver_from_syscfgzs  rScCs^t}tjt}|rZ|rVt|ddgkrVt|ddgkrVdtd||f}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 overriden by an environment variable. If neither source has a value, then None is returned r$zE mismatch: now "%s" but "%s" during configure; must use 10.3 or later)rSr$r*rJrQ split_versionr)Z syscfg_verZenv_vermy_msgrArArBget_macosx_target_vers rXcCsdd|dDS)zEConvert a dot-separated string into a list of numbers for comparisonscSsg|] }t|qSrA)r-).0nrArArB z!split_version...)split)srArArBrVsrVcCsztjdkr|S|s|S|ddkr.td||ddkrFtd||d}d|vrd|dqP|sntjStjj|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. rrzpath '%s' cannot be absolutezpath '%s' cannot end with '/'r])r$sep ValueErrorr^removecurdirpathjoin)pathnamepathsrArArB convert_paths       ricCstjdkr._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s'N)rxr/subrwrb)r_rzr|varrArArB subst_varss  rerror: cCs |t|S)N)ry)excprefixrArArBgrok_environment_error srcCs(tdtjatdatdadS)Nz [^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r/r0string whitespace _wordchars_re _squote_re _dquote_rerArArArB _init_regexs rcCstdurt|}g}d}|rt||}|}|t|krZ||d|q||tjvr||d|||d }d}n||dkr|d|||dd}|d}n||dkrt ||}n*||dkrt ||}nt d|||dur t d|||\}}|d|||d|d||d}|d }|t|kr||qq|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. Nrrjr'"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rrstripr2endlenappendrrlstriprr RuntimeErrorrbspan)r_wordsposr?rbegrArArB split_quoteds>        ,   rcCsP|dur6d|j|f}|dddkr6|ddd}t||sL||dS)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%s%rz,)r))__name__rinfo)funcargsmsgverbosedry_runrArArBexecuteYs  rcCs2|}|dvrdS|dvr dStd|fdS)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)rZnoffalseoff0rzinvalid truth value %rN)r(rb)valrArArB strtoboolls rc Cshddl}tjrtd|dur*do(|dk}|sTzddlm} | d\} } Wn,tyxddlm} d| d} } Yn0t d| |s| durt | d } n t | d } | L| d | d tt|d | d |||||fWdn1s0Ytjg}|t|| t||dtt j| fd| |dnddlm}|D]}|dddkr~qd|dkr|dkrdn|}tjj||d}n tj|}|}|r|dt||krtd||f|t|d}|r t j||}t j |}|rd|s0t!||rRt d|||s`||||nt"d||qddS)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. rNzbyte-compiling is disabled.T)mkstempz.py)mktempz$writing byte-compilation script '%s'wz2from distutils.util import byte_compile files = [ z, z] z byte_compile(files, optimize=%r, force=%r, prefix=%r, base_dir=%r, verbose=%r, dry_run=0, direct=1) )rz removing %s)r0r) optimizationz1invalid prefix: filename %r doesn't start with %rzbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)# subprocessr&dont_write_bytecodertempfilerrvrrrr$fdopenopenwriterfmaprepr executableextendrrrrrc py_compiler0 importlibutilcache_from_sourcerrbrebasenamerdebug)py_filesoptimizeforcerbase_dirrrdirectrr script_fd script_namerscriptcmdr0fileoptcfiledfile cfile_baserArArB byte_compile|st$         &        rcCs|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 )r^rf)headerlinesrarArArB rfc822_escapes r)r)Nrr)rrNNrrN)*__doc__r$r/importlib.utilrrr&distutils.errorsrdistutils.dep_utilrdistutils.spawnrr@rrZ py35compatrrCrLr)rNrQrOrSrXrVrirorrrxrrrrrrrrrrrrArArArBsL      P    =