7f(dZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z ddl m Z mZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZeje Z!d Z"de e#e#fde#fdZ$GddZ%Gdde%Z&Gdde&Z'GddZ(Gdde%Z)dS)zCache Management N)Path)AnyDictListOptional)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename) DirectUrl)Link)Wheel) TempDirectory tempdir_kinds) path_to_urlz origin.jsondreturnctj|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.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/cache.py _hash_dictr$sB 1$OOOA >!((7++ , , 6 6 8 88ceZdZdZdeddffd ZdedeefdZdededee fd Z dedefd Z ded e ed ee defd ZxZS)CachezuAn abstract class - provides cache directories for data from links :param cache_dir: The root of the cache. cache_dirrNct|r!tj|sJ|pd|_dSN)super__init__ospathisabsr(selfr( __class__s r#r,zCache.__init__&sH 8 i 8 8888"*dr%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||tjr fdtjDSgS)Ncg|]}|fSrE).0 candidater.s r# z)Cache._get_candidates..SsHHH)Y%HHHr%)r(get_path_for_linkr-r.isdirlistdir)r1r3rB can_not_cacher.s @r#_get_candidateszCache._get_candidatesLs~ N*T2H.HTPTH  I%%d++ 7==   IHHHHrz$7G7GHHH H r%ct)z5Return a directory to store cached items in for link.NotImplementedErrorr1r3s r#rIzCache.get_path_for_linkVs!###r% package_namesupported_tagsct)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rO)r1r3rRrSs r#getz Cache.getZs"###r%)__name__ __module__ __qualname____doc__strr,rrrArrMrIrrrU __classcell__r2s@r#r'r' s  +#+$++++++ $49BD#$s)$d$s$$$$ $ $sm $S $  $ $ $ $ $ $ $ $r%r'cleZdZdZdeddffd ZdedefdZdedeed e e defd Z xZ S) SimpleWheelCachez&A cache of wheels for future installs.r(rNcJt|dSr*)r+r,r0s r#r,zSimpleWheelCache.__init__is! #####r%r3cx||}|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)rAr(r-r.join)r1r3r@s r#rIz"SimpleWheelCache.get_path_for_linklsB**400~~w|DNH=u====r%rRrSc6g}|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 rMrr nameloggerdebug supportedappendsupport_index_minminrrr-r.rb) r1r3rRrS candidatesrB wheel_name wheel_dirwheel_s r#rUzSimpleWheelCache.getsT   K!222    ++N;;     K#&z?? :yK Y C CDDEEEsA AA) rVrWrXrYrZr,rrIrrrrUr[r\s@r#r^r^fs00$#$$$$$$$$>d>s>>>>()F)Fsm)FS )F  )F)F)F)F)F)F)F)Fr%r^c$eZdZdZdfd ZxZS)EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryrNcttjd|_t |jjdS)NT)kindglobally_managed)rrEPHEM_WHEEL_CACHE _temp_dirr+r,r.)r1r2s r#r,zEphemWheelCache.__init__sG&0!    ,-----r%)rN)rVrWrXrYr,r[r\s@r#rqrqsCLL..........r%rqceZdZdedefdZdS) CacheEntryr3 persistentcx||_||_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))r3ryoriginr file_pathparentORIGIN_JSON_NAMEexistsr from_json read_text Exceptionrewarningfilename)r1r3ryorigin_direct_url_pathes r#r,zCacheEntry.__init__s  $+/ !%di&9!:!:!ADT!T ! ( ( * *  '1*44g4FF    M*M    s-B B7 "B22B7N)rVrWrXrboolr,rEr%r#rxrxs:r%rxc eZdZdZdeddffd ZdedefdZdedefdZded e ed e e defd Z ded e ed e e de e fd Zeded eddfdZxZS) 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(rNct|t||_t |_dSr*)r+r,r^ _wheel_cacherq _ephem_cacher0s r#r,zWheelCache.__init__s? ###,Y77+--r%r3c6|j|Sr*)rrIrQs r#rIzWheelCache.get_path_for_link 224888r%c6|j|Sr*)rrIrQs r#get_ephem_path_for_linkz"WheelCache.get_ephem_path_for_linkrr%rRrScF||||}||S|jSr*)get_cache_entryr3)r1r3rRrS cache_entrys r#rUzWheelCache.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. )r3rRrST)ryFN)rrUrxr)r1r3rRrSretvals r#rzWheelCache.get_cache_entrys"&&%)'     f666 6"&&%)'     f777 7tr% download_infoct|tz }|r tj|d}|j|jkr'td|j||jn3#t$r&}td||Yd}~nd}~wwxYw| | ddS)Nr{r|zOrigin 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 rrr5rerr write_textto_json)r(r origin_pathr~rs r#record_download_originz!WheelCache.record_download_origin s9oo(88       ",[-B-BG-B-T-TUU:!222NN@ !%)    4  & }4466IIIIIs(B B=B88B=)rVrWrXrYrZr,rrIrrrrrUrxr staticmethodr rr[r\s@r#rrsb .#.$...... 9d9s99999D9S9999    sm  S       smS  *  8J#JiJDJJJ\JJJJJr%r)*rYrrloggingr-pathlibrtypingrrrrpip._vendor.packaging.tagsrr r pip._vendor.packaging.utilsr pip._internal.exceptionsr pip._internal.models.direct_urlr pip._internal.models.linkrpip._internal.models.wheelrpip._internal.utils.temp_dirrrpip._internal.utils.urlsr getLoggerrVrerrZr$r'r^rqrxrrEr%r#rsV  ,,,,,,,,,,,,QQQQQQQQQQ999999999999555555******,,,,,,EEEEEEEE000000  8 $ $ 9$sCx.9S9999 C$C$C$C$C$C$C$C$LCFCFCFCFCFuCFCFCFL . . . . .& . . .0RJRJRJRJRJRJRJRJRJRJr%