Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python3.6/site-packages/pip/req/__pycache__/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python3.6/site-packages/pip/req/__pycache__/req_install.cpython-36.pyc

3

���^���@s0ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZmZddlmZddlmZdd	lmZmZdd
lmZddlmZmZ
ddl!m"Z"ddl#Z$dd
l%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGddlHmIZIddlJmKZKddlLmMZMddlNmOZOddlPmQZQddlRmSZSddlTmUZUddl#mVZVmWZWejXeY�ZZej[j\j]�Z^dd�Z_dd�Z`Gdd�dea�Zbd
d!�Zcd$d"d#�ZddS)%�)�absolute_importN)�	sysconfig)�change_root)�
FeedParser)�
pkg_resources�six)�
specifiers)�Marker)�InvalidRequirement�Requirement)�canonicalize_name)�Version�parse)�configparser)�
native_str�
get_stdlib�WINDOWS)�is_url�url_to_path�path_to_url�is_archive_file)�InstallationError�UninstallationError)�bin_py�running_under_virtualenv�PIP_DELETE_MARKER_FILENAME�bin_user)�display_path�rmtree�ask_path_exists�
backup_dir�is_installable_dir�dist_in_usersite�dist_in_site_packages�dist_in_install_path�
egg_link_path�call_subprocess�read_text_file�FakeFile�_make_build_dir�
ensure_dir�get_installed_version�normalize_path�
dist_is_local)�Hashes)�RemovedInPip10Warning)�
indent_log)�SETUPTOOLS_SHIM)�open_spinner)�UninstallPathSet)�vcs)�move_wheel_files�WheelcCs6tjd|�}d}|r*|jd�}|jd�}n|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)�path�m�extrasZpath_no_extras�r?�!/usr/lib/python3.6/req_install.py�
_strip_extras9s
rAcCstdd�|D��S)Ncss|]}tj|�VqdS)N)rZ
safe_extra)�.0�extrar?r?r@�	<genexpr>Fsz_safe_extras.<locals>.<genexpr>)�set)r>r?r?r@�_safe_extrasEsrFc@s�eZdZdQdd�ZedRdd��ZedSdd	��Zd
d�Zdd
�Zdd�Z	e
dd��Ze
dd��Zdd�Z
dd�Zdd�Ze
dd��Ze
dd��Ze
dd��Zd
d!�Zd"d#�Zd$d%�Zd&d'�Zejd(�Ze
d)d*��Zd+d,�ZdTd-d.�ZdUd/d0�Zd1d2�Zd3d4�Zd5d6�Z
d7d8�Z!dVd9d:�Z"gdddfd;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&fdfdCdD�Z'dEdF�Z(e
dGdH��Z)dWdIdJ�Z*dKdL�Z+e
dMdN��Z,dXdOdP�Z-dS)Y�InstallRequirementNFTcsJf|_t�tj�r�yt���Wndtk
r�tjj�kr@d}n.d�krft	�fdd�t
D��rfd}ntj�}t
d�|f��YnXt�j�|_�|_||_|
|_||_||_||_||_|_||_|	dk	r�|	|_n�oވj|_d|_d|_d|_d|_d|_||_d|_
d|_!d|_"d|_#d|_$|�r.|ni|_%||_&d|_'|
|_(dS)Nz%It looks like a path. Does it exist
?�=c3s|]}|�kVqdS)Nr?)rB�op)�reqr?r@rDVsz.InstallRequirement.__init__.<locals>.<genexpr>z,=
is not a valid operator. Did you mean == ?zInvalid requirement:
'%s'
%sF))r>�
isinstancer�string_typesrr
�osr<�sep�any�	operators�	traceback�
format_excrrFrJ�
comes_from�
constraint�
source_dir�editable�_wheel_cache�link�
original_link�as_egg�markers�marker�_egg_info_path�satisfied_by�conflicts_with�_temp_build_dir�_ideal_build_dir�update�install_succeeded�uninstalled�nothing_to_uninstall�
use_user_site�
target_dir�options�	pycompileZprepared�isolated)�selfrJrSrUrVrXrZrbrir[rjrh�wheel_cacherT�add_msgr?)rJr@�__init__KsN
zInstallRequirement.__init__cCspddlm}t||�\}	}
}|
jd�r0t|
�}nd}||	||d||
�|||rP|ni|d�	}
|dk	rlt|�|
_|
S)Nr)�Linkzfile:T)rUrVrXrTrjrhrl)�	pip.indexro�parse_editable�
startswithrrFr>)�cls�editable_reqrS�default_vcsrjrhrlrTro�name�urlZextras_overriderU�resr?r?r@�
from_editable�s




