Re$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 /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/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_formatsrNct|r!tj|sJ|pd|_||_||_ddh}|j||ksJdS)Nsourcebinary) super__init__ospathisabsr(r)r*union)selfr(r)r*_valid_formats __class__s r#r/zCache.__init__(s 8 i 8 8888"*d,."H-#)).99^KKKKKKr%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_linkr0r1isdirlistdirappend)r4r7rF can_not_cacheformats candidatesr1 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.NotImplementedErrorr4r7s r#rKzCache.get_path_for_linkes!###r% package_namesupported_tagsct)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rU)r4r7rXrYs r#getz Cache.getis"###r%)__name__ __module__ __qualname____doc__strr rr/rrrErrSrKrrr[ __classcell__r6s@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/r4r(r)r6s r#r/zSimpleWheelCache.__init__xs' NXJ?????r%r7cx||}|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)rEr(r0r1join)r4r7rDs r#rKz"SimpleWheelCache.get_path_for_link{sC**400~w|DNH=u====r%rXrYc6g}|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 rSrr nameloggerdebug supportedrNsupport_index_minminrrr0r1rj) r4r7rXrYrQrF wheel_name wheel_dirwheel_s r#r[zSimpleWheelCache.getsT   K!222    ++N;;     K#&z?? :yK Y C CDDEEEsA AA)r\r]r^r_r`r r/rrKrrrr[rarbs@r#rdrdus00@#@}@@@@@@@>d>s>>>>()F)Fsm)FS )F  )F)F)F)F)F)F)F)Fr%rdc,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/r1)r4r)r6s r#r/zEphemWheelCache.__init__sI&0!    ,n=====r%)r\r]r^r_r r/rarbs@r#rwrwsQLL>}>>>>>>>>>>>r%rwceZdZdedefdZdS) CacheEntryr7 persistentc"||_||_dSrH)r7r)r4r7rs r#r/zCacheEntry.__init__s  $r%N)r\r]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 ||_dSrf)r.r/rd _wheel_cacherw _ephem_cachergs r#r/zWheelCache.__init__sI NXJ???,YGG+N;;r%r7c6|j|SrH)rrKrWs r#rKzWheelCache.get_path_for_link 224888r%c6|j|SrH)rrKrWs r#get_ephem_path_for_linkz"WheelCache.get_ephem_path_for_linkrr%rXrYcF||||}||S|jSrH)get_cache_entryr7)r4r7rXrY cache_entrys r#r[zWheelCache.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. )r7rXrYT)rFN)rr[r~r)r4r7rXrYretvals r#rzWheelCache.get_cache_entrys"&&%)'     f666 6"&&%)'     f777 7tr%)r\r]r^r_r`r r/rrKrrrrr[r~rrarbs@r#rrs) <#<}<<<<<<< 9d9s99999D9S9999    sm  S       smS  *  r%r)(r_rrloggingr0typingrrrrrpip._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 getLoggerr\rmr`r$r'rdrwr~rrr%r#rs0  11111111111111QQQQQQQQQQ999999999999======******,,,,,,EEEEEEEE000000  8 $ $9$sCx.9S9999 U$U$U$U$U$U$U$U$pCFCFCFCFCFuCFCFCFL > > > > >& > > >%%%%%%%%7777777777r%