U .eRC @ sF d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z mZmZm Z mZ ddlmZ ddlmZmZmZmZ dd lmZmZ dd lmZ erddlmZmZmZmZm Z m!Z! ddl"m#Z# dd l$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ee0e-ge-f Z1e2e3Z4dddZ5G dd de6Z7dS )ay Dependency 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)BestVersionAlreadyInstalledDistributionNotFound HashError HashErrorsUnsupportedPythonVersion) indent_log)dist_in_install_pathdist_in_usersite ensure_dirnormalize_version_info)check_requires_pythonget_requires_python)MYPY_CHECK_RUNNING)CallableDefaultDictListOptionalSetTuple) pkg_resources)AbstractDistribution) PipSession) PackageFinder)RequirementPreparer)InstallRequirement)RequirementSetFc C s t | }zt||d}W n: tjk rR } ztd| j| W Y dS d}~X Y nX |r\dS dtt |}|rt d| j|| dS td| 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}) r r r ZInvalidSpecifierloggerwarningZproject_namejoinmapstrdebugr format)distr ignore_requires_pythonZrequires_pythonZ is_compatibleexcversion r, @/usr/lib/python3.8/site-packages/pip/_internal/legacy_resolve.py_check_dist_requires_python> s> r. c sd e Zd ZdZdddhZd fdd Zdd Zd d Zdd Zdd Z dd Z dd Zdd Z Z S )ResolverzResolves which packages need to be installed/uninstalled to perform the requested operation without breaking the requirements of any package. eageronly-if-neededto-satisfy-onlyNc s t t| |d kr&tjd d }nt|}|| _|| _|| _|| _ d | _ | | _| | _|| _ || _|| _|| _|| _tt| _d S )N )superr/ __init__sysr r _py_version_infopreparerfindersessionrequire_hashesupgrade_strategyforce_reinstallignore_dependenciesignore_installedr) use_user_site_make_install_reqr list_discovered_dependencies)selfr8 r: r9 Zmake_install_reqr@ r> r? r) r= r<