z InstallRequirement.from_editablec
Cs�ddlm}t|�rd}nd}||krR|j|d�\}}	|	j�}	|	sHd}	qVt|	�}	nd}	|j�}d}
tjjtjj	|��}d}d}
t|�r�||�}n�t
|�\}}
tjj|�r�tjj|ks�|j
d�r�t|�s�td|��|t|��}n0t|��rtjj|��stjd	|�|t|��}|�r||jd
k�rPtjd|j��rP|ttjjtjj	|j����}|j�rtt|j�}d|j|jf}
n|j}
n|}
|�r�|ni}||
|||	||||d
�}|
�r�tt d|
�j!�|_!|S)z�Creates an
InstallRequirement from a name, which might be a
        requirement, directory containing 'setup.py', filename,
or URL.
        r)roz; �;r7N�.z;Directory %r is not installable. File
'setup.py' not found.zARequirement %r looks like a filename, but
the file does not
exist�filez\.\./z%s==%s)rXr[rjrhrlrT�placeholder)"rpror�split�stripr	rMr<�normpath�abspathrA�isdirrNrrr!rrr�isfile�logger�warning�schemer9�searchrw�is_wheelr6�filenamerv�version�egg_fragmentrFrr>)rsrvrSrjrhrlrTroZ
marker_sepr[rJr<rXr>�p�wheelrxr?r?r@�	from_line�sb





zInstallRequirement.from_linecCs�|jr(t|j�}|jr:|d|jj7}n|jr6|jjnd}|jdk	rX|dt|jj�7}|jr�t|jt	j
�rt|j}n
|jj�}|r�|d|7}|S)Nz from %sz in %sz
 (from
%s))rJ�strrXrwr^r�locationrSrKrrL�	from_path)rk�srSr?r?r@�__str__�s


zInstallRequirement.__str__cCsd|jjt|�|jfS)Nz<%s
object: %s
editable=%r>)�	__class__�__name__r�rV)rkr?r?r@�__repr__szInstallRequirement.__repr__cCs^|jdkr|j||�|_|jdk	rZ|rZ|j}|jj|j|j�|_||jkrZtjd|j�dS)aEnsure
that if a link can be found for this, that it is found.

        Note that self.link may still be None - if Upgrade is False and the
        requirement is already installed.

        If require_hashes is True, don't use the wheel cache, because
cached
        wheels, always built locally, have different hashes than the files
        downloaded from the index server and thus throw false hash
mismatches.
        Furthermore, cached wheels at present have undeterministic contents
due
        to file modification times.
        NzUsing cached wheel link:
%s)rXZfind_requirementrWZcached_wheelrvr��debug)rk�finderZupgradeZrequire_hashesZold_linkr?r?r@�
populate_link	s

z
InstallRequirement.populate_linkcCs|jjS)N)rJ�	specifier)rkr?r?r@r�szInstallRequirement.specifiercCs$|j}t|�dko"tt|��jdkS)z�Return
whether I am pinned to an exact version.

        For example, some-package==1.2 is pinned; some-package>1.2 is
not.
       
r7�==�===)r�r�)r��len�next�iter�operator)rkrr?r?r@�	is_pinned!szInstallRequirement.is_pinnedcCsR|jdkrdSt|j�}|jrNt|jtj�r4|j}n
|jj�}|rN|d|7}|S)Nz->)rJr�rSrKrrLr�)rkr�rSr?r?r@r�+s


