1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
U
H=®dCIã@svdZddlZddlZddlmZddlmZddlmZddl    m
Z
m Z m Z m Z mZddlmZddlmZdd    lmZdd
lmZdd lmZdd lmZmZdd lmZmZddlm Z e rNddl!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddlm3Z3ddlm4Z4e"e5e#e3fZ6e 7e8¡Z9ddd„Z:Gdd„deƒZ;dS)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)Úcheck_invalid_constraint_type)ÚRequirementSet)Ú BaseResolver)Ú get_supported)Ú
indent_log)Údist_in_usersiteÚnormalize_version_info)Úcheck_requires_pythonÚget_requires_python)ÚMYPY_CHECK_RUNNING)Ú DefaultDictÚListÚOptionalÚSetÚTuple)Ú pkg_resources)Ú
WheelCache)ÚAbstractDistribution)Ú PackageFinder)ÚLink)ÚRequirementPreparer)ÚInstallRequirement)ÚInstallRequirementProviderFc
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}) rrrÚInvalidSpecifierÚloggerÚwarningÚ project_nameÚjoinÚmapÚstrÚdebugr    Úformat)Údistr!Úignore_requires_pythonÚrequires_pythonÚ is_compatibleÚexcÚversion©r2ú_D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/resolution/legacy/resolver.pyÚ_check_dist_requires_python<s>ÿ
þýÿÿr4csteZdZdZdddhZd‡fdd„    Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Z‡ZS)Ú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|ƒ ¡|
|jkst‚| dkr4tjdd…} nt| ƒ} | |_||_    ||_
||_ |
|_ |    |_ ||_||_||_||_||_ttƒ|_dS)Né)Úsuperr5Ú__init__Ú_allowed_strategiesÚAssertionErrorÚsysr!rÚ_py_version_infoÚpreparerÚfinderÚ wheel_cacheÚupgrade_strategyÚforce_reinstallÚignore_dependenciesÚignore_installedr-Ú use_user_siteÚ_make_install_reqrÚlistÚ_discovered_dependencies) Úselfr@rArBÚmake_install_reqrGrErFr-rDrCÚpy_version_info©Ú    __class__r2r3r;ss$ÿzResolver.__init__c Csžt|d}|D]}|jr t|ƒ| |¡qg}tƒ}t|j|ƒD]N}z| | ||¡¡WqBt    k
rŽ}z||_
|  |¡W5d}~XYqBXqB|rš|‚|S)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.
        )Úcheck_supported_wheelsN) r Ú
constraintr
Úadd_requirementrrÚall_requirementsÚextendÚ _resolve_onerÚreqÚappend)rKÚ    root_reqsrPÚrequirement_setrVÚdiscovered_reqsÚ hash_errorsr0r2r2r3Úresolve›s$ ÿ zResolver.resolvecCs:|jdkrdS|jdkrdS|jdks*t‚|jp4|jSdS)Nr8Fr6Tr7)rCr=Ú user_suppliedrQ©rKrVr2r2r3Ú_is_upgrade_allowedÁs 
 
zResolver._is_upgrade_allowedcCs |jrt|jƒrd|_d|_dS)z4
        Set a requirement to be installed.
        TN)rGrÚ satisfied_byÚshould_reinstallr^r2r2r3Ú_set_req_to_reinstallËszResolver._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.
        Nr7z#already satisfied, skipping upgradezalready satisfiedT)Úupgradezalready up-to-date) rFÚcheck_if_existsrGr`rDrbr_rCÚlinkrAÚfind_requirementrr)rKÚreq_to_installr2r2r3Ú_check_skip_installedÖs* 
 
 
 
zResolver._check_skip_installedcCsR| |¡}|j ||¡}|s dS|j}|jrN|jp4d}dj||d}t |¡|S)Nz <none given>zqThe candidate selected for download or install is a yanked version: {candidate}
Reason for being yanked: {reason})Ú    candidateÚreason)    r_rArfreÚ    is_yankedÚ yanked_reasonr+r$r%)rKrVrcÚbest_candidatererjÚmsgr2r2r3Ú_find_requirement_link s
 
