"Jd$zdZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z mZddlmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZejeZ d ee!e!fd e!fdZ"GddZ#Gdde#Z$Gdde$Z%GddZ&Gdde#Z'dS)zCache Management N)AnyDictListOptionalSet)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename) FormatControl)Link)Wheel) TempDirectory tempdir_kinds) path_to_urldreturnctj|ddd}tj|dS)z'Return a stable sha224 of a dictionary.T),:) sort_keys separators ensure_asciiascii)jsondumpshashlibsha224encode hexdigest)rss F/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/cache.py _hash_dictr$sB 1$OOOA >!((7++ , , 6 6 8 88ceZdZdZdededeeddffd Zdede efd Z ded ede e fd Z dedefd Z ded eede edefdZxZS)CacheanAn 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) cache_dirformat_controlallowed_formatsrNc~t|pd|_||_||_ddh}dS)Nsourcebinary)super__init__r(r)r*)selfr(r)r*_valid_formats __class__s r#r/zCache.__init__(sE "*d,."H-r%linkc"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_namec^|j p| p| }|rgS|j|}|j|sgSg}||}t j|r.t j |D]}| ||f|SN) r(r)get_allowed_formatsr* intersectionget_path_for_linkospathisdirlistdirappend)r0r3rB can_not_cacheformats candidatesrI candidates r#_get_candidateszCache._get_candidatesUs N*T2H.HTPTH  I%99:PQQ#0099 I %%d++ 7==   5Z-- 5 5 !!9d"34444r%ct)z5Return a directory to store cached items in for link.NotImplementedErrorr0r3s r#rGzCache.get_path_for_linkes!###r% package_namesupported_tagsct)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rS)r0r3rVrWs r#getz Cache.getis"###r%)__name__ __module__ __qualname____doc__strr rr/rrrArrQrGrrrY __classcell__r2s@r#r'r's. L L.; LNQRUh L  L L L L L L$49BD#$s) $d$s$$$$ $ $sm $S $  $ $ $ $ $ $ $ $r%r'cpeZdZdZdededdffd ZdedefdZded e ed e e defd Z xZ S) SimpleWheelCachez&A cache of wheels for future installs.r(r)rNcPt||dhdSNr-)r.r/r0r(r)r2s r#r/zSimpleWheelCache.__init__xs' NXJ?????r%r3cf||}tjj|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)rArHrIjoinr()r0r3r@s r#rGz"SimpleWheelCache.get_path_for_link{s7**400w|DNH=u====r%rVrWc6g}|s|St|}|||D]\}} t|}n#t$rY"wxYwt|j|krt d|||\||sr|| |||f|s|St|\} }}tttj||S)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r rQrr nameloggerdebug supportedrLsupport_index_minminrrrHrIrh) r0r3rVrWrOrB wheel_name wheel_dirwheel_s r#rYzSimpleWheelCache.getsT   K!222    ++N;;     K#&z?? :yK Y C CDDEEEsA AA)rZr[r\r]r^r r/rrGrrrrYr_r`s@r#rbrbus00@#@}@@@@@@@>d>s>>>>()F)Fsm)FS )F  )F)F)F)F)F)F)F)Fr%rbc,eZdZdZdeddffd ZxZS)EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryr)rNcttjd|_t |jj|dS)NT)kindglobally_managed)rrEPHEM_WHEEL_CACHE _temp_dirr.r/rI)r0r)r2s r#r/zEphemWheelCache.__init__sI&0!    ,n=====r%)rZr[r\r]r r/r_r`s@r#rurusQLL>}>>>>>>>>>>>r%ruceZdZdedefdZdS) CacheEntryr3 persistentc"||_||_dSrD)r3r})r0r3r}s r#r/zCacheEntry.__init__s  $r%N)rZr[r\rboolr/r%r#r|r|s:%%%%%%%%r%r|c eZdZdZdededdffd ZdedefdZdedefd Z ded e ed e e defd Z ded e ed e e de efd ZxZS) 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(r)rNct||dht|||_t ||_dSrd)r.r/rb _wheel_cacheru _ephem_cacheres r#r/zWheelCache.__init__sI NXJ???,YGG+N;;r%r3c6|j|SrD)rrGrUs r#rGzWheelCache.get_path_for_link 224888r%c6|j|SrD)rrGrUs r#get_ephem_path_for_linkz"WheelCache.get_ephem_path_for_linkrr%rVrWcF||||}||S|jSrD)get_cache_entryr3)r0r3rVrW cache_entrys r#rYzWheelCache.gets/ **4~NN  Kr%c|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. )r3rVrWT)r}FN)rrYr|r)r0r3rVrWretvals r#rzWheelCache.get_cache_entrys"&&%)'     f666 6"&&%)'     f777 7tr%)rZr[r\r]r^r r/rrGrrrrrYr|rr_r`s@r#rrs) <#<}<<<<<<< 9d9s99999D9S9999    sm  S       smS  *  r%r)(r]rrloggingrHtypingrrrrrpip._vendor.packaging.tagsrr r pip._vendor.packaging.utilsr pip._internal.exceptionsr #pip._internal.models.format_controlr pip._internal.models.linkrpip._internal.models.wheelrpip._internal.utils.temp_dirrrpip._internal.utils.urlsr getLoggerrZrkr^r$r'rbrur|rrr%r#rs0  11111111111111QQQQQQQQQQ999999999999======******,,,,,,EEEEEEEE000000  8 $ $9$sCx.9S9999 U$U$U$U$U$U$U$U$pCFCFCFCFCFuCFCFCFL > > > > >& > > >%%%%%%%%7777777777r%