zInstallRequirement.from_pathcCs�|jdk	r|jS|jdkr<tjjtjdd��|_||_|jS|jrN|j	j
�}n|j	}tjj|�sttj
d|�t|�tjj||�S)Nz-buildzpip-zCreating
directory
%s)r`rJrMr<�realpath�tempfile�mkdtemprarVrv�lower�existsr�r�r)�join)rk�	build_dirrvr?r?r@�build_location8s

z!InstallRequirement.build_locationcCs�|jdk	rdS|jdk	st�|js&t�|js0t�|j}d|_|j|j�}tjj|�rdt	dt
|���tjd|t
|�t
|��t
j||�||_d|_||_d|_dS)a�Move
self._temp_build_dir to self._ideal_build_dir/self.req.name

        For some requirements (e.g. a path to a directory), the name of the
        package is not available until we run egg_info, so the
build_location
        will return a temporary directory and store the _ideal_build_dir.

        This is only called by self.egg_info_path to fix the temporary
build
        directory.
        Nz<A package already exists in %s; please remove it to
continuez,Moving package %s from %s to new location
%s)rUrJ�AssertionErrorr`rar�rMr<r�rrr�r��shutil�mover])rkZold_locationZnew_locationr?r?r@�_correct_build_locationSs(



z*InstallRequirement._correct_build_locationcCs
|jdkrdSttj|jj��S)N)rJrrZ	safe_namerv)rkr?r?r@rvss
zInstallRequirement.namecCstjj|j|jr|jjpd�S)N�)rMr<r�rUrXZsubdirectory_fragment)rkr?r?r@�setup_py_diryszInstallRequirement.setup_py_dircCs�|jstd|��yddl}Wn:tk
rXtd�dkr@d}ntj�}td|��YnXtj	j
|jd�}tj
r�t|tj�r�|jtj��}|S)NzNo source dir
for %sr�
setuptoolszPlease install setuptools.zWCould not import setuptools which
is required to install from a source distribution.
%szsetup.py)rUr�r��ImportErrorr+rQrRrrMr<r�r�r�PY2rKZ	text_type�encode�sys�getfilesystemencoding)rkr�rm�setup_pyr?r?r@r�szInstallRequirement.setup_pyc
CsZ|js
t�|jr$tjd|j|j�ntjd|j|j�t��xt|j}t	j
d|g}|jrd|dg7}|dg}|jrzg}n
t
jj|jd�}t|�ddg}t|||jdd	d
�WdQRX|j�stt|j�d�t�r�d}nd
}tdj|j�d||j�dg��|_|j�nDt|j�d�}t|jj�|k�rVtjd|j|j||j�t|�|_dS)Nz2Running
setup.py (path:%s) egg_info for package %sz7Running setup.py (path:%s)
egg_info for package from %sz-cz
--no-user-cfg�egg_infozpip-egg-infoz
--egg-baseFzpython setup.py
egg_info)�cwd�show_stdoutZcommand_descr
z==z===r��NamezuRunning
setup.py (path:%s) egg_info for package %s produced metadata for project
name %s. Fix your #egg=%s fragments.)rUr�rvr�r�r�rXr0r1r��
executablerjrVrMr<r�r�r*r&rJrK�
parse_version�pkg_infor
rr�rr�)rk�scriptZbase_cmdZegg_info_cmdZegg_base_option�egg_info_dirrIZ
metadata_namer?r?r@�run_egg_info�sP





zInstallRequirement.run_egg_infocCsV|jdk	r&|jj|�sdS|jj|�S|js0t�|j|�}tjj|�sJdSt	|�}|S)N)
r^�has_metadata�get_metadatarUr��
egg_info_pathrMr<r�r')rkr��datar?r?r@�
egg_info_data�s


z
InstallRequirement.egg_info_datacs||jdk�rl|jr|j}ntjj|jd�}tj|�}|j�rg}x�tj|�D]�\�}}x
t	j
D]}||kr^|j|�q^Wxjt|�D]^}tjj
tjj�|dd��s�tjjtjj�|dd��r�|j|�q�|dks�|dkr�|j|�q�W|j�fdd	�|D��qLWd
d	�|D�}|�s$td||f��|�s:td||f��t|�dk�rX|jd
d�d�tjj||d�|_tjj|j|�S)Nzpip-egg-info�bin�pythonZScriptsz
Python.exeZtestZtestscsg|]}tjj�|��qSr?)rMr<r�)rB�dir)�rootr?r@�
<listcomp>�sz4InstallRequirement.egg_info_path.<locals>.<listcomp>cSsg|]}|jd�r|�qS)z	.egg-info)�endswith)rB�fr?r?r@r��sz$No
files/directories in %s (from
%s)r7cSs(|jtjj�tjjr"|jtjj�p$dS)Nr)�countrMr<rN�altsep)�xr?r?r@�<lambda>
sz2InstallRequirement.egg_info_path.<locals>.<lambda>)�keyr)r]rVrUrMr<r�r��listdir�walkr4�dirnames�remove�list�lexistsr��extendrr�r��sort)rkr��base�	filenames�dirs�filesr�r?)r�r@r��sB
z
InstallRequirement.egg_info_pathcCs@t�}|jd�}|s*tjdt|jd���|j|p4d�|j�S)NzPKG-INFOzNo
PKG-INFO file found in
%sr�)rr�r�r�rr�Zfeed�close)rkr�r�r?r?r@r�s
zInstallRequirement.pkg_infoz	\[(.*?)\]cCs
t|j�S)N)r+rv)rkr?r?r@�installed_version
sz$InstallRequirement.installed_versioncCsV|js
t�|j�d}|jjr<||jjkr<tjd||j�ntjdt	|j�||�dS)Nr�z'Requested
%s, but installing version %sz;Source in %s has version %s, which satisfies
requirement %s)
rUr�r�rJr�r�r�r�r�r)rkr�r?r?r@�assert_source_matches_version$s

