zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
U
H=®dÙ/ã@s*dZddlZddlZddlZddlZddlmZmZddlm    Z    ddl
m Z ddl m Z ddlmZddlmZmZdd    lmZdd
lmZerÄdd lmZmZmZmZmZdd lmZdd lmZe  e!¡Z"dd„Z#Gdd„de$ƒZ%Gdd„de%ƒZ&Gdd„de&ƒZ'Gdd„de$ƒZ(Gdd„de%ƒZ)dS)zCache Management
éN)Úinterpreter_nameÚinterpreter_version)Úcanonicalize_name)ÚInvalidWheelFilename)ÚLink)ÚWheel)Ú TempDirectoryÚ tempdir_kinds)ÚMYPY_CHECK_RUNNING)Ú path_to_url)ÚOptionalÚSetÚListÚAnyÚDict)ÚTag)Ú FormatControlcCs&tj|dddd}t | d¡¡ ¡S)z'Return a stable sha224 of a dictionary.T)ú,ú:)Ú    sort_keysÚ
separatorsÚ ensure_asciiÚascii)ÚjsonÚdumpsÚhashlibÚsha224ÚencodeÚ    hexdigest)ÚdÚs©r!úJD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/cache.pyÚ
_hash_dictsr#csPeZdZdZ‡fdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
‡Z S)ÚCachea‚An abstract class - provides cache directories for data from links
 
 
        :param cache_dir: The root of the cache.
        :param format_control: An object of FormatControl class to limit
            binaries being read from the cache.
        :param allowed_formats: which formats of files the cache should store.
            ('binary' and 'source' are the only allowed values)
    csXtt|ƒ ¡|r"tj |¡s"t‚|p(d|_||_||_    ddh}|j     
|¡|ksTt‚dS)NÚsourceÚbinary) Úsuperr$Ú__init__ÚosÚpathÚisabsÚAssertionErrorÚ    cache_dirÚformat_controlÚallowed_formatsÚunion)Úselfr-r.r/Ú_valid_formats©Ú    __class__r!r"r(/s
zCache.__init__cCs€|jg}|jdk    r4|jdk    r4| d |j|jg¡¡d |¡}t | ¡¡ ¡}|dd…|dd…|dd…|dd…g}|S)zGet parts of part that must be os.path.joined with cache_dir
 
        Legacy cache key (pip < 20) for compatibility with older caches.
        Nú=ú#ééé)    Úurl_without_fragmentÚ    hash_nameÚhashÚappendÚjoinrrrr)r1ÚlinkÚ    key_partsÚkey_urlÚhashedÚpartsr!r!r"Ú_get_cache_path_parts_legacy:s
 
,z"Cache._get_cache_path_parts_legacycCs†d|ji}|jdk    r*|jdk    r*|j||j<|jr:|j|d<tƒ|d<tƒ|d<t|ƒ}|dd…|dd…|dd…|dd…g}|S)    zEGet parts of part that must be os.path.joined with cache_dir
        ÚurlNÚ subdirectoryrrr7r8r9)r:r;r<Úsubdirectory_fragmentrrr#)r1r?r@rBrCr!r!r"Ú_get_cache_path_partsVs
 
 
 
,zCache._get_cache_path_partsc    Cs¨|j p| p| }|rgS|j |¡}|j |¡s8gSg}| |¡}tj |¡rpt     |¡D]}| 
||f¡q\|  |¡}tj |¡r¤t     |¡D]}| 
||f¡q|S©N) r-r.Úget_allowed_formatsr/Ú intersectionÚget_path_for_linkr)r*ÚisdirÚlistdirr=Úget_path_for_link_legacy)    r1r?Úcanonical_package_nameÚ can_not_cacheÚformatsÚ
candidatesr*Ú    candidateÚ legacy_pathr!r!r"Ú_get_candidatesys,ÿýÿ 
 
 zCache._get_candidatescCs
tƒ‚dSrI©ÚNotImplementedError©r1r?r!r!r"rO•szCache.get_path_for_link_legacycCs
tƒ‚dS)z>Return a directory to store cached items in for link.
        NrWrYr!r!r"rL™szCache.get_path_for_linkcCs
tƒ‚dS)zaReturns a link to a cached item if it exists, otherwise returns the
        passed link.
        NrW)r1r?Ú package_nameÚsupported_tagsr!r!r"ÚgetŸs
z    Cache.get) Ú__name__Ú
__module__Ú __qualname__Ú__doc__r(rDrHrVrOrLr\Ú __classcell__r!r!r3r"r$$s
#r$cs8eZdZdZ‡fdd„Zdd„Zdd„Zdd    „Z‡ZS)
ÚSimpleWheelCachez+A cache of wheels for future installs.
    cstt|ƒ ||dh¡dS©Nr&)r'rbr(©r1r-r.r3r!r"r(°s
 
