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_set.cpython-36.pyc

3

���^��@s~ddlmZddlmZddlmZddlZddlZddlm	Z	ddlm
Z
ddlmZddl
mZmZmZmZmZdd	lmZmZmZmZmZmZmZmZmZmZdd
lmZddl
m!Z!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'dd
l(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ej0e1�Z2Gdd�de3�Z4Gdd�de3�Z5dd�Z6Gdd�de5�Z7Gdd�de5�Z8Gdd�de5�Z9Gdd�de3�Z:dS)�)�absolute_import)�defaultdict)�chainN)�
pkg_resources)�requests)�
expanduser)�is_file_url�
is_dir_url�
is_vcs_url�url_to_path�
unpack_url)
�InstallationError�BestVersionAlreadyInstalled�DistributionNotFound�PreviousBuildDirError�	HashError�
HashErrors�HashUnpinned�DirectoryUrlHashUnsupported�VcsHashUnsupported�UnsupportedPythonVersion)�InstallRequirement)�display_path�dist_in_usersite�dist_in_install_path�
ensure_dir�normalize_path)�
MissingHashes)�
indent_log)�check_dist_requires_python)�vcs)�Wheelc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�RequirementscCsg|_i|_dS)N)�_keys�_dict)�self�r&�/usr/lib/python3.6/req_set.py�__init__"szRequirements.__init__cCs|jS)N)r#)r%r&r&r'�keys&szRequirements.keyscs�fdd��jD�S)Ncsg|]}�j|�qSr&)r$)�.0�key)r%r&r'�
<listcomp>*sz'Requirements.values.<locals>.<listcomp>)r#)r%r&)r%r'�values)szRequirements.valuescCs
||jkS)N)r#)r%�itemr&r&r'�__contains__,szRequirements.__contains__cCs$||jkr|jj|�||j|<dS)N)r#�appendr$)r%r+�valuer&r&r'�__setitem__/s
zRequirements.__setitem__cCs
|j|S)N)r$)r%r+r&r&r'�__getitem__4szRequirements.__getitem__cs$�fdd��j�D�}ddj|�S)Ncs$g|]}dt|�t�|�f�qS)z%s:
%s)�repr)r*�k)r%r&r'r,8sz)Requirements.__repr__.<locals>.<listcomp>zRequirements({%s})z,
)r)�join)r%r-r&)r%r'�__repr__7szRequirements.__repr__N)
�__name__�
__module__�__qualname__r(r)r-r/r2r3r7r&r&r&r'r"
sr"c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�DistAbstractionatAbstracts
out the wheel vs non-wheel prepare_files logic.

    The requirements for anything installable are as follows:
     - we must be able to determine the requirement name
       (or we can't correctly handle the non-upgrade case).
     - we must be able to generate a list of run-time dependencies
       without installing any additional packages (or we would
       have to either burn time by doing temporary isolated installs
       or alternatively violate pips 'don't start installing
unless
       all requirements are available' rule - neither of which are
       desirable).
     - for packages with setup requirements, we must also be able
       to determine their requirements without installing additional
       packages (for the same reason as run-time dependencies)
     - we must be able to create a Distribution object exposing the
       above metadata.
    cCs
||_dS)N)�req_to_install)r%r<r&r&r'r(OszDistAbstraction.__init__cCst|j��dS)z
Return a setuptools Dist
object.N)�NotImplementedError�dist)r%�finderr&r&r'r>RszDistAbstraction.distcCst|j��dS)z3Ensure
that we can get a Dist for this
requirement.N)r=r>)r%r&r&r'�
prep_for_distVszDistAbstraction.prep_for_distN)r8r9r:�__doc__r(r>r@r&r&r&r'r;<sr;cCs0|jrt|�S|jr$|jjr$t|�St|�SdS)z�Factory
to make an abstract dist object.

    Preconditions: Either an editable req with a source_dir, or
satisfied_by or
    a wheel link, or a non-editable req with a source_dir.

    :return: A concrete DistAbstraction.
   
N)�editable�IsSDist�link�is_wheel�IsWheel)r<r&r&r'�make_abstract_dist[s
rGc@seZdZdd�Zdd�ZdS)rFcCsttj|jj��dS)Nr)�listrZfind_distributionsr<�
source_dir)r%r?r&r&r'r>mszIsWheel.distcCsdS)Nr&)r%r&r&r'r@qszIsWheel.prep_for_distN)r8r9r:r>r@r&r&r&r'rFksrFc@seZdZdd�Zdd�ZdS)rCcCs(|jj�}|jd�r$|j|jd��|S)Nzdependency_links.txt)r<Zget_distZhas_metadataZadd_dependency_linksZget_metadata_lines)r%r?r>r&r&r'r>xs