z0InstallRequirement.assert_source_matches_versioncCs�|jstjd|j�dS|js"t�|js,t�|jjdkr<dSd|jjksXtd|jj��|jsbdS|jjj	dd�\}}t
j|�}|r�||jj�}|r�|j|j�q�|j
|j�nds�td|j|f��dS)Nz>Cannot
update repository at %s; repository location is unknownr|�+zbad url:
%rr7rz+Unexpected version control type (in %s):
%s)rXr�r�rUrVr�r�rwrbr~r4�get_backend�obtainZexport)rkr��vc_typerw�backendZvcs_backendr?r?r@�update_editable5s,


z"InstallRequirement.update_editablecsx|j�std|jf��|jp"|j}t|j�}t|�sTtj	d|j
|tj�d|_
dS|t�krxtj	d|j
|�d|_
dSt|�}t|�}djtj|j��}|jo�tjj|j�}t|jdd�}|o�|jjd�o�|jj|��r�|j|j�|jd	��r2x�|jd	�j�D](}	tjj
tjj!|j|	��}
|j|
��qWn�|jd
��r|jd��rV|jd��ng�xj�fdd
�|jd
�j�D�D]J}tjj!|j|�}
|j|
�|j|
d�|j|
d�|j|
d��qxW�nH|�r�t"j#dj|j�t$�|j|��n
|jjd��rH|j|j�tjj%|j�d}tjj!tjj&|j�d�}
|j'|
d|�n�|�r�|jjd��r�x�t(j)j*|�D]}
|j|
��qjWn�|�rt+|d��}tjj,|j-�j.��}WdQRX||jk�s�t/d||j|jf��|j|�tjj!tjj&|�d�}
|j'|
|j�ntj0d||j�|jd��r�|j1d��r�xZ|j2d�D]L}t3|��rJt4}nt5}|jtjj!||��t6�r6|jtjj!||�d��q6W|jd��rdt7j8�r�i}ndd#i}t9j:f|�}|j;t<|j=d���|j>d��rdx�|j?d�D]�\}}t3|��r�t4}nt5}|jtjj!||��t6�r�|jtjj!||�d
�|jtjj!||�d!�|jtjj!||�d"��q�W|j@|�||_AdS)$a�
        Uninstall the distribution currently satisfying this requirement.

        Prompts before removing or modifying files unless
        ``auto_confirm`` is True.

        Refuses to delete or modify files outside of ``sys.prefix`` -
        thus uninstallation within a virtual environment can only
        modify that virtual environment, even if the virtualenv is
        linked to global site-packages.

        z.Cannot uninstall requirement %s, not installedz1Not uninstalling
