U ��.eRC�@sFdZddlZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZddlmZddlmZmZmZmZdd lmZmZdd lmZe�rdd lmZmZmZmZm Z m!Z!dd l"m#Z#dd l$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ee0e-ge-fZ1e�2e3�Z4ddd�Z5Gdd�de6�Z7dS)ayDependency Resolution The dependency resolution in pip is performed as follows: for top-level requirements: a. only one spec allowed per project, regardless of conflicts or not. otherwise a "double requirement" exception is raised b. they override sub-dependency requirements. for sub-dependencies a. "first found, wins" (where the order is breadth first) �N)� defaultdict)�chain)� specifiers)�BestVersionAlreadyInstalled�DistributionNotFound� HashError� HashErrors�UnsupportedPythonVersion)� indent_log)�dist_in_install_path�dist_in_usersite� ensure_dir�normalize_version_info)�check_requires_python�get_requires_python)�MYPY_CHECK_RUNNING)�Callable� DefaultDict�List�Optional�Set�Tuple)� pkg_resources)�AbstractDistribution)� PipSession)� PackageFinder)�RequirementPreparer)�InstallRequirement)�RequirementSetFc Cs�t|�}zt||d�}Wn:tjk rR}zt�d|j|�WY�dSd}~XYnX|r\dSd�tt |��}|r�t� d|j||�dSt d� |j||���dS)a� Check whether the given Python version is compatible with a distribution's "Requires-Python" value. :param version_info: A 3-tuple of ints representing the Python major-minor-micro version to check. :param ignore_requires_python: Whether to ignore the "Requires-Python" value if the given Python version isn't compatible. :raises UnsupportedPythonVersion: When the given Python version isn't compatible. )� version_infoz-Package %r has an invalid Requires-Python: %sN�.zBIgnoring failed Requires-Python check for package %r: %s not in %rz8Package {!r} requires a different Python: {} not in {!r}) rrrZInvalidSpecifier�logger�warningZ project_name�join�map�str�debugr �format)�distr�ignore_requires_pythonZrequires_pythonZ is_compatible�exc�version�r,�@/usr/lib/python3.8/site-packages/pip/_internal/legacy_resolve.py�_check_dist_requires_python>s>� ����r.csdeZdZdZdddhZd�fdd� Zdd �Zd d �Zd d �Zdd�Z dd�Z dd�Z dd�Z �Z S)�Resolverz�Resolves which packages need to be installed/uninstalled to perform the requested operation without breaking the requirements of any package. �eager�only-if-needed�to-satisfy-onlyNc s�tt|���| dkr&tjdd�} nt| �} | |_||_||_||_ d|_ | |_ | |_ ||_ ||_||_||_||_tt�|_dS)N�)�superr/�__init__�sysrr�_py_version_info�preparer�finder�session�require_hashes�upgrade_strategy�force_reinstall�ignore_dependencies�ignore_installedr)� use_user_site�_make_install_reqr�list�_discovered_dependencies) �selfr8r:r9Zmake_install_reqr@r>r?r)r=r<Zpy_version_info�� __class__r,r-r5us$�zResolver.__init__c Cs�|jjrt|jj�|jt|j���}|jp>tdd�|D��|_|j j }|� �}|r`t � |�g}t�}t||�D]N}z|�|�||��Wqttk r�}z||_|�|�W5d}~XYqtXqt|r�|�dS)a�Resolve what operations need to be done As a side-effect of this method, the packages (and their dependencies) are downloaded, unpacked and prepared for installation. This preparation is done by ``pip.operations.prepare``. Once PyPI has static dependency metadata available, it would be possible to move the preparation to become a step separated from dependency resolution. css|] }|jVqdS�N)Zhas_hash_options)�.0�reqr,r,r-� �sz#Resolver.resolve..N)r8Zwheel_download_dirr Zunnamed_requirementsrB� requirements�valuesr;�anyr9� search_scopeZget_formatted_locationsr!�inforr�extend� _resolve_onerrI�append) rD�requirement_setZ root_reqsrNZ locationsZdiscovered_reqsZ hash_errorsrIr*r,r,r-�resolve�s2   ���  �zResolver.resolvecCs&|jdkrdS|jdkrdS|jSdS)Nr2Fr0T)r<� is_direct�rDrIr,r,r-�_is_upgrade_allowed�s   zResolver._is_upgrade_allowedcCs,|jrt|j�r"t|j�r"|j|_d|_dS)z4 Set a requirement to be installed. N)r@r � satisfied_byr Zconflicts_withrVr,r,r-�_set_req_to_reinstall�s��zResolver._set_req_to_reinstallcCs�|jr dS|�|j�|js dS|jr4|�|�dS|�|�sP|jdkrLdSdS|js�z|j j |dd�Wn(t k r�YdSt k r�YnX|�|�dS)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. Nr1z#already satisfied, skipping upgradezalready satisfiedT)Zupgradezalready up-to-date) r?�check_if_existsr@rXr=rYrWr<�linkr9Zfind_requirementrr)rD�req_to_installr,r,r-�_check_skip_installed�s*     zResolver._check_skip_installedcCs�|jr|j�||j|j|j�S|�|�}|jr@|j�||j|�S|� |�}|� |j||j�|j� ||j |j|j�}|j s�|�|j�|jr�|jdkp�|jp�|j p�|jjdk}|r�|�|�n t�d|�|S)zzTakes a InstallRequirement and returns a single AbstractDist representing a prepared variant of the same. r2�filez.add_reqN)rbz!Installing extra requirements: %r�,z"%s does not provide the extra '%s')rc)� constraintZpreparedZreqs_to_cleanuprRraZget_pkg_resources_distributionr.r7r)r Zhas_requirementrdrUrer>Zextrasr!r&r#�sorted�setr"Zrequiresr_rXZsuccessfully_downloaded) rDrSr\r`r(rhZmissing_requestedZmissingZavailable_requestedrfr,rgr-rQ[sV   � � ����zResolver._resolve_onecs8g�t������fdd��|j��D] }�|�q&�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. csN|js|�krdS|jrdS��|��j|jD] }�|�q2��|�dSrG)rXrj�addrCrdrR)rIZdep��orderZ ordered_reqs�schedulerDr,r-rp�s  z1Resolver.get_installation_order..schedule)rlrKrL)rDZreq_setZ install_reqr,rnr-�get_installation_order�s   zResolver.get_installation_order)N)�__name__� __module__� __qualname__�__doc__Z_allowed_strategiesr5rTrWrYr]rarQrq� __classcell__r,r,rEr-r/ns �+3  5<Zr/)F)8ruZloggingr6� collectionsr� itertoolsrZpip._vendor.packagingrZpip._internal.exceptionsrrrrr Zpip._internal.utils.loggingr Zpip._internal.utils.miscr r r rZpip._internal.utils.packagingrrZpip._internal.utils.typingr�typingrrrrrrZ pip._vendorrZpip._internal.distributionsrZpip._internal.network.sessionrZpip._internal.indexrZ pip._internal.operations.preparerZpip._internal.req.req_installrZpip._internal.req.req_setrr%ZInstallRequirementProviderZ getLoggerrrr!r.�objectr/r,r,r,r-�s4              � � 0