a Ra$@sdZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z mZddlmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZeeZ ee!e!fe!d d dZ"GdddZ#Gddde#Z$Gddde$Z%GdddZ&Gddde#Z'dS)zCache Management N)AnyDictListOptionalSet)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename) FormatControl)Link)Wheel) TempDirectory tempdir_kinds) path_to_url)dreturncCs&tj|dddd}t|dS)z'Return a stable sha224 of a dictionary.T),:)Z sort_keysZ separatorsZ ensure_asciiascii)jsondumpshashlibZsha224encodeZ hexdigest)rsrD/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/cache.py _hash_dictsrcseZdZdZeeeeddfdd Zee edddZ eee e d d d Z eedd d Z eeee eedddZZS)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) N) cache_dirformat_controlallowed_formatsrcsTt|rtj|sJ|p$d|_||_||_ddh}|j||ksPJdS)Nsourcebinary) super__init__ospathisabsr r!r"union)selfr r!r"Z_valid_formats __class__rrr&(s  zCache.__init__linkrcCsd|ji}|jdur*|jdur*|j||j<|jr:|j|d<t|d<t|d<t|}|dd|dd|dd|ddg}|S) zr7Z wheel_nameZ wheel_dirZwheel_rrrrGs:    zSimpleWheelCache.get)rHrIrJrKrLr r&r r:rrrrGrMrrr,rrNusrNcs(eZdZdZeddfdd ZZS)EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryN)r!rcs&ttjdd|_t|jj|dS)NT)kindZglobally_managed)rrZEPHEM_WHEEL_CACHEZ _temp_dirr%r&r()r+r!r,rrr&s zEphemWheelCache.__init__)rHrIrJrKr r&rMrrr,rrXsrXc@seZdZeedddZdS) CacheEntryr/ persistentcCs||_||_dSr8r[)r+r/r\rrrr&szCacheEntry.__init__N)rHrIrJr boolr&rrrrrZsrZcseZdZdZeeddfdd ZeedddZeedd d Z ee ee e ed d d Z ee ee e e ed ddZZS) 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. NrOcs,t||dht|||_t||_dSrP)r%r&rN _wheel_cacherX _ephem_cacherQr,rrr&s zWheelCache.__init__r.cCs |j|Sr8)r_r:rCrrrr:szWheelCache.get_path_for_linkcCs |j|Sr8)r`r:rCrrrget_ephem_path_for_linksz"WheelCache.get_ephem_path_for_linkrDcCs ||||}|dur|S|jSr8)get_cache_entryr/)r+r/rErFZ cache_entryrrrrGszWheelCache.getcCsP|jj|||d}||ur&t|ddS|jj|||d}||urLt|ddSdS)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. )r/rErFT)r\FN)r_rGrZr`)r+r/rErFZretvalrrrrbs   zWheelCache.get_cache_entry)rHrIrJrKrLr r&r r:rarrrrGrZrbrMrrr,rr^s r^)(rKrrZloggingr'typingrrrrrZpip._vendor.packaging.tagsrrr Zpip._vendor.packaging.utilsr Zpip._internal.exceptionsr Z#pip._internal.models.format_controlr Zpip._internal.models.linkr Zpip._internal.models.wheelrZpip._internal.utils.temp_dirrrZpip._internal.utils.urlsrZ getLoggerrHrTrLrrrNrXrZr^rrrrs(       XF