zIsSDist.distcCs|jj�|jj�dS)N)r<Zrun_egg_infoZassert_source_matches_version)r%r&r&r'r@�s
zIsSDist.prep_for_distN)r8r9r:r>r@r&r&r&r'rCvs	rCc@seZdZdd�Zdd�ZdS)�	InstalledcCs|jjS)N)r<�satisfied_by)r%r?r&r&r'r>�szInstalled.distcCsdS)Nr&)r%r&r&r'r@�szInstalled.prep_for_distN)r8r9r:r>r@r&r&r&r'rJ�srJc@s�eZdZd$dd�Zdd�Zdd	�Zd%d
d�Zdd
�Zedd��Z	edd��Z
dd�Zd&dd�Zdd�Z
dd�Zdd�Zd'dd�Zdd�Zd
d!�Zffd"d#�ZdS)(�RequirementSetFNTcCs�|dkrtd��||_||_||_||_||_||_|
|_t�|_	i|_
g|_|	|_||_
g|_g|_g|_||_||_||_||_|
|_||_|r�t|�}||_||_||_tt�|_dS)a3Create
a RequirementSet.

        :param wheel_download_dir: Where still-packed .whl files should be
            written to. If None they are written to the download_dir
parameter.
            Separate to download_dir to permit only keeping wheel archives
for
            pip wheel.
        :param download_dir: Where still packed archives should be written
to.
            If None they are not saved, and are deleted immediately after
            unpacking.
        :param wheel_cache: The pip wheel cache, for passing to
            InstallRequirement.
        Nz?RequirementSet() missing 1 required keyword argument:
'session')�	TypeError�	build_dir�src_dir�download_dir�upgrade�upgrade_strategy�ignore_installed�force_reinstallr"�requirements�requirement_aliases�unnamed_requirements�ignore_dependencies�ignore_requires_python�successfully_downloaded�successfully_installed�reqs_to_cleanup�as_egg�
use_user_site�
target_dir�session�	pycompile�isolatedr�wheel_download_dir�_wheel_cache�require_hashesrrH�
_dependencies)r%rNrOrPrQrRrSr]r_rXrTr^r`rarbrc�wheel_cachererYr&r&r'r(�s<zRequirementSet.__init__cCs8dd�|jj�D�}|jdd�d�djdd�|D��S)NcSsg|]}|js|�qSr&)Z
comes_from)r*�reqr&r&r'r,�sz*RequirementSet.__str__.<locals>.<listcomp>cSs
|jj�S)N)�name�lower)rhr&r&r'�<lambda>�sz(RequirementSet.__str__.<locals>.<lambda>)r+�
cSsg|]}t|j��qSr&)�strrh)r*rhr&r&r'r,�s)rUr-�sortr6)r%�reqsr&r&r'�__str__�szRequirementSet.__str__cCsNdd�|jj�D�}|jdd�d�djdd�|D��}d|jjt|�|fS)	NcSsg|]}|�qSr&r&)r*rhr&r&r'r,�sz+RequirementSet.__repr__.<locals>.<listcomp>cSs
|jj�S)N)rirj)rhr&r&r'rk�sz)RequirementSet.__repr__.<locals>.<lambda>)r+z,
cSsg|]}t|j��qSr&)rmrh)r*rhr&r&r'r,�sz"<%s
object; %d requirement(s):
%s>)rUr-rnr6�	__class__r8�len)r%roZreqs_strr&r&r'r7�s
zRequirementSet.__repr__c	
Cs�|j}|j|�s&tjd|j|j�gS|jrV|jjrVt|jj�}|j	�sVt
d|j��|j|_|j|_|j
|_
|j|_|dk|_|s�|jj|�|gSy|j|�}Wntk
r�d}YnX|dko�|o�|jo�|j|jko�|jj|jjk�rt
d|||f��|�s8||j|<|j�|k�r0||j|j�<|g}n�g}|j�r�|j�r�|j�r�|j�ol|jj|jjk�r�|jj|�t
d|��d|_ttt|j�j
t|j����|_tj!d||j�|g}|}|�r�|j|�}|j"|j|�|SdS)a'Add
install_req as a requirement to install.

        :param parent_req_name: The name of the requirement that needed
this
            added. The name is used because when multiple unnamed
requirements
            resolve to the same name, we could otherwise end up with
dependency
            links that point outside the Requirements set. parent_req must
            already be added. Note that None implies that this is a user
            supplied requirement, vs an inferred one.
        :param extras_requested: an iterable of extras used to evaluate the
            environement markers.
        :return: Additional requirements to scan. That is either [] if
            the requirement is not applicable, or [install_req] if the
            requirement is applicable and has just been added.
        z6Ignoring %s: markers '%s' don't match your
environmentz-%s is not a supported wheel on this platform.Nz5Double
requirement given: %s (already in %s, name=%r)zhCould not satisfy
constraints for '%s': installation from path or url cannot be
constrained to a versionFzSetting %s extras to:
%s)#riZ
match_markers�logger�warningZmarkersrDrEr!�filenameZ	supportedr
r]r^r_ra�	is_directrWr0�get_requirement�KeyError�
constraint�extrasrhZ	specifierrUrjrV�pathr\�tuple�sorted�set�union�debugrf)	r%�install_reqZparent_req_name�extras_requestedriZwheelZexisting_req�resultZ
parent_reqr&r&r'�add_requirement�sp






zRequirementSet.add_requirementcCsF|j�}||jkr
|j|js>||jkrB|j|j|jrBdSdS)NTF)rjrUryrV)r%�project_namerir&r&r'�has_requirement4s

zRequirementSet.has_requirementcCstdd�|jj�D��p|jS)Ncss|]}|js|VqdS)N)ry)r*rhr&r&r'�	<genexpr>?sz2RequirementSet.has_requirements.<locals>.<genexpr>)rHrUr-rW)r%r&r&r'�has_requirements=szRequirementSet.has_requirementscCsD|jr@t|j�|_tjj|j�r$dStjd�tdt|j���dS)NTz!Could
not find download directoryz0Could not find or access download directory
'%s'F)	rPr�osr{�existsrs�criticalr
r)r%r&r&r'�is_downloadBs
zRequirementSet.is_downloadcCsTxB||j�fD]2}||jkr&|j|S||jkr|j|j|SqWtd|��dS)NzNo
project with the name %r)rjrUrVrx)r%r�rir&r&r'rwOs


zRequirementSet.get_requirementcCs4x.|jj�D]
}|jrq|j|d�|j�qWdS)N)�auto_confirm)rUr-ry�	uninstall�commit_uninstall)r%r�rhr&r&r'r�Ws
zRequirementSet.uninstallcCs�|jrt|j�|j|jj�}|jp6tdd�|D��}|rJ|jrJtd��g}t	�}xdt
||�D]V}y|j|j||||j
d��Wq`tk
r�}z||_|j|�WYdd}~Xq`Xq`W|r�|�dS)zY
        Prepare process. Create temp directories, download and/or unpack
files.
       