ÿzSimpleWheelCache.__init__cCs*| |¡}|jst‚tjj|jdf|žŽS)NÚwheels)rDr-r,r)r*r>©r1r?rCr!r!r"rO¶s
 
z)SimpleWheelCache.get_path_for_link_legacycCs*| |¡}|jst‚tjj|jdf|žŽS)a³Return a directory to store cached wheels for link
 
        Because there are M wheels for any one sdist, we provide a directory
        to cache them in, and then consult that directory when looking up
        cache hits.
 
        We only insert things into the cache if they have plausible version
        numbers, so that we don't contaminate the cache with things that were
        not unique. E.g. ./package might have dozens of installs done for it
        and build a version of 0.0...and if we built and cached a wheel, we'd
        end up using the same wheel even if the source has been edited.
 
        :param link: The link of the sdist for which this will cache wheels.
        re)rHr-r,r)r*r>rfr!r!r"rL¼s
 
z"SimpleWheelCache.get_path_for_linkc
    Cs¾g}|s |St|ƒ}| ||¡D]p\}}z t|ƒ}Wntk
rLYq YnXt|jƒ|krnt d|||¡q | |¡szq | |     |¡||f¡q |sš|St
|ƒ\}    }}t t t j ||¡ƒƒS)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)rrVrrÚnameÚloggerÚdebugÚ    supportedr=Úsupport_index_minÚminrr r)r*r>)
r1r?rZr[rSrPÚ
wheel_nameÚ    wheel_dirÚwheelÚ_r!r!r"r\Ñs@ÿ  
ý
ýÿzSimpleWheelCache.get)    r]r^r_r`r(rOrLr\rar!r!r3r"rb¬s
 rbcs eZdZdZ‡fdd„Z‡ZS)ÚEphemWheelCachezGA SimpleWheelCache that creates it's own temporary cache directory
    cs*ttjdd|_tt|ƒ |jj|¡dS)NT)ÚkindÚglobally_managed)rr    ÚEPHEM_WHEEL_CACHEÚ    _temp_dirr'rqr(r*)r1r.r3r!r"r(sþ
ÿzEphemWheelCache.__init__)r]r^r_r`r(rar!r!r3r"rqþsrqc@seZdZdd„ZdS)Ú
CacheEntrycCs||_||_dSrI)r?Ú
persistent)r1r?rwr!r!r"r(szCacheEntry.__init__N)r]r^r_r(r!r!r!r"rvsrvcsHeZdZdZ‡fdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    ‡Z
S)Ú
WheelCachezØWraps EphemWheelCache and SimpleWheelCache into a single Cache
 
    This Cache allows for gracefully degradation, using the ephem wheel cache
    when a certain link is not found in the simple wheel cache first.
    cs0tt|ƒ ||dh¡t||ƒ|_t|ƒ|_dSrc)r'rxr(rbÚ _wheel_cacherqÚ _ephem_cacherdr3r!r"r(s
ÿ zWheelCache.__init__cCs |j |¡SrI)ryrOrYr!r!r"rO'sz#WheelCache.get_path_for_link_legacycCs |j |¡SrI)ryrLrYr!r!r"rL+szWheelCache.get_path_for_linkcCs |j |¡SrI)rzrLrYr!r!r"Úget_ephem_path_for_link/sz"WheelCache.get_ephem_path_for_linkcCs | |||¡}|dkr|S|jSrI)Úget_cache_entryr?)r1r?rZr[Ú cache_entryr!r!r"r\3szWheelCache.getcCsP|jj|||d}||k    r&t|ddS|jj|||d}||k    rLt|ddSdS)z¶Returns a CacheEntry with a link to a cached item if it exists or
        None. The cache entry indicates if the item was found in the persistent
        or ephemeral cache.
        )r?rZr[T)rwFN)ryr\rvrz)r1r?rZr[Úretvalr!r!r"r|?s ý ý zWheelCache.get_cache_entry) r]r^r_r`r(rOrLr{r\r|rar!r!r3r"rxs  rx)*r`rrÚloggingr)Úpip._vendor.packaging.tagsrrZpip._vendor.packaging.utilsrÚpip._internal.exceptionsrÚpip._internal.models.linkrÚpip._internal.models.wheelrÚpip._internal.utils.temp_dirrr    Úpip._internal.utils.typingr
Úpip._internal.utils.urlsr Útypingr r rrrrÚ#pip._internal.models.format_controlrÚ    getLoggerr]rhr#Úobjectr$rbrqrvrxr!r!r!r"Ú<module>s0        
    R