a lj#@sddlZddlZddlmZmZmZmZmZmZm Z ddl m Z ddl m Z mZmZddlmZddlmZerddl mZdd lmZeee fZe ee efZne ZGd d d eZdS) N) TYPE_CHECKINGDictIterableIteratorMappingSequenceUnion)AbstractProvider) Candidate Constraint Requirement)REQUIRES_PYTHON_IDENTIFIER)Factory) Preference)RequirementInformationc@s eZdZdZeeeefeeeee fddddZ e e e fedddZeeee feeee feeed fed d d d d ZeedddZeeeee feeee fee dddZe e edddZe ee dddZeeed edddZdS) PipProvideraPip's provider implementation for resolvelib. :params constraints: A mapping of constraints specified by the user. Keys are canonicalized project names. :params ignore_dependencies: Whether the user specified ``--no-deps``. :params upgrade_strategy: The user-specified upgrade strategy. :params user_requested: A set of canonicalized package names that the user supplied for pip to install/upgrade. N)factory constraintsignore_dependenciesupgrade_strategyuser_requestedreturncCs2||_||_||_||_||_tdd|_dS)NcSstjSN)mathinfrrP/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/provider.py@z&PipProvider.__init__..)_factory _constraints_ignore_dependencies_upgrade_strategy_user_requested collections defaultdict _known_depths)selfrrrrrrrr__init__3s zPipProvider.__init__)requirement_or_candidatercCs|jSrname)r(r*rrridentifyBszPipProvider.identifyPreferenceInformationr) identifier resolutions candidates informationbacktrack_causesrc sdd||D}t|\}}dddd|DD} |du} tdd| D} t| } zj|} WnDtytj} fdd||D}td d|Dd }Yn0d }|j|<j |tj} |t k}|d k} ||}| || | | || | |f S) a[Produce a sort key for given requirement based on preference. The lower the return value is, the more preferred this group of arguments is. Currently pip considers the followings in order: * Prefer if any of the known requirements is "direct", e.g. points to an explicit URL. * If equal, prefer if any requirement is "pinned", i.e. contains operator ``===`` or ``==``. * If equal, calculate an approximate "depth" and resolve requirements closer to the user-specified requirements first. * Order user-specified requirements by the order they are specified. * If equal, prefers "non-free" requirements, i.e. contains at least one operator, such as ``>=`` or ``<``. * If equal, order alphabetically for consistency (helps debuggability). css|]\}}|VqdSr)Zget_candidate_lookup).0r_rrr _rz-PipProvider.get_preference..cSsg|]}|D] }|jq qSr)operator)r4Z specifier_set specifierrrr asz.PipProvider.get_preference..css|]}|r|jVqdSr)r9)r4Zireqrrrr7crNcss|]}|dddkVqdS)Nz==r)r4oprrrr7hrc3s*|]"\}}|durj|jndVqdS)Ng)r'r,)r4r6parentr(rrr7oscss|] }|VqdSrr)r4drrrr7srg?Z setuptools) zipanyboolr$KeyErrorrrminr'getris_backtrack_cause)r(r/r0r1r2r3Zlookups candidateZireqsZ operatorsZdirectZpinnedZunfreeZrequested_orderZ parent_depthsZinferred_depthZrequires_pythonZ delay_thisbacktrack_causerr>rget_preferenceEs@       zPipProvider.get_preference)r/rcCsD||jvr|j|S|d\}}}|r<||jvr<|j|StS)N[)r! partitionr empty)r(r/r,Z open_bracketr6rrr_get_constraints    zPipProvider._get_constraint)r/ requirementsincompatibilitiesrcs6ttdfdd }jj||||| |dS)N)r,rcs&jdkrdSjdkr"|jvSdS)aAre upgrades allowed for this project? This checks the upgrade strategy, and whether the project was one that the user specified in the command line, in order to decide whether we should upgrade if there's a newer version available. (Note that we don't need access to the `--upgrade` flag, because an upgrade strategy of "to-satisfy-only" means that `--upgrade` was not specified). ZeagerTzonly-if-neededF)r#r$r+r>rr_eligible_for_upgrades   z7PipProvider.find_matches.._eligible_for_upgrade)r/rNZ constraintZprefers_installedrO)strrBr Zfind_candidatesrM)r(r/rNrOrPrr>r find_matchesszPipProvider.find_matches) requirementrGrcCs ||Sr)is_satisfied_by)r(rSrGrrrrTszPipProvider.is_satisfied_by)rGrcCs|j }dd||DS)NcSsg|]}|dur|qSrr)r4r5rrrr:rz0PipProvider.get_dependencies..)r"Ziter_dependencies)r(rGZ with_requiresrrrget_dependenciesszPipProvider.get_dependencies)r/r3rcCs8|D].}||jjkrdS|jr||jjkrdSqdS)NTF)rSr,r=)r/r3rHrrrrFs  zPipProvider.is_backtrack_cause)__name__ __module__ __qualname____doc__rrrQr rBintr)rr r r-rrrrrIrMrRrTrU staticmethodrFrrrrr(s8      T r)r%rtypingrrrrrrrZ pip._vendor.resolvelib.providersr baser r r r1rrrrZ pip._vendor.resolvelib.resolversrr.rQZ _ProviderBaserrrrrs$