üù
zResolver._find_requirement_linkcCs~|jdkr| |¡|_|jdks(|jjr,dS|jj|j|jtƒd}|dk    rzt     d|j¡|j|j
krr|j rrd|_ |j|_dS)afEnsure that if a link can be found for this, that it is found.
 
        Note that req.link may still be None - if the requirement is already
        installed and not needed to be upgraded based on the return value of
        _is_upgrade_allowed().
 
        If preparer.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.
        N)reÚ package_nameÚsupported_tagszUsing cached wheel link: %sT) rerorBr@Úrequire_hashesÚget_cache_entryÚnamer r$r*Ú original_linkÚ
persistentÚoriginal_link_is_in_wheel_cache)rKrVÚ cache_entryr2r2r3Ú_populate_link"s
 ýzResolver._populate_linkcCs®|jr|j |¡S|jdks t‚| |¡}|jr>|j ||¡S| |¡|j |¡}|j    sf| 
|j ¡|jrª|j dkpŒ|j pŒ|j    pŒ|jjdk}|rž| |¡n t d|¡|S)zzTakes a InstallRequirement and returns a single AbstractDist         representing a prepared variant of the same.
        Nr8Úfilez<Requirement already satisfied (use --upgrade to upgrade): %s)Úeditabler@Úprepare_editable_requirementr`r=rhÚprepare_installed_requirementryÚprepare_linked_requirementrFrdrGrCrDreÚschemerbr$Úinfo)rKrVÚ skip_reasonÚ abstract_distÚ should_modifyr2r2r3Ú_get_abstract_dist_for@s8 
ÿ
 
 
ÿþ
ü þzResolver._get_abstract_dist_forc
    s&ˆjs ˆjrgSdˆ_ˆ ˆ¡}| ¡}t|ˆjˆjdg‰‡‡‡‡fdd„}tƒÆˆ ˆj    ¡s|ˆj
snt ‚ˆj ˆddˆj sˆjržt dd ˆj¡¡ttˆjƒt|jƒƒ}|D]}t d    ||¡qºtt|jƒtˆjƒ@ƒ}| |¡D]}    ||    |d
qðˆjsˆjsdˆ_W5QRXˆS) zxPrepare a single requirements file.
 
        :return: A list of additional InstallRequirements to also install.
        T)r!r-csPˆ t|ƒˆ¡}ˆj}ˆj|||d\}}|rB|rBˆj| |¡ˆ |¡dS)N)Úparent_req_nameÚextras_requested)rHr)rtrRrJrWrT)Úsubreqr†Úsub_install_reqr…Ú to_scan_againÚ add_to_parent©Ú    more_reqsrgrYrKr2r3Úadd_req‘sþý
 
ÿz&Resolver._resolve_one.<locals>.add_reqN)r…z!Installing extra requirements: %rú,z"%s does not provide the extra '%s')r†)rQÚpreparedr„Úget_pkg_resources_distributionr4r?r-rÚhas_requirementrtr]r=rRrEÚextrasr$r*r'ÚsortedÚsetr%Úrequiresr{r`Úsuccessfully_downloaded)
rKrYrgr‚r,rÚmissing_requestedÚmissingÚavailable_requestedr‡r2r‹r3rUrsT 
þ 
ÿ
þÿþÿ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ˆ |¡dS)N)r`rQÚaddrJrtrW)rVÚdep©ÚorderÚ ordered_reqsÚschedulerKr2r3rŸÙs
 
z1Resolver.get_installation_order.<locals>.schedule)r”Ú requirementsÚvalues)rKÚreq_setÚ install_reqr2rœr3Úget_installation_orderËs 
 
zResolver.get_installation_order)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r<r;r\r_rbrhroryr„rUr¤Ú __classcell__r2r2rNr3r5ls
ô(&
 52Yr5)F)<r¨Úloggingr>Ú collectionsrÚ    itertoolsrZpip._vendor.packagingrÚpip._internal.exceptionsrrrrr    Zpip._internal.req.req_installr
Zpip._internal.req.req_setr Úpip._internal.resolution.baser Ú&pip._internal.utils.compatibility_tagsr Úpip._internal.utils.loggingrÚpip._internal.utils.miscrrÚpip._internal.utils.packagingrrÚpip._internal.utils.typingrÚtypingrrrrrÚ pip._vendorrÚpip._internal.cacherÚpip._internal.distributionsrÚ"pip._internal.index.package_finderrÚpip._internal.models.linkrÚ pip._internal.operations.preparerrr r)ZDiscoveredDependenciesÚ    getLoggerr¥r$r4r5r2r2r2r3Ú<module>s:                 
0