%s at %s, outside environment %sTNz<Not uninstalling %s at %s, as it is
in the standard
library.z{0}.egg-infor<z	.egg-infozinstalled-files.txtz
top_level.txtznamespace_packages.txtcsg|]}|r|�kr|�qSr?r?)rBr�)�
namespacesr?r@r��sz0InstallRequirement.uninstall.<locals>.<listcomp>z.pyz.pycz.pyoz�Uninstalling
a distutils installed project ({0}) has been deprecated and will be removed
in a future version. This is due to the fact that uninstalling a distutils
project will only partially uninstall the
project.z.eggr7zeasy-install.pthz./z
.dist-info�rz;Egg-link %s does not match installed location of %s (at
%s)z)Not sure how to uninstall: %s - Check:
%s�scriptsz.batzentry_points.txtZ
delimitersrHZconsole_scriptsz.exez
.exe.manifestz
-script.py)rH)B�check_if_existsrrvr^r_r,r�r-r��infor�r��prefixrerr3r%�formatrZto_filename�project_namer�rMr<r��getattrZ	_providerr��addr�r��
splitlinesr�r��warnings�warnr/r~�dirnameZadd_pth�pipr�Zuninstallation_paths�open�normcase�readlinerr�r�Zmetadata_isdirZmetadata_listdirr"rrrrr�rZSafeConfigParserZreadfpr(Zget_metadata_linesZhas_section�itemsr�rd)rkZauto_confirmZdistZ	dist_pathZpaths_to_removeZdevelop_egg_linkZdevelop_egg_link_egg_infoZegg_info_existsZdistutils_egg_infoZinstalled_filer<Z
top_level_pkgZeasy_install_eggZeasy_install_pthZfhZlink_pointerr�Zbin_dirrh�configrv�valuer?)r�r@�	uninstallRs�









zInstallRequirement.uninstallcCs$|jr|jj�ntjd|j�dS)Nz'Can't
rollback %s, nothing
uninstalled.)rdZrollbackr��errorrv)rkr?r?r@�rollback_uninstall�sz%InstallRequirement.rollback_uninstallcCs*|jr|jj�n|js&tjd|j�dS)Nz%Can't
commit %s, nothing
uninstalled.)rdZcommitrer�r�rv)rkr?r?r@�commit_uninstall�s
z#InstallRequirement.commit_uninstallcCs�|js
t�d}d|j|j�df}tjj||�}tjj|�r�tdt	|�d�}|dkr^d	}nj|dkr�t
jd
t	|��tj|�nF|dkr�t
|�}t
jdt	|�t	|��tj||�n|dkr�tjd�|�r�tj|dtjdd
�}tjjtjj|j��}x�tj|�D]�\}	}
}d|
k�r"|
jd�xR|
D]J}tjj|	|�}|j||�}
tj|jd|
d�}d|_|j|d��q(WxL|D]D}|tk�r��q|tjj|	|�}|j||�}
|j||jd|
��q|W�qW|j�t
j dt	|��dS)NTz	%s-%s.zipr�z8The file %s exists. (i)gnore,
(w)ipe, (b)ackup, (a)bort �i�w�b�aFzDeleting %szBacking up %s
to %sr7)Z
allowZip64zpip-egg-info�/i��r�zSaved
%s)rrrr���i�)!rUr�rvr�rMr<r�r�rrr�r�r�r
r�r�r��exit�zipfileZZipFileZZIP_DEFLATEDr�r�r�r��_clean_zip_nameZZipInfoZ
external_attrZwritestrr�writer�r�)rkr�Zcreate_archiveZarchive_nameZarchive_pathZresponseZ	dest_file�zipr��dirpathr�r�r�rvZzipdirr�r?r?r@�archivesX







"zInstallRequirement.archivecCsJ|j|tjj�s"td||f��|t|�dd�}|jtjjd�}|S)Nz$name
%r doesn't start with prefix
%rr7r)rrrMr<rNr�r��replace)rkrvr�r?r?r@r	5s
z"InstallRequirement._clean_zip_namecs0|sd}�jdk	r(t�fdd�|D��SdSdS)Nr�c3s|]}�jjd|i�VqdS)rCN)r[Zevaluate)rBrC)rkr?r@rDDsz3InstallRequirement.match_markers.<locals>.<genexpr>T)r�)r[rO)rkZextras_requestedr?)rkr@�
match_markers=s


