3 ”ReÙ/ã@s*dZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZmZdd lmZdd lmZerÄdd lmZmZmZmZmZdd lmZdd lmZej e!ƒZ"dd„Z#Gdd„de$ƒZ%Gdd„de%ƒZ&Gdd„de&ƒZ'Gdd„de$ƒZ(Gdd„de%ƒZ)dS)zCache Management éN)Úinterpreter_nameÚinterpreter_version)Úcanonicalize_name)ÚInvalidWheelFilename)ÚLink)ÚWheel)Ú TempDirectoryÚ tempdir_kinds)ÚMYPY_CHECK_RUNNING)Ú path_to_url)ÚOptionalÚSetÚListÚAnyÚDict)ÚTag)Ú FormatControlcCs&tj|dddd�}tj|jdƒƒjƒS)z'Return a stable sha224 of a dictionary.Tú,ú:)Ú sort_keysÚ separatorsÚ ensure_asciiÚascii)rr)ÚjsonÚdumpsÚhashlibÚsha224ÚencodeÚ hexdigest)ÚdÚs©r!ú‚/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/cache.pyÚ _hash_dictsr#csPeZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z ‡Z S)ÚCachea‚An 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) csZtt|ƒjƒ| s$tjj|ƒs$t‚|p*d|_||_||_ ddh}|j j |ƒ|ksVt‚dS)NÚsourceÚbinary) Úsuperr$Ú__init__ÚosÚpathÚisabsÚAssertionErrorÚ cache_dirÚformat_controlÚallowed_formatsÚunion)Úselfr-r.r/Ú_valid_formats)Ú __class__r!r"r(/s zCache.__init__cCs€|jg}|jdk r4|jdk r4|jdj|j|jgƒƒdj|ƒ}tj|jƒƒjƒ}|dd…|dd…|dd…|dd…g}|S)z�Get parts of part that must be os.path.joined with cache_dir Legacy cache key (pip < 20) for compatibility with older caches. Nú=ú#ééé) Úurl_without_fragmentÚ hash_nameÚhashÚappendÚjoinrrrr)r1ÚlinkÚ key_partsÚkey_urlÚhashedÚpartsr!r!r"Ú_get_cache_path_parts_legacy:s  ,z"Cache._get_cache_path_parts_legacycCs†d|ji}|jdk r*|jdk r*|j||j<|jr:|j|d<tƒ|d<tƒ|d<t|ƒ}|dd…|dd…|dd…|dd…g}|S) zEGet parts of part that must be os.path.joined with cache_dir ÚurlNÚ subdirectoryrrr6r7r8)r9r:r;Úsubdirectory_fragmentrrr#)r1r>r?rArBr!r!r"Ú_get_cache_path_partsVs     ,zCache._get_cache_path_partsc Cs°|j p| p| }|rgS|jj|ƒ}|jj|ƒs8gSg}|j|ƒ}tjj|ƒrtx tj |ƒD]}|j ||fƒq^W|j |ƒ}tjj|ƒr¬x tj |ƒD]}|j ||fƒq–W|S)N) r-r.Úget_allowed_formatsr/Ú intersectionÚget_path_for_linkr)r*ÚisdirÚlistdirr<Úget_path_for_link_legacy) r1r>Úcanonical_package_nameÚ can_not_cacheÚformatsÚ candidatesr*Ú candidateÚ legacy_pathr!r!r"Ú_get_candidatesys&     zCache._get_candidatescCs tƒ‚dS)N)ÚNotImplementedError)r1r>r!r!r"rM•szCache.get_path_for_link_legacycCs tƒ‚dS)z>Return a directory to store cached items in for link. N)rU)r1r>r!r!r"rJ™szCache.get_path_for_linkcCs tƒ‚dS)zaReturns a link to a cached item if it exists, otherwise returns the passed link. N)rU)r1r>Ú package_nameÚsupported_tagsr!r!r"ÚgetŸs z Cache.get) Ú__name__Ú __module__Ú __qualname__Ú__doc__r(rCrGrTrMrJrXÚ __classcell__r!r!)r3r"r$$s  #r$cs8eZdZdZ‡fdd„Zdd„Zdd„Zdd „Z‡ZS) ÚSimpleWheelCachez+A cache of wheels for future installs. cstt|ƒj||dhƒdS)Nr&)r'r^r()r1r-r.)r3r!r"r(°s zSimpleWheelCache.__init__cCs*|j|ƒ}|jst‚tjj|jdf|žŽS)NÚwheels)rCr-r,r)r*r=)r1r>rBr!r!r"rM¶s  z)SimpleWheelCache.get_path_for_link_legacycCs*|j|ƒ}|jst‚tjj|jdf|žŽS)a³Return 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. r_)rGr-r,r)r*r=)r1r>rBr!r!r"rJ¼s  z"SimpleWheelCache.get_path_for_linkc CsÀg}|s |St|ƒ}x~|j||ƒD]n\}}y t|ƒ}Wntk rLw"YnXt|jƒ|krntjd|||ƒq"|j|ƒszq"|j|j |ƒ||fƒq"W|sœ|St |ƒ\} }}t t t jj||ƒƒƒS)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)rrTrrÚnameÚloggerÚdebugÚ supportedr<Úsupport_index_minÚminrr r)r*r=) r1r>rVrWrQrNÚ wheel_nameÚ wheel_dirÚwheelÚ_r!r!r"rXÑs2    zSimpleWheelCache.get) rYrZr[r\r(rMrJrXr]r!r!)r3r"r^¬s  r^cs eZdZdZ‡fdd„Z‡ZS)ÚEphemWheelCachezGA SimpleWheelCache that creates it's own temporary cache directory cs*ttjdd�|_tt|ƒj|jj|ƒdS)NT)ÚkindÚglobally_managed)rr ÚEPHEM_WHEEL_CACHEÚ _temp_dirr'rjr(r*)r1r.)r3r!r"r(s   zEphemWheelCache.__init__)rYrZr[r\r(r]r!r!)r3r"rjþsrjc@seZdZdd„ZdS)Ú CacheEntrycCs||_||_dS)N)r>Ú persistent)r1r>rpr!r!r"r(szCacheEntry.__init__N)rYrZr[r(r!r!r!r"rosrocsHeZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z ‡Z S)Ú WheelCachezØWraps 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. cs0tt|ƒj||dhƒt||ƒ|_t|ƒ|_dS)Nr&)r'rqr(r^Ú _wheel_cacherjÚ _ephem_cache)r1r-r.)r3r!r"r(s   zWheelCache.__init__cCs |jj|ƒS)N)rrrM)r1r>r!r!r"rM'sz#WheelCache.get_path_for_link_legacycCs |jj|ƒS)N)rrrJ)r1r>r!r!r"rJ+szWheelCache.get_path_for_linkcCs |jj|ƒS)N)rsrJ)r1r>r!r!r"Úget_ephem_path_for_link/sz"WheelCache.get_ephem_path_for_linkcCs |j|||ƒ}|dkr|S|jS)N)Úget_cache_entryr>)r1r>rVrWÚ cache_entryr!r!r"rX3szWheelCache.getcCsP|jj|||d�}||k r&t|dd�S|jj|||d�}||k rLt|dd�SdS)z¶Returns 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>rVrWT)rpFN)rrrXrors)r1r>rVrWÚretvalr!r!r"ru?s   zWheelCache.get_cache_entry) rYrZr[r\r(rMrJrtrXrur]r!r!)r3r"rqs  rq)*r\rrÚloggingr)Úpip._vendor.packaging.tagsrrZpip._vendor.packaging.utilsrÚpip._internal.exceptionsrÚpip._internal.models.linkrÚpip._internal.models.wheelrÚpip._internal.utils.temp_dirrr Úpip._internal.utils.typingr Úpip._internal.utils.urlsr Útypingr r rrrrÚ#pip._internal.models.format_controlrÚ getLoggerrYrar#Úobjectr$r^rjrorqr!r!r!r"Ús0          R