7i(ddZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z ddl m Z mZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZej>e Z!d Z"de e#e#fde#fdZ$GddZ%Gdde%Z&Gdde&Z'GddZ(Gdde%Z)y)zCache Management N)Path)AnyDictListOptional)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename) DirectUrl)Link)Wheel) TempDirectory tempdir_kinds) path_to_urlz origin.jsondreturnctj|ddd}tj|j dj S)z'Return a stable sha224 of a dictionary.T),:) sort_keys separators ensure_asciiascii)jsondumpshashlibsha224encode hexdigest)rss \/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pip/_internal/cache.py _hash_dictr$s7 1$OA >>!((7+ , 6 6 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_dirrNc~t||r!tjj |sJ|xsd|_yN)super__init__ospathisabsr(selfr( __class__s r#r,zCache.__init__&s2  i 888"*dr%linkc(d|ji}|j%|j|j||j<|jr|j|d<t |d<t |d<t |}|dd|dd|dd|ddg}|S) z> %$))*?(, Idnn %  % %(,(B(BIn %)9(: $%+>+@ '( I& VAa[&1+vabzB r%canonical_package_namec|j xs| xs| }|rgS|j|}tjj |r%tj |Dcgc]}||fc}SgScc}wr*)r(get_path_for_linkr-r.isdirlistdir)r1r3rB can_not_cacher. candidates r#_get_candidateszCache._get_candidatesLsq NN*T2H.HTPTH I%%d+ 77== 79zz$7GH)Y%H H Is# A3ct)z5Return a directory to store cached items in for link.NotImplementedErrorr1r3s r#rDzCache.get_path_for_linkVs !##r% package_namesupported_tagsct)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rK)r1r3rNrOs r#getz Cache.getZs "##r%)__name__ __module__ __qualname____doc__strr,rrrArrIrDrrrQ __classcell__r2s@r#r'r' s +#+$+ $49BD#$s)$d$s$ $ $sm $S $  $r%r'c`eZdZdZdeddffd ZdedefdZdedeed e e defd Z xZ S) SimpleWheelCachez&A cache of wheels for future installs.r(rNc$t||yr*)r+r,r0s r#r,zSimpleWheelCache.__init__is #r%r3c|j|}|jsJtjj|jdg|S)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#rDz"SimpleWheelCache.get_path_for_linkls>**40~~~ww||DNNH=u==r%rNrOcg}|s|St|}|j||D]w\}} t|}t|j|k7rt j d|||C|j|sU|j|j|||fy|s|St|\} }}tttjj||S#t$rYwxYw)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r rIrr nameloggerdebug supportedappendsupport_index_minminrrr-r.r^) r1r3rNrO candidatesrB wheel_name wheel_dirwheel_s r#rQzSimpleWheelCache.gets  K!22   ++N; # 2K#&z? :yK Y CDEE5(  s C## C/.C/) rRrSrTrUrVr,rrDrrrrQrWrXs@r#rZrZfsd0$#$$$>d>s>()F)Fsm)FS )F  )Fr%rZc$eZdZdZdfd ZxZS)EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directorycttjd|_t||jj y)NT)kindglobally_managed)rrEPHEM_WHEEL_CACHE _temp_dirr+r,r.)r1r2s r#r,zEphemWheelCache.__init__s4&00!  ,,-r%)rN)rRrSrTrUr,rWrXs@r#rmrmsL..r%rmceZdZdedefdZy) CacheEntryr3 persistentcv||_||_d|_t|jjj t z }|jr, tj|jd|_yy#t$r,}tjd||j|Yd}~yd}~wwxYw)Nutf-8encodingz7Ignoring invalid cache entry origin file %s for %s (%s))r3ruoriginr file_pathparentORIGIN_JSON_NAMEexistsr from_json read_text Exceptionrawarningfilename)r1r3ruorigin_direct_url_pathes r#r,zCacheEntry.__init__s  $+/ !%dii&9&9!:!A!ADT!T ! ( ( * '11*44g4F  +  M*MM  s*B B8 "B33B8N)rRrSrTrboolr,r%r#rtrtsr%rtc 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(rNcbt||t||_t |_yr*)r+r,rZ _wheel_cacherm _ephem_cacher0s r#r,zWheelCache.__init__s( #,Y7+-r%r3c8|jj|Sr*)rrDrMs r#rDzWheelCache.get_path_for_link  22488r%c8|jj|Sr*)rrDrMs r#get_ephem_path_for_linkz"WheelCache.get_ephem_path_for_linkrr%rNrOcH|j|||}||S|jSr*)get_cache_entryr3)r1r3rNrO cache_entrys r#rQzWheelCache.gets/ **4~N  Kr%c|jj|||}||ur t|dS|jj|||}||ur t|dSy)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. )r3rNrOT)ruFN)rrQrtr)r1r3rNrOretvals r#rzWheelCache.get_cache_entrys}""&&%)'   f6 6""&&%)'   f7 7r% download_infoct|tz }|jrl tj|j d}|j |j k7r-tjd|j ||j  |j|jdy#t$r!}tjd||Yd}~Gd}~wwxYw)NrwrxzOrigin 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.) rr}r~r rrr5rarr write_textto_json)r(r origin_pathrzrs r#record_download_originz!WheelCache.record_download_origin s9o(88     ",,[-B-BG-B-TU::!2!22NN@ !%))  }446I' 4  s%B11 C:CC)rRrSrTrUrVr,rrDrrrrrQrtr staticmethodr rrWrXs@r#rrs .#.$. 9d9s99D9S9    sm  S    smS  *  8J#JiJDJJr%r)*rUrrloggingr-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 getLoggerrRrar}rVr$r'rZrmrtrrr%r#rs  ,,QQ995*,E0   8 $ 9$sCx.9S9 C$C$LCFuCFL .& .0RJRJr%