css|]}|jVqdS)N)Zhas_hash_options)r*rhr&r&r'r�jsz/RequirementSet.prepare_files.<locals>.<genexpr>z�--egg
is not allowed with --require-hashes mode, since it delegates dependency
resolution to setuptools and could thus result in installation of unhashed
packages.)rerXN)rcrrWrUr-re�anyr]r
rr�extend�
_prepare_filerXrrhr0)r%r?Z	root_reqsreZdiscovered_reqsZhash_errorsrh�excr&r&r'�
prepare_files^s,

 zRequirementSet.prepare_filescCs
|jo|jdkp|jdko|jS)NZeagerzonly-if-needed)rQrRrv)r%rhr&r&r'�_is_upgrade_allowed�s
z"RequirementSet._is_upgrade_allowedcCs�|j�|jr�|j|�}d}|r�|jp*|jshy|j||�Wn*tk
rTd}Yntk
rfYnX|s�|jr~t	|j�p�t
|j�s�|j|_d|_|r�d}n|jdkr�d}nd}|SdSdS)aCheck
if req_to_install should be skipped.

        This will check if the req is installed, and whether we should
upgrade
        or reinstall it, taking into account all the relevant user options.

        After calling this req_to_install will only have satisfied_by set
to
        None if the req_to_install is to be upgraded/reinstalled etc. Any
        other value will be a dist recording the current thing installed
that
        satisfies the requirement.

        Note that for vcs urls and the like we can't assess skipping
in this
        routine - we simply identify that we need to pull the thing down,
        then later on it is pulled down and introspected to assess upgrade/
        reinstalls etc.

        :return: A text reason for why it was skipped, or None.
        FTNzalready up-to-datezonly-if-neededz%not upgraded as not
directly requiredzalready
satisfied)
�check_if_existsrKr�rTrDZfind_requirementrrr^rr�conflicts_withrR)r%r<r?Zupgrade_allowedZbest_installed�skip_reasonr&r&r'�_check_skip_installed�s4

z$RequirementSet._check_skip_installedc(s��js�jrgSd�_�jr*tjd��n��jdks8t��jsJ�j�|�}�jrx|dk	shtd�jf��tjd|��n<�j	r��j	j
dkr�t�j	j�}tjdt
|��ntjd��t�����j�r
|r�td	����j�j��j�j�t��}|j��j�r�j�j��j��n0�j�rD|�r8tjd
�t��}�n�j�j�tjjtjj�j
d���r|t!d��j
f���j"|�j#��|��j	�s�t��j	}|�r�t$|��r�t%��nt&|��r�t'|��r�t(���j)�r�j*�r�t+���j,|d
�}	|�r|	�rt-�}	yZ�j}
d}�j	j.�r4�j/�r4�j/}
�j	j.�rN|
�rJd}nd}t0�j	�j |
|�j1|	d�WnHt2j3k
�r�}z(tj4d�|�td�|�j	f��WYdd}~XnXt��}|j��j�r�j	j
t5j6k�r�j�j��j�s��j��j�rP�j7�s�j�rD�j8�r&t9�j��p0t:�j��s<�j�_;d�_ntjd��|j<|�}
yt=|
�WnHt>k
�r�}z*�j?�r�tj@|jAd�n
�jB��WYdd}~XnXg����fdd�}�jC�jD��sވjE�d�|�sp�jF�rtjddj�jF��tGtH�jF�tH|
jF��}x|D]}tj@d|
|��qWtGtH|
jF�tH�jF�@�}x
|
jI|�D]}|||d��qZW�jJjK���j�r��j�r��jLjK��WdQRX�S)zxPrepare
a single requirements file.

        :return: A list of additional InstallRequirements to also install.
        TzObtaining %sNzP_check_skip_installed returned None but
