U Wzf_Q@sdZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZd d Zd d ZddZddZdaddZddZd+ddZdaaaddZddZd,ddZdd Z d-d!d"Z!d#d$Z"d.d%d&Z#d/d'd(Z$Gd)d*d*Z%dS)0zudistutils.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 CstjdkrFdtjkrdSdtjkr.dSdtjkr@dStjSdtjkrZtjdStjd 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)z win-arm64_PYTHON_HOST_PLATFORMposixuname/ _-Nlinuxz%s-%ssunosr5solarisz%d.%s32bit64bit)ilz.%saixr) aix_platformcygwinz[\d.]+darwinz%s-%s-%s)osnamesysversionlowerplatformenvironhasattrrreplaceintmaxsizeZ py38compatrrecompileASCIImatchgroup _osx_supportdistutils.sysconfigget_platform_osx sysconfigget_config_vars) osnamehostreleaser&machinebitnessrrel_remr3 distutilsr@r/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-slp6y8a5/setuptools/_distutils/util.pyget_host_platformsT             rBcCs8tjdkr.dddd}|tjdp,tStSdS)Nr win32r r )x86x64armVSCMD_ARG_TGT_ARCH)r#r$getr)rB)TARGET_TO_PLATr@r@rA get_platformds rJcCsztjdkr|S|s|S|ddkr.td||ddkrFtd||d}d|krd|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#sep ValueErrorsplitremovecurdirpathjoin)pathnamepathsr@r@rA convert_pathos       rVcCstjdkr._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s'N)rer.subrdrN)srgrivarr@r@rA subst_varss  rmerror: cCs |t|SN)rf)excprefixr@r@rAgrok_environment_errorsrrcCs(tdtjatdatdadS)Nz [^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r.r/string whitespace _wordchars_re _squote_re _dquote_rer@r@r@rA _init_regexs rxcCstdkrt|}g}d}|rt||}|}|t|krZ||d|q||tjkr||d|||d }d}n||dkr|d|||dd}|d}n||dkrt ||}n*||dkrt ||}nt d|||dkr 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. NrrWr'"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rurxstripr1endlenappendrsrtlstriprvrw RuntimeErrorrNspan)rkwordsposr>r|begr@r@rA split_quoteds@        ,   rcCsP|dkr6d|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_runr@r@rAexecute"s  rcCs2|}|dkrdS|dkr 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)nnoffalseoff0rzinvalid truth value %rN)r'rN)valr@r@rA strtobool5s rc CsRddl}tjrtd|dkr*do(|dk}|s>zddlm} | d\} } Wn.tk rzddlm} d| d} } YnXt d| |s| dk rt | d } n t | d } | B| d | d tt|d | d |||||fW5QRXtjg}|t|| t||dtt j| fd| |dnddlm}|D]}|dddkrhqN|dkr|dkrdn|}tjj||d}n tj|}|}|r|dt||krtd||f|t|d}|rt j||}t j |}|rN|st!||r.DistutilsRefactoringToolc_stj|f|dSro)rerror)selfrrkwr@r@rA log_errorsz4run_2to3..DistutilsRefactoringTool.log_errorcWstj|f|dSro)rrrrrr@r@rA log_messagesz6run_2to3..DistutilsRefactoringTool.log_messagecWstj|f|dSro)rrrr@r@rA log_debugsz4run_2to3..DistutilsRefactoringTool.log_debugN)r __module__ __qualname__rrrr@r@r@rADistutilsRefactoringToolsrz lib2to3.fixes)optionsT)r)lib2to3.refactorrrrefactor)files fixer_namesrexplicitrrrrr@r@rArun_2to3s  rc Csddlm}ddlm}ddlm}|} t} t|z | W5t| X| j | j dd<|r| D]} | } | sqr| | qrg} | j D]L} tj|| }|tj||tj|| |dd}|dr| |qtdd | D|||d | S) zRecursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in. r)mkpath) copy_file)FileListNr)updatecSsg|]}|dr|qS)r)r'endswith).0fnr@r@rA sz$copydir_run_2to3..)rrr)distutils.dir_utilrdistutils.file_utilrdistutils.filelistrr#getcwdchdirfindallallfilesr splitlinesr{process_template_linerRrSdirnamer~r)srcdesttemplaterrrrrrfilelistrQlinecopiedfilenameoutnameresr@r@rAcopydir_run_2to3s:          rc@s$eZdZdZdZdZdZddZdS) Mixin2to3zMixin class for commands that run 2to3. To configure 2to3, setup scripts may either change the class variables, or inherit from individual commands to override how 2to3 is invoked.NcCst||j|j|jSro)rrrr)rrr@r@rAr0szMixin2to3.run_2to3)rrr__doc__rrrrr@r@r@rAr s r)rn)Nrr)rrNNrrN)NNN)NNNN)&rr#r.Zimportlib.utilrrsr%distutils.errorsrdistutils.dep_utilrdistutils.spawnrr?rrZ py35compatrrBrJrVr\r_rermrrrurvrwrxrrrrrrrrr@r@r@rAsP      P   =    !