(RndZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZdd lmZejeZ dZ!ddZ"GddZ#Gdde#Z$Gdde$Z%GddZ&Gdde#Z'dS)zCache Management) annotationsN)Path)Any)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename) DirectUrl)Link)Wheel) TempDirectory tempdir_kinds) path_to_urlz origin.jsonddict[str, str]returnstrctj|ddd}tj|dS)z'Return a stable sha224 of a dictionary.T),:) sort_keys separators ensure_asciiascii)jsondumpshashlibsha224encode hexdigest)rss s/builddir/build/BUILD/imunify360-venv-2.6.1/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/cache.py _hash_dictr$sB 1$OOOA >!((7++ , , 6 6 8 88cDeZdZdZdfd Zdd Zdd ZddZddZxZ S)CachezuAn abstract class - provides cache directories for data from links :param cache_dir: The root of the cache. cache_dirrrNonect|r!tj|sJ|pd|_dSN)super__init__ospathisabsr(selfr( __class__s r#r-zCache.__init__'sH 8 i 8 8888"*dr%linkr list[str]c"d|ji}|j|j|j||j<|jr |j|d<t |d<t |d<t |}|dd|dd|dd|ddg}|S) z %$)*?(, Idn %  % C(,(BIn %)9(:(: $%+>+@+@ '( I&& VAaC[&1+vabbzB r%canonical_package_name list[Any]c|j p| p| }|rgS||tjr fdtjDSgS)Ncg|]}|fSrH).0 candidater/s r# z)Cache._get_candidates..TsHHH)Y%HHHr%)r(get_path_for_linkr.r/isdirlistdir)r2r4rD can_not_cacher/s @r#_get_candidateszCache._get_candidatesMs~ N*T2H.HTPTH  I%%d++ 7==   IHHHHrz$7G7GHHH H r%ct)z5Return a directory to store cached items in for link.NotImplementedErrorr2r4s r#rLzCache.get_path_for_linkWs!###r% package_name str | Nonesupported_tags list[Tag]ct)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rR)r2r4rUrWs r#getz Cache.get[s"###r%r(rrr))r4r rr5)r4r rDrrrEr4r rrr4r rUrVrWrXrr ) __name__ __module__ __qualname____doc__r-rCrPrLrZ __classcell__r3s@r#r'r'!s ++++++ B$$$$ $ $ $ $ $ $ $ $r%r'c4eZdZdZdfd Zdd ZddZxZS)SimpleWheelCachez&A cache of wheels for future installs.r(rrr)cJt|dSr+)r,r-r1s r#r-zSimpleWheelCache.__init__js! #####r%r4r cx||}|jsJtjj|jdg|RS)aReturn 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. wheels)rCr(r.r/join)r2r4rBs r#rLz"SimpleWheelCache.get_path_for_linkmsB**400~~w|DNH=u====r%rUrVrWrXcg}|s|St|}|||D]\}} t|}n#t$rY"wxYw|j|krt d|||O||se|| |||f|s|St|\} }}tttj||S)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r rPr r nameloggerdebug supportedappendsupport_index_minminr rr.r/ri) r2r4rUrW candidatesrD wheel_name wheel_dirwheel_s r#rZzSimpleWheelCache.getsL   K!222    ++N;;     K#&z?? :yK Y C CDDEEEsA AAr[r\r])r^r_r`rar-rLrZrbrcs@r#reregss00$$$$$$>>>>()F)F)F)F)F)F)F)Fr%rec$eZdZdZdfd ZxZS)EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryrr)cttjd|_t |jjdS)NT)kindglobally_managed)rrEPHEM_WHEEL_CACHE _temp_dirr,r-r/)r2r3s r#r-zEphemWheelCache.__init__sG&0!    ,-----r%)rr))r^r_r`rar-rbrcs@r#rxrxsCLL..........r%rxceZdZddZdS) CacheEntryr4r persistentboolcx||_||_d|_t|jjjt z }|rj tj | d|_dS#t$r-}t d||j|Yd}~dSd}~wwxYwdS)Nutf-8encodingz7Ignoring invalid cache entry origin file %s for %s (%s))r4roriginr file_pathparentORIGIN_JSON_NAMEexistsr from_json read_text Exceptionrlwarningfilename)r2r4rorigin_direct_url_pathes r#r-zCacheEntry.__init__s  $(, !%di&9!:!:!ADT!T ! ( ( * *  '1*44g4FF    M*M    s-B B7 "B22B7N)r4r rr)r^r_r`r-rHr%r#rrs(r%rc\eZdZdZdfd Zdd Zdd ZddZddZe ddZ xZ S) WheelCachezWraps 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. r(rrr)ct|t||_t |_dSr+)r,r-re _wheel_cacherx _ephem_cacher1s r#r-zWheelCache.__init__s? ###,Y77+--r%r4r c6|j|Sr+)rrLrTs r#rLzWheelCache.get_path_for_link 224888r%c6|j|Sr+)rrLrTs r#get_ephem_path_for_linkz"WheelCache.get_ephem_path_for_linkrr%rUrVrWrXcF||||}||S|jSr+)get_cache_entryr4)r2r4rUrW cache_entrys r#rZzWheelCache.gets/ **4~NN  Kr%CacheEntry | Nonec|j|||}||urt|dS|j|||}||urt|dSdS)zReturns 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. )r4rUrWT)rFN)rrZrr)r2r4rUrWretvals r#rzWheelCache.get_cache_entrys"&&%)'     f666 6"&&%)'     f777 7tr% download_infor ct|tz }|r tj|d}|j|jkr'td|j||jn3#t$r&}td||Yd}~nd}~wwxYw| | ddS)NrrzOrigin URL %s in cache entry %s does not match download URL %s. This is likely a pip bug or a cache corruption issue. Will overwrite it with the new value.zPCould not read origin file %s in cache entry (%s). Will attempt to overwrite it.) rrrr rrr7rlrr write_textto_json)r(r origin_pathrrs r#record_download_originz!WheelCache.record_download_origin s9oo(88       ",[-B-BG-B-T-TUU:!222NN@ !%)    4  & }4466IIIIIs(B B=B88B=r[r\r])r4r rUrVrWrXrr)r(rrr rr)) r^r_r`rar-rLrrZr staticmethodrrbrcs@r#rrs ...... 99999999     8JJJ\JJJJJr%r)rrrr)(ra __future__rrrloggingr.pathlibrtypingrpip._vendor.packaging.tagsrrrpip._vendor.packaging.utilsr pip._internal.exceptionsr pip._internal.models.direct_urlr pip._internal.models.linkr pip._internal.models.wheelr pip._internal.utils.temp_dirrrpip._internal.utils.urlsr getLoggerr^rlrr$r'rerxrrrHr%r#rs:""""""  QQQQQQQQQQ999999999999555555******,,,,,,EEEEEEEE000000  8 $ $ 9999 C$C$C$C$C$C$C$C$LCFCFCFCFCFuCFCFCFL . . . . .& . . .0RJRJRJRJRJRJRJRJRJRJr%