req_to_install.satisfied_by is set to %rzRequirement %s:
%s�filez
Processing %sz
Collecting %szoThe editable requirement %s
cannot be installed when requiring hashes, because there is no single file
to hash.z�Since it is already installed, we are trusting this package
without checking its hash. To ensure a completely repeatable environment,
install into an empty virtualenv.zsetup.pyz�pip can't proceed with
requirements '%s' due to a pre-existing build directory (%s).
This is likely due to a previous installation that failed. pip is being
responsible and not assuming it can delete this. Please delete it and try
again.)Ztrust_internetF)r`�hashesz4Could not install requirement %s
because of error %szDCould not install requirement %s because of HTTP error
%s for URL %sz<Requirement already satisfied (use --upgrade to upgrade):
%srcs4tt|���j�jd�}�j�j|�j|d��dS)N)rbrg)r�)rrmrbrdr�r�ri)�subreqr�Zsub_install_req)�	more_reqsr<r%r&r'�add_req�s
z-RequirementSet._prepare_file.<locals>.add_reqz!Installing
extra requirements: %r�,z"%s does not provide the extra
'%s')r�)MryZpreparedrBrs�inforK�AssertionErrorrSr�rD�schemerZurlrrr
Zensure_has_source_dirrOZupdate_editabler�rGr@�archiverPr�r�rJrNr�r{r�r6rIrZ
populate_linkr�r
rrr	rZ
original_linkZ	is_pinnedrr�rrErcrr`rZ	HTTPErrorr�r
Zall_schemesrQr^rrr�r>rrrYrt�args�remove_temporary_sourcer�rir�rzr}r~Zrequiresr\r0rZ)r%r?r<rerXr�r{Z
abstract_distrDr�rPZautodelete_unpackedr�r>�er�Zmissing_requestedZmissingZavailable_requestedr�r&)r�r<r%r'r��s

	





"


zRequirementSet._prepare_filec	Cs8tjd�t��x|jD]}|j�qWWdQRXdS)zClean
up files, remove builds.zCleaning
up...N)rsr�rr\r�)r%rhr&r&r'�
cleanup_files�s
zRequirementSet.cleanup_filescs<g�t������fdd��x�jj�D]}�|�q(W�S)z�Create
the installation order.

        The installation order is topological - requirements are installed
        before the requiring thing. We break cycles at an arbitrary point,
        and make no other guarantees.
       
csP|js|�krdS|jrdS�j|�x�j|D]}�|�q2W�j|�dS)N)rKry�addrfr0)rhZdep)�order�ordered_reqs�scheduler%r&r'r��s
z,RequirementSet._to_install.<locals>.schedule)r~rUr-)r%r�r&)r�r�r�r%r'�_to_install�s
	zRequirementSet._to_installcOs�|j�}|r(tjddjdd�|D���t���x�|D]�}|jrltjd|j�t��|jdd�WdQRXy|j||f|�|�Wn$|jr�|jr�|j	��YnX|jr�|jr�|j
�|j�q6WWdQRX||_dS)	zl
        Install everything in this set (after having downloaded and
unpacked
        the packages)
        z!Installing collected packages: %sz, cSsg|]
}|j�qSr&)ri)r*rhr&r&r'r,sz*RequirementSet.install.<locals>.<listcomp>zFound
existing installation:
%sT)r�N)
r�rsr�r6rr�r��installZinstall_succeededZrollback_uninstallr�r�r[)r%Zinstall_optionsZglobal_optionsr��kwargsZ
to_installZrequirementr&r&r'r��s:

zRequirementSet.install)FNFFNFFFNTFNNFF)NN)F)FF)r8r9r:r(rpr7r�r��propertyr�r�rwr�r�r�r�r�r�r�r�r&r&r&r'rL�s4
4
[	

'E
	rL);Z
__future__r�collectionsr�	itertoolsrZloggingr�Zpip._vendorrrZ
pip.compatrZpip.downloadrr	r
rrZpip.exceptionsr
rrrrrrrrrZpip.req.req_installrZ	pip.utilsrrrrrZpip.utils.hashesrZpip.utils.loggingrZpip.utils.packagingrZpip.vcsr
Z	pip.wheelr!Z	getLoggerr8rs�objectr"r;rGrFrCrJrLr&r&r&r'�<module>s00