3 (\g!@s8dZddlmZmZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z e rpddlmZmZy ddlZWnRek ryddlmZWn,ek rddlZeje_eje_YnXYnXdd d d d d ddddg ZejeZe jd/krdZddlm Z n6ddl!Z!y e!j Z Wne"k r<dZ YnXe dk Ze jd0krXdZ#nddZ$ej%de$dZ#dd Z&e jd1krd2dd Z'n d3dd Z'dd Z(e jd4krdd l)m*Z*d!dZ+ndd"l!m,Z,d#dZ+d$d%Z-d&d'd(hZ.e j/j0d)p e j/d*ko ej1d+kZ2d,dZ3e4edr,d-dZ5nd.dZ5dS)5zKStuff that differs in different Python versions and platform distributions.)absolute_importdivisionN) text_type)MYPY_CHECK_RUNNING)TupleText) ipaddressr uses_pycacheconsole_to_str native_str get_path_uid stdlib_pkgsWINDOWSsamefileget_terminal_sizeget_extension_suffixesT)cache_from_sourcebackslashreplacecsRfddtjjD}tjddkr8dd|D}djdd|DjfS)Nc3s|]}j|VqdS)N)object).0i)errm/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/pip/_internal/utils/compat.py ?sz-backslashreplace_decode_fn..rcss|]}t|VqdS)N)ord)rbrrrrBscss|]}d|VqdS)z\x%xNr)rcrrrrCs)rangestartendsys version_infojoin)rZ raw_bytesr)rrbackslashreplace_decode_fn>sr)backslashreplace_decodec Cstj}| stj|jdkr"d}y|j|}Wn.tk r^tjd||j|t d}YnXt t t dddd}|r|j |dd}|j|}|S) a4Return a string, safe for output, of subprocess output. We assume the data is in the locale preferred encoding. If it won't decode properly, we warn the user but decode as best we can. We also ensure that the output can be safely written to standard output without encoding errors. asciizutf-8z5Subprocess output does not appear to be encoded as %s)errors __stderr__Nencodingr) localegetpreferredencodingcodecslookupnamedecodeUnicodeDecodeErrorloggerwarningr*getattrr&encode)datar.Z decoded_dataZoutput_encodingZoutput_encodedrrrr Ks$  FcCs"t|tr|jd|rdndS|S)Nzutf-8replacestrict) isinstancebytesr4)sr;rrrr s cCst|tr|jdS|S)Nzutf-8)r=rr9)r?r;rrrr s  cCs`ttdr6tj|tjtjB}tj|j}tj|n&tjj |sPtj |j}n t d||S)a) Return path's uid. Does not follow symlinks: https://github.com/pypa/pip/pull/935#discussion_r5307003 Placed this function in compat due to differences on AIX and Jython, that should eventually go away. :raises OSError: When path is a symlink or can't be read. O_NOFOLLOWz1%s is a symlink; Will not return uid for symlinks) hasattrosopenO_RDONLYr@fstatst_uidclosepathislinkstatOSError)rHfdfile_uidrrrr s     )EXTENSION_SUFFIXEScCstS)N)rNrrrrrs) get_suffixescCsddtDS)NcSsg|] }|dqS)rr)rsuffixrrr sz*get_extension_suffixes..)rOrrrrrscCs0tjj|}|jdr,|jdr,|dd}|S)zm Expand ~ and ~user constructions. Includes a workaround for https://bugs.python.org/issue14768 z~/z//N)rBrH expanduser startswith)rHexpandedrrrrSs  rSpythonwsgirefargparsewinclintcCsNttjdrtjj||Stjjtjj|}tjjtjj|}||kSdS)z>Provide an alternative for os.path.samefile on Windows/Python2rN)rArBrHrnormcaseabspath)file1file2path1path2rrrrs  cCs ttjS)z Returns a tuple (x, y) representing the width(x) and the height(y) in characters of the terminal window. )tupleshutilrrrrrrsc Csdd}|dp|dp|d}|sby(tjtjtj}||}tj|Wntk r`YnX|stjjddtjjdd f}t|dt|dfS) z Returns a tuple (x, y) representing the width(x) and the height(y) in characters of the terminal window. c SsZy4ddl}ddl}ddl}|jd|j||jd}Wntk rHdSX|dkrVdS|S)NrhhZ12345678)rr)fcntltermiosstruct unpack_fromioctl TIOCGWINSZ Exception)rLrerfrgcrrrr ioctl_GWINSZsz'get_terminal_size..ioctl_GWINSZrrRrLINESCOLUMNSP) rBrCctermidrDrGrkenvirongetint)rmrlrLrrrrs)rr)rr)r)F)F)rr)6__doc__ __future__rrr1r/loggingrBrcr&pip._vendor.sixrZpip._internal.utils.typingrZtypingrrr ImportError pip._vendoripaddrZ IPAddress ip_addressZ IPNetwork ip_network__all__ getLogger__name__r6r'r Zimportlib.utilrimpAttributeErrorr*r)register_errorr r r importlib.machineryrNrrOrSr platformrTr3rrrArrrrrst         7