z
InstallRequirement.match_markersc,s`|jr|j|||d�dS|jr\tjj|j�}tjj||j�|j	|j�||d�d|_
dS||jjdg�7}||jjdg�7}|j
r�t|�dg}tjdd�}tjj|d	�}�z�|j||�|�}	d
|jf}
t|
��.}t��t|	||jd|d�WdQRXWdQRXtjj|��s(tjd
|�dSd|_
|j�r:dS�fdd�}t|��H}
x@|
D](}tjj|�}|jd��rV||�}P�qVWtj
d|�dSWdQRXg}t|��P}
xH|
D]@}|j!�}tjj"|��r�|tjj#7}|j$tjj%||�|���q�WWdQRXtjj|d�}t|d��}
|
j&dj|�d�WdQRXWdtjj|��rRtj'|�t(|�XdS)N)r�)r�r��strip_file_prefixT�global_options�install_optionsz
--no-user-cfgz-recordzpip-zinstall-record.txtzRunning
setup.py install for %sF)r�r��spinnerzRecord file %s not
foundcs(�dkstjj|�r|St�|�SdS)N)rMr<�isabsr)r<)r�r?r@�prepend_root~sz0InstallRequirement.install.<locals>.prepend_rootz	.egg-infoz;Could
not find .egg-info directory in install record for
%szinstalled-files.txtr�
))rV�install_editabler�r�r�Z
wheel_versionrUZcheck_compatibilityrvr5rcrh�getrjr�r�r�rMr<r��get_install_argsr2r0r&r�r�r�r�rZr�r�r�r�rr�rN�append�relpathr
r�r)rkrrr�r�rr�Z
temp_location�record_filename�install_args�msgrrr��lineZ	directoryr�Z	new_linesr�Zinst_files_pathr?)r�r@�installIs~




"
zInstallRequirement.installcCs|jdkr|j|�|_|jS)aAEnsure that
a source_dir is set.

        This will create a temporary build dir if the name of the
requirement
        isn't known yet.

        :param parent_dir: The ideal pip parent_dir for the source_dir.
            Generally src_dir for editables and build_dir for sdists.
        :return: self.source_dir
        N)rUr�)rkZ
parent_dirr?r?r@�ensure_has_source_dir�s

z(InstallRequirement.ensure_has_source_dircCs�tjdg}|jd�|jt|j�|t|�dd|g7}|jsJ|dg7}|dk	r^|d|g7}|dk	rr|d|g7}|jr�|dg7}n
|d	g7}t�r�d
t	j
�}|dtjj
tjdd
||j�g7}|S)Nz-uz-cr
z--recordz#--single-version-externally-managedz--rootz--prefixz	--compilez--no-compiler�z--install-headers�includeZsite)r�r�rr1r�r�rZrirr�get_python_versionrMr<r�r�rv)rkrrr�r�rZ
py_ver_strr?r?r@r�s(



z#InstallRequirement.get_install_argscCsd|jr6tjjtjj|jt��r6tjd|j�t|j�d|_|j	rZtjj|j	�rZt|j	�d|_	dS)zVRemove
the source files from this requirement, if they are marked
        for deletionzRemoving source in %sN)
rUrMr<r�r�rr�r�rr`)rkr?r?r@�remove_temporary_source�s

z*InstallRequirement.remove_temporary_sourcecCs�tjd|j�|jr"t|�dg}|r>dj|�g}t|�|}t��<ttj	dt
|jgt|�ddgt|�|jdd�WdQRXd	|_
dS)
NzRunning setup.py develop for
%sz
--no-user-cfgz--prefix={0}z-cZdevelopz	--no-depsF)r�r�T)r�r�rvrjr�r�r0r&r�r�r1r�r�rc)rkrrr�Zprefix_paramr?r?r@r�s
z#InstallRequirement.install_editablecCs�|jdkrdSyFtt|j��}d|_tjt|��|_|jrR|jrR|j|_d|_dSWn�tj	k
rjdStj
k
r�tj|jj�}|jr�t
|�r�||_q�t�r�t|�r�td|j|jf��nt|�r�||_YnXdS)z�Find
an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.conflicts_with appropriately.
        NFTzVWill not install to the user site because it will lack
sys.path precedence to %s in
%s)rJrr�r\rZget_distributionr^rVr_ZDistributionNotFoundZVersionConflictrvrfr"rr#rr�r�r$)rkZ	no_markerZ
existing_distr?r?r@r��s4

z"InstallRequirement.check_if_existscCs|jo|jjS)N)rXr�)rkr?r?r@r�
szInstallRequirement.is_wheelcCs,t|j|j||j|j|||j|j|d�
dS)N)�user�homer�r�rirjr)r5rvrJrfrgrirj)rkZwheeldirr�r�rr?r?r@r5$s
z#InstallRequirement.move_wheel_filescCsX|jd�jd�}tjj|�}tj||�}tjjtjj|��d}tj	tjj|�||d�S)zAReturn
a pkg_resources.Distribution built from
self.egg_info_pathr�rr)r��metadata)
r��rstriprMr<r�rZPathMetadata�splitext�basenameZDistribution)rkr�Zbase_dirr'Z	dist_namer?r?r@�get_dist0s
zInstallRequirement.get_distcCst|jjdi��S)z�Return
whether any known-good hashes are specified as options.

        These activate --require-hashes mode; hashes specified as part of a
        URL do not.

       
