Y3j@sddlmZddlmZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlmZddlmZmZmZddlmZmZmZmZmZddlm Z ddl!m"Z"dd l#m$Z$dd l%m&Z&e$rudd lm'Z(ndd lm(Z(d ddddddddddddddddddd d!d"d#d$gZ)e j*e+Z,dyZ-dzZ.d{Z/d|Z0e/e-e0e.Z1e/e0Z2yddl3Z3e2e-7Z2Wne4k rQe,j5d1YnXyddl6Z6e2e.7Z2Wne4k re,j5d2YnXd3d4Z7d5d!Z8d6dZ9e&d7d8d9d:d;d<d Z:d=d>Z;d?dZ<d@dAdZ=dBdCZ>dDdZ?dEdZ@dFdZAdGdZBdHdZCejDdIdJZEdKdZFdLdZGdMdNdZHdOdZIdPdZJdQdRZKdSdTZLdUdVZMdWdXZNdYdZZOdMedMd;d;d[d\ZPd]d^ZQd_d`ZRdadZSdbdcZTdMdddZUdedZVdfdZWdMddgddddhdZXdidjZYdkdlZZGdmdndne[Z\Gdodpdpe(Z]ej^dqdrZ_dsd Z`Gdtdudue[Zaddvd$ZbdwdxZcdS)})absolute_import)dequeN)InstallationError)console_to_str expanduser stdlib_pkgs) site_packages user_siterunning_under_virtualenvvirtualenv_no_globalwrite_delete_marker_file) pkg_resources)input)PY2)retry)BytesIO)StringIOrmtree display_path backup_dirasksplitext format_sizeis_installable_dir is_svn_page file_contentssplit_leading_dirhas_leading_dirnormalize_pathrenamesget_terminal_sizeget_prog unzip_file untar_file unpack_filecall_subprocesscaptured_stdout ensure_dirARCHIVE_EXTENSIONSSUPPORTED_EXTENSIONSget_installed_version.tar.bz2.tbz.tar.xz.txz.tlz.tar.lz .tar.lzma.zip.whl.tar.gz.tgz.tarzbz2 module is not availablezlzma module is not availablec Os6yt|SWn!tk r1|||YnXdS)N) __import__ ImportError)pkg_or_module_string ExceptionTypeargskwargsr=1/tmp/pip-build-3puug3g5/pip/pip/utils/__init__.pyimport_or_raiseIs r?cCsRytj|Wn:tk rM}z|jtjkr;WYdd}~XnXdS)z os.path.makedirs without EEXIST.N)osmakedirsOSErrorerrnoEEXIST)pather=r=r>r'Ps c CsPy.tjjtjddkr-dtjSWntttfk rKYnXdS)Nr __main__.py-cz %s -m pippip)rGrH) r@rEbasenamesysargv executableAttributeError TypeError IndexErrorr=r=r=r>r!Ys stop_max_delayi wait_fixediFcCstj|d|dtdS)N ignore_errorsonerror)shutilrrmtree_errorhandler)dirrSr=r=r>rcscCsAtj|jtj@r:tj|tj||dSdS)zOn Windows, the files in .svn are read-only, so when rmtree() tries to remove them, an exception is thrown. We catch that here, remove the read-only attribute, and hopefully continue without problems.N)r@statst_modeS_IREADchmodS_IWRITE)funcrEexc_infor=r=r>rVis  rVcCstjjtjj|}tjddkra|jtjd}|jtj d}|j tj tjj rd|t tj d}|S)zTGives the display value for a given path, making it relative to cwd if possible.rreplace.N)r@rEnormcaseabspathrK version_infodecodegetfilesystemencodingencodegetdefaultencoding startswithgetcwdseplen)rEr=r=r>rxs z.bakcCsKd}|}x4tjj||rB|d7}|t|}qW||S)z\Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc))r@rEexistsstr)rWextn extensionr=r=r>rs  cCsCx3tjjddjD]}||kr|SqWt||S)NPIP_EXISTS_ACTION)r@environgetsplitr)messageoptionsactionr=r=r>ask_path_existss" r{cCs{xttjjdr%td|t|}|jj}||krotd|dj|fq|SqWdS)z@Ask the message interactively, with the given possible responses PIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: %szrs   cCsX|dkrd|ddS|d kr4d|dS|dkrLd|dSd|SdS) Niz%.1fMBg@@ z%ikBz%.1fkBz%ibytesi@Bi'r=)bytesr=r=r>rs     cCsEtjj|sdStjj|d}tjj|rAdSdS)z@Return True if `path` is a directory containing a setup.py file.Fzsetup.pyT)r@rEisdirrisfile)rEsetup_pyr=r=r>rs cCs(tjd|o'tjd|tjS)zT Returns true if the page appears to be the index page of an svn repository z[^<]*Revision \d+:z#Powered by (?:<a[^>]*?>)?Subversion)researchI)htmlr=���r=���r>���r������s����c���������� ���C���s0���t��|��d���}�|�j���j�d��SWd��QRXd��S)Nrbzutf-8)openreadre���)filenamefpr=���r=���r>���r������s����c�������������c���s&���x�|��j��|��}�|�s�P|�Vq�Wd�S)z7Yield pieces of data from a file-like object until EOF.N)r���)filesizechunkr=���r=���r>��� read_chunks���s ����r���c�������������C���s���|��j��d��j��d��}��d�|��k�rj�d�|��k�rN�|��j�d��|��j�d��k��sZ�d�|��k�rj�|��j�d�d��Sd�|��k�r�|��j�d�d��S|��d�f�Sd��S)N/\rm���rt���)lstripfindrw���)rE���r=���r=���r>���r������s����6  c�������������C���s\���d�}�xO�|��D]G�}�t��|��\�}�}�|�s/�d�S|�d�k�rD�|�}�q �|�|�k�r �d�Sq �Wd�S)zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r���)paths common_prefixrE���prefixrestr=���r=���r>���r������s����    Tc�������������C���sI���t��|���}��|�r'�t�j�j�|���}��n�t�j�j�|���}��t�j�j�|���S)zN Convert a path to its canonical, case-normalized, absolute version. )r���r@���rE���realpathrc���rb���)rE���resolve_symlinksr=���r=���r>���r������s ���� c�������������C���sX���t��j�|���\�}�}�|�j���j�d��rN�|�d�d��|�}�|�d�d��}�|�|�f�S)z,Like os.path.splitext, but take off .tar tooz.tar���Nr���) posixpathr���r���endswith)rE���baserp���r=���r=���r>���r������s ����c���������� ���C���s���t��j�j�|��\�}�}�|�rD�|�rD�t��j�j�|�� rD�t��j�|��t�j�|��|��t��j�j�|���\�}�}�|�r�|�r�y�t��j�|��Wn�t�k �r�Yn�Xd�S)z7Like os.renames(), but handles renaming across devices.N) r@���rE���rw���rn���rA���rU���move removedirsrB���)oldnewheadtailr=���r=���r>���r�����s����   c�������������C���s)���t����s �d�St�|���j�t�t�j���S)z Return True if path is within sys.prefix, if we're running in a virtualenv. If we're not in a virtualenv, all paths are considered "local." T)r ���r���ri���rK���r���)rE���r=���r=���r>���is_local��s���� r���c�������������C���s���t��t�|����S)z Return True if given Distribution object is installed locally (i.e. within current virtualenv). Always True if we're not in a virtualenv. )r��� dist_location)distr=���r=���r>��� dist_is_local!��s����r���c�������������C���s%���t��t�|����}�|�j�t��t���S)zF Return True if given Distribution is installed in user site. )r���r���ri���r ���)r��� norm_pathr=���r=���r>���dist_in_usersite,��s����r���c�������������C���s���t��t�|����j�t��t���S)ze Return True if given Distribution is installed in distutils.sysconfig.get_python_lib(). )r���r���ri���r���)r���r=���r=���r>���dist_in_site_packages4��s����r���c�������������C���sJ���xC�t��j�D]8�}�t�j�j�|�|��j�d��}�t�j�j�|��r �d�Sq �Wd�S)z$Is distribution an editable install?z .egg-linkTF)rK���rE���r@���r��� project_namer���)r��� path_itemegg_linkr=���r=���r>���dist_is_editable>��s ����r���c����������������s���|��r�t���n �d�d����|�r0�d�d�����n �d�d�����|�rQ�d�d����n �d�d����|�rl�t��n �d �d ����������f�d �d ���t�j�D�S) a�� Return a list of installed Distribution objects. If ``local_only`` is True (default), only return installations local to the current virtualenv, if in a virtualenv. ``skip`` argument is an iterable of lower-case project names to ignore; defaults to stdlib_pkgs If ``editables`` is False, don't report editables. If ``editables_only`` is True , only report editables. If ``user_only`` is True , only report installations in the user site directory. c�������������S���s���d�S)NTr=���)dr=���r=���r>��� local_test`��s����z/get_installed_distributions.<locals>.local_testc�������������S���s���d�S)NTr=���)r���r=���r=���r>��� editable_testd��s����z2get_installed_distributions.<locals>.editable_testc�������������S���s ���t��|��� S)N)r���)r���r=���r=���r>���r���g��s����c�������������S���s ���t��|���S)N)r���)r���r=���r=���r>���editables_only_testk��s����z8get_installed_distributions.<locals>.editables_only_testc�������������S���s���d�S)NTr=���)r���r=���r=���r>���r���n��s����c�������������S���s���d�S)NTr=���)r���r=���r=���r>��� user_testt��s����z.get_installed_distributions.<locals>.user_testc����������������sU���g��|��]K�}��|��r�|�j���k�r���|��r��|��r��|��r�|��q�Sr=���)key).0r���)r���r���r���skipr���r=���r>��� <listcomp>w��s ��� �   z/get_installed_distributions.<locals>.<listcomp>)r���r���r ��� working_set) local_onlyr���include_editableseditables_only user_onlyr=���)r���r���r���r���r���r>���get_installed_distributionsG��s����      r���c�������������C���s���g��}�t����rK�t���r(�|�j�t��qk�|�j�t��t�rk�|�j�t��n �t�r^�|�j�t��|�j�t��x@�|�D]8�}�t�j�j�|�|��j��d�}�t�j�j �|��rr�|�Sqr�Wd�S)a�� Return the path for the .egg-link file if it exists, otherwise, None. There's 3 scenarios: 1) not in a virtualenv try to find in site.USER_SITE, then site_packages 2) in a no-global virtualenv try to find in site_packages 3) in a yes-global virtualenv try to find in site_packages, then site.USER_SITE (don't look in global location) For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations. This method will just return the first one found. z .egg-linkN) r ���r ���appendr���r ���r@���rE���r���r���r���)r���sitessiteegglinkr=���r=���r>��� egg_link_path��s����      r���c�������������C���s���t��|���}�|�r�|�S|��j�S)z Get the site-packages location of this distribution. Generally this is dist.location, except in the case of develop-installed packages, where dist.location is the source code location, and we want to know where the egg-link file is. )r���location)r���r���r=���r=���r>���r�����s���� r���c����������� ���C���s���d�d���}��|��d��p-�|��d��p-�|��d��}�|�sy�y8�t��j�t��j���t��j��}�|��|��}�t��j�|��Wn�Yn�X|�s�t��j�j�d�d��t��j�j�d�d ��f�}�t�|�d��t�|�d��f�S) zlReturns a tuple (x, y) representing the width(x) and the height(x) in characters of the terminal window.c���������� ���S���so���yL�d�d��l��}�d�d��l�}�d�d��l�}�|�j�d�|�j�|��|�j�d���}�Wn �d��SYn�X|�d�k�rk�d��S|�S)Nr���hh1234)r���r���)fcntltermiosstructunpackioctl TIOCGWINSZ)fdr���r���r���crr=���r=���r>��� ioctl_GWINSZ��s����     z'get_terminal_size.<locals>.ioctl_GWINSZr���rm���r_���LINES���COLUMNSP���)r@���r���ctermidO_RDONLYcloseru���rv���int)r���r���r���r=���r=���r>���r �����s���� $ *c��������������C���s ���t��j�d��}��t��j�|���|��S)zBGet the current umask which involves having to set it temporarily.r���)r@���umask)maskr=���r=���r>��� current_umask��s���� r���c������� ������C���sx��t��|��t�|��d��}�zMt�j�|�d�d�}�t�|�j����oF�|�}�x|�j���D] }�|�j�}�|�j�|��}�|�} �|�r�t �|��d�} �t �j �j �|�| ��} �t �j �j �| ��} �| �j�d��s�| �j�d��r�t��| ��qV�t��| ��t�| �d��} �z�| �j�|��Wd�| �j���|�j�d �?} �| �r`t�j�| ��r`| �d �@r`t �j�| �d �t���d �B�XqV�WWd�|�j���Xd�S) a�� Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. r��� allowZip64Trm���r���r���wbN���I���i��)r'���r���zipfileZipFiler���namelistinfolistr���r���r���r@���rE���r���dirnamer���writer��� external_attrrX���S_ISREGr[���r���) r���r���flattenzipfpzipleadinginfonamedatafnrW���r���moder=���r=���r>���r"�����s0����      $c������� ��� ���C���s��t��|��|��j���j�d��s4�|��j���j�d��r=�d�}�np�|��j���j�t��r[�d�}�nR�|��j���j�t��ry�d�}�n4�|��j���j�d��r�d�}�n�t�j�d�|���d �}�t�j�|��|��}�zt �d �d ���|�j ���D��}�x|�j ���D]}�|�j �}�|�d �k�r q�|�r"t �|��d �}�t �j�j�|�|��}�|�j���rPt��|��q�|�j���ry�|�j�|�|��Wqt�k �r}�z!�t�j�d�|��|�j �|��w�WYd�d�}�~�XqXq�y�|�j�|��} �WnG�t�t�f�k �r}�z!�t�j�d�|��|�j �|��w�WYd�d�}�~�Xn�Xt��t �j�j�|���t�|�d���} �t�j�| �| ��Wd�QRX| �j���|�j�|�|��|�j�d�@r�t �j�|�d�t���d�B�q�WWd�|�j���Xd�S)a�� Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*c�������������S���s(���g��|��]�}�|�j��d��k�r�|�j���q�S)pax_global_header)r���)r���memberr=���r=���r>���r�����s��� �zuntar_file.<locals>.<listcomp>r���rm���z/In the tar file %s the member %s is invalid: %sNr���r���i��)r'���r���r���BZ2_EXTENSIONS XZ_EXTENSIONSloggerwarningtarfiler���r��� getmembersr���r���r@���rE���r���r���issym_extract_memberr}��� extractfileKeyErrorrN���r���rU��� copyfileobjr���utimer���r[���r���) r���r���r���tarr���r���r���rE���excr���destfpr=���r=���r>���r#�����s`���� *            #c�������������C���s(��t��j�j�|���}��|�d�k�sB�|��j���j�t��sB�t�j�|���rb�t�|��|�d�|��j�d�� n�|�d�k�s�t �j �|���s�|��j���j�t �t �t ��r�t�|��|��nz�|�r�|�j�d��r�t�t�|����r�d�d�l�m�}�|�d�|�j��j�|��n&�t�j�d �|��|�|��t�d �|���d��S) Nzapplication/zipr���z.whlzapplication/x-gzipz text/htmlr���) Subversionzsvn+zZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz%Cannot determine archive format of %s)r@���rE���r���r���r���ZIP_EXTENSIONSr��� is_zipfiler"���r��� is_tarfileTAR_EXTENSIONSr���r���r#���ri���r���r���pip.vcs.subversionr��urlr���r���criticalr���)r���r��� content_typelinkr��r=���r=���r>���r$���O��s,����    raisec�������������C���s��|�r�d��}�n �t��j�}�|�d��k�r�g��}�xa�|��D]Y�} �d�| �k�sg�d�| �k�sg�d�| �k�sg�d�| �k�r}�d�| �j�d�d��} �|�j�| ��q1�Wd�j�|��}�t�j�d�|��t�j�j ���} �|�r�| �j �|��y4�t��j �|��d�t��j �d �d��d �|�d �|�d �| �} �Wn;�t �k �r@} �z�t�j�d �| �|����WYd��d��} �~ �Xn�X|�d��k �rg��} �xx�t�| �j�j����}�|�srP|�j���}�| �j�|�d��t�j���t�j�k�rt�j�|��qV|�d��k �rV|�j���qVW| �j���|�d��k �r | �j�r|�j�d��n �|�j�d��| �j�r|�d�k�rt�j���t�j�k�re|� ret�j�d�|��t�j�d�j�| ��d��t�d�|�| �j�|�f���nM�|�d�k�rt�j�d�|�| �j�|��n%�|�d�k�rn�t�d�t�|����|�sd�j�| ��Sd��S)N  "'z"%s"z\"zRunning command %sstderrstdinstdoutcwdenvz#Error %s while executing command %serrordoner��z Complete output from command %s:rt���z) ----------------------------------------z,Command "%s" failed with error code %s in %swarnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=%s) subprocessPIPEr`���r���r���r���debugr@���ru���copyupdatePopenSTDOUTr}���r��r���r��readlinerstripgetEffectiveLevel std_loggingDEBUGspinwait returncodefinishr���r���r��� ValueErrorrepr)cmd show_stdoutr�� on_returncode command_desc extra_environspinnerr�� cmd_partspartr��procr�� all_outputliner=���r=���r>���r%���p��sz����    0               c�������������C���s���t��|��d���}�|�j���}�Wd�QRXd�t�j�d��d�g�}�x:�|�D]2�}�y�|�j�|��}�Wn�t�k �rt�wD�Yn�XPqD�Wt�|��t�k�s�t��|�S)aR��Return the contents of *filename*. Try to decode the file contents with utf-8, the preferred system encoding (e.g., cp1252 on some Windows machines), and latin1, in that order. Decoding a byte string with latin1 will never raise an error. In the worst case, the returned string will contain some garbage characters. r���Nzutf-8Flatin1) r���r���localegetpreferredencodingre���UnicodeDecodeErrortyper���AssertionError)r���r���r��� encodingsencr=���r=���r>���read_text_file��s����   rD��c�������������C���s���t��j�|���t�|���d��S)N)r@���rA���r ���) build_dirr=���r=���r>���_make_build_dir��s���� rF��c���������������@���s:���e��Z�d��Z�d�Z�d�d���Z�d�d���Z�d�d���Z�d�S) FakeFilezQWrap a list of lines in an object with readline() to make ConfigParser happy.c�������������C���s���d�d���|�D�|��_��d��S)Nc�������������s���s���|��] �}�|�Vq�d��S)Nr=���)r���lr=���r=���r>��� <genexpr>��s����z$FakeFile.__init__.<locals>.<genexpr>)_gen)selflinesr=���r=���r>���__init__��s����zFakeFile.__init__c�������������C���sT���y7�y�t��|��j��SWn�t�k �r5�|��j�j����SYn�XWn�t�k �rO�d�SYn�Xd��S)Nrt���)nextrJ�� NameError StopIteration)rK��r=���r=���r>���r&����s����  zFakeFile.readlinec�������������C���s���|��j��S)N)rJ��)rK��r=���r=���r>���__iter__��s����zFakeFile.__iter__N)__name__ __module__ __qualname____doc__rM��r&��rQ��r=���r=���r=���r>���rG����s���   rG��c���������������@���s4���e��Z�d��Z�e�d�d����Z�e�d�d����Z�d�S) StreamWrapperc�������������C���s���|�|��_��|����S)N) orig_stream)clsrW��r=���r=���r>��� from_stream��s���� zStreamWrapper.from_streamc�������������C���s ���|��j��j�S)N)rW��encoding)rK��r=���r=���r>���rZ�� ��s����zStreamWrapper.encodingN)rR��rS��rT�� classmethodrY��propertyrZ��r=���r=���r=���r>���rV����s��� rV��c���������� ���c���sR���t��t�|���}�t�t�|��t�j�|���z�t��t�|���VWd�t�t�|��|��Xd�S)zReturn a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO. Taken from Lib/support/__init__.py in the CPython repo. N)getattrrK���setattrrV��rY��) stream_name orig_stdoutr=���r=���r>���captured_output��s ����ra��c���������������C���s ���t��d��S)zCapture the output of sys.stdout: with captured_stdout() as stdout: print('hello') self.assertEqual(stdout.getvalue(), 'hello ') Taken from Lib/support/__init__.py in the CPython repo. r��)ra��r=���r=���r=���r>���r&�����s���� c���������������@���s.���e��Z�d��Z�d�Z�d�d���Z�d�d���Z�d�S)cached_propertyzA property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/blob/0.11.5/bottle.py#L175 c�������������C���s���t��|�d��|��_�|�|��_�d��S)NrU��)r]��rU��r]���)rK��r]���r=���r=���r>���rM��2��s����zcached_property.__init__c�������������C���s4���|�d��k�r�|��S|��j��|��}�|�j�|��j��j�<|�S)N)r]���__dict__rR��)rK��objrX��valuer=���r=���r>���__get__6��s����  zcached_property.__get__N)rR��rS��rT��rU��rM��rf��r=���r=���r=���r>���rb��*��s���  rb��c�������������C���s\���t��j�j�|���}�|�d�k�r-�t��j���}�n�t��j�|��}�|�j�|��}�|�rX�|�j�Sd�S)zCGet the installed version of dist_name avoiding pkg_resources cacheN)r ��� Requirementparse WorkingSetr���version) dist_name lookup_dirsreqr���r���r=���r=���r>���r*���>��s ���� c�������������C���s���t��|��d�d�d�S)zConsume an iterable at C speed.maxlenr���N)r���)iteratorr=���r=���r>���consumeR��s����rp��)r+���r,���)r-���r.���r/���r0���r1���)r2���r3���)r4���r5���r6���)d __future__r��� collectionsr��� contextlibrC���ior=��loggingr)��r���r@���r���rU���rX���r��rK���r���r���pip.exceptionsr��� pip.compatr���r���r��� pip.locationsr���r ���r ���r ���r ��� pip._vendorr ���pip._vendor.six.movesr���pip._vendor.sixr���pip._vendor.retryingr���r���r���__all__ getLoggerrR��r���r���r���r��r ��r(���r)���bz2r8���r!��lzmar?���r'���r!���r���rV���r���r���r{���r���r���r���r���r���DEFAULT_BUFFER_SIZEr���r���r���r���r���r���r���r���r���r���r���r���r���r���r ���r���r"���r#���r$���r%���rD��rF��objectrG��rV��contextmanagerra��r&���rb��r*���rp��r=���r=���r=���r>���<module>���s���              (                     5 %   + L !_