�hashes)�boolrhr)rkr?r?r@�has_hash_options;sz#InstallRequirement.has_hash_optionscCsJ|jjdi�j�}|r|jn|j}|rB|jrB|j|jg�j|j�t	|�S)a�Return
a hash-comparer that considers my option- and URL-based
        hashes to be known-good.

        Hashes in URLs--ones embedded in the requirements file, not ones
        downloaded from an index server--are almost peers with ones from
        flags. They satisfy --require-hashes (whether it was implicitly or
        explicitly activated) but do not activate it. md5 and sha224 are
not
        allowed in flags, which should nudge people toward good algos. We
        always OR all hashes together, even ones from URLs.

        :param trust_internet: Whether to trust URL-based (#md5=...) hashes
            downloaded from the internet, as by populate_link()

        r,)
rhr�copyrXrY�hash�
setdefaultZ	hash_namerr.)rkZtrust_internetZgood_hashesrXr?r?r@r,Es

zInstallRequirement.hashes)NFNFTTNFNNF)NNFNNF)NFNNF)T)F)N)NNN)T).r��
__module__�__qualname__rn�classmethodryr�r�r�r��propertyr�r�r�r�r�rvr�r�r�r�r�r�r9�compileZ_requirements_section_rer�r�r�r�r�r�r
r	rr
r!rr$rr�r�r5r+r.r,r?r?r?r@rGIs`
;M

 :6


$0
\
)

rGcCstjd|�}|r|jd�}|S)z2
        Strip req postfix ( -dev, 0.2, etc )
   
z^(.*?)(?:-dev|-\d.*)$r7)r9r�r;)rJr:r?r?r@�_strip_postfix[s
r7cCs�ddlm}|}d}tjd|�}|r:|jd�}|jd�}n|}tjj|�rttjjtjj	|d��slt
d|��t|�}|j�j
d	�r�||�j}|r�||td
|j��jfS||dfSx,tD]$}|j�j
d|�r�d||f}Pq�Wd
|k�r|�r
tjdt�|d
|}nt
d|��|jd
d�dj�}	tj|	��s`d|dj	dd�tjD��d}
t
|
��||�j}|�sxt
d��|�s�t
d|��t|�|dfS)aParses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
       
svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    r)roNz^(.+)(\[[^\]]+\])$r7r8zsetup.pyz;Directory %r is not
installable. File 'setup.py' not
found.zfile:r}z%s:z%s+%sr�zD--default-vcs has been deprecated and will
be removed in the future.zb%s should either be a path to a local project or
a VCS url beginning with svn+, git+, hg+, or bzr+zFor --editable=%s only
z,
cSsg|]}|jd�qS)z+URL)rv)rBr�r?r?r@r��sz"parse_editable.<locals>.<listcomp>z
is currently supportedz@Could not detect requirement name, please specify
one with #egg=z@--editable=%s is not the right format; it must have
#egg=Package)rpror9r:r;rMr<r�r�r�rrr�rrr�rr>r4r�r�r/r~r�Zbackendsr7)rtrurorwr>r=Z
url_no_extrasZpackage_nameZversion_controlr�Z
error_messager?r?r@rqgs`





rq)N)eZ
__future__rZloggingrMr9r�r�r�rQr�rZ	distutilsrZdistutils.utilrZemail.parserrZpip._vendorrrZpip._vendor.packagingrZpip._vendor.packaging.markersr	Z"pip._vendor.packaging.requirementsr
rZpip._vendor.packaging.utilsrZpip._vendor.packaging.versionr
rr�Zpip._vendor.six.movesrZ	pip.wheelr�Z
pip.compatrrrZpip.downloadrrrrZpip.exceptionsrrZ
pip.locationsrrrrZ	pip.utilsrrrr
r!r"r#r$r%r&r'r(r)r*r+r,r-Zpip.utils.hashesr.Zpip.utils.deprecationr/Zpip.utils.loggingr0Zpip.utils.setuptools_buildr1Zpip.utils.uir2Zpip.req.req_uninstallr3Zpip.vcsr4r5r6Z	getLoggerr�r�Z	SpecifierZ
_operators�keysrPrArF�objectrGr7rqr?r?r?r@�<module>s`L