HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/__pycache__/cache.cpython-37.pyc
B

L��g�(�@s*dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZddlm
Z
mZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZe�e �Z!d
Z"e	e#e#fe#d�dd�Z$Gdd�d�Z%Gdd�de%�Z&Gdd�de&�Z'Gdd�d�Z(Gdd�de%�Z)dS)zCache Management
�N)�Path)�Any�Dict�List�Optional)�Tag�interpreter_name�interpreter_version)�canonicalize_name)�InvalidWheelFilename)�	DirectUrl)�Link)�Wheel)�
TempDirectory�
tempdir_kinds)�path_to_urlzorigin.json)�d�returncCs&tj|dddd�}t�|�d����S)z'Return a stable sha224 of a dictionary.T)�,�:)�	sort_keys�
separators�ensure_ascii�ascii)�json�dumps�hashlib�sha224�encode�	hexdigest)r�s�r!�7/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/cache.py�
_hash_dictsr#cs~eZdZdZedd��fdd�Zeeed�dd�Zeeee	d	�d
d�Z
eed�dd
�Zeeeee
ed�dd�Z�ZS)�CachezuAn abstract class - provides cache directories for data from links

    :param cache_dir: The root of the cache.
    N)�	cache_dirrcs,t���|rtj�|�st�|p$d|_dS)N)�super�__init__�os�path�isabs�AssertionErrorr%)�selfr%)�	__class__r!r"r'&s
zCache.__init__)�linkrcCs�d|ji}|jdk	r*|jdk	r*|j||j<|jr:|j|d<t�|d<t�|d<t|�}|dd�|dd�|dd�|dd�g}|S)	z<Get parts of part that must be os.path.joined with cache_dir�urlN�subdirectoryrr	���)�url_without_fragment�	hash_name�hash�subdirectory_fragmentrr	r#)r,r.�	key_parts�hashed�partsr!r!r"�_get_cache_path_parts+s



,zCache._get_cache_path_parts)r.�canonical_package_namercsN|jp|p|}|rgS|�|��tj���rJ�fdd�t���D�SgS)Ncsg|]}|�f�qSr!r!)�.0�	candidate)r)r!r"�
<listcomp>Ssz)Cache._get_candidates.<locals>.<listcomp>)r%�get_path_for_linkr(r)�isdir�listdir)r,r.r<�
can_not_cacher!)r)r"�_get_candidatesLs
zCache._get_candidatescCs
t��dS)z5Return a directory to store cached items in for link.N)�NotImplementedError)r,r.r!r!r"r@VszCache.get_path_for_link)r.�package_name�supported_tagsrcCs
t��dS)zaReturns a link to a cached item if it exists, otherwise returns the
        passed link.
        N)rE)r,r.rFrGr!r!r"�getZs	z	Cache.get)�__name__�
__module__�__qualname__�__doc__�strr'r
rr;rrDr@rrrH�
__classcell__r!r!)r-r"r$ s!
r$csTeZdZdZedd��fdd�Zeed�dd�Zeeee	e
ed	�d
d�Z�ZS)�SimpleWheelCachez&A cache of wheels for future installs.N)r%rcst��|�dS)N)r&r')r,r%)r-r!r"r'iszSimpleWheelCache.__init__)r.rcCs*|�|�}|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.
        �wheels)r;r%r+r(r)�join)r,r.r:r!r!r"r@ls

z"SimpleWheelCache.get_path_for_link)r.rFrGrc
	Cs�g}|s|St|�}x~|�||�D]n\}}yt|�}Wntk
rLw"YnXt|j�|krnt�d|||�q"|�|�szq"|�|�	|�||f�q"W|s�|St
|�\}	}}ttt
j�||���S)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r
rDrr�name�logger�debug�	supported�append�support_index_min�minr
rr(r)rQ)
r,r.rFrG�
candidatesr<�
wheel_name�	wheel_dir�wheel�_r!r!r"rH�s4
zSimpleWheelCache.get)
rIrJrKrLrMr'r
r@rrrrHrNr!r!)r-r"rOfsrOcs&eZdZdZdd��fdd�Z�ZS)�EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryN)rcs$ttjdd�|_t��|jj�dS)NT)�kind�globally_managed)rr�EPHEM_WHEEL_CACHE�	_temp_dirr&r'r))r,)r-r!r"r'�s
zEphemWheelCache.__init__)rIrJrKrLr'rNr!r!)r-r"r^�sr^c@seZdZeed�dd�ZdS)�
CacheEntry)r.�
persistentc
Cs~||_||_d|_t|jj�jt}|��rzyt�	|j
dd��|_Wn4tk
rx}zt�
d||j|�Wdd}~XYnXdS)Nzutf-8)�encodingz7Ignoring invalid cache entry origin file %s for %s (%s))r.rd�originr�	file_path�parent�ORIGIN_JSON_NAME�existsr�	from_json�	read_text�	ExceptionrS�warning�filename)r,r.rdZorigin_direct_url_path�er!r!r"r'�szCacheEntry.__init__N)rIrJrKr
�boolr'r!r!r!r"rc�srccs�eZdZdZedd��fdd�Zeed�dd�Zeed�d	d
�Zee	ee
eed�dd
�Zee	ee
ee	e
d�dd�Zeeedd�dd��Z�ZS)�
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.
    N)r%rcs"t��|�t|�|_t�|_dS)N)r&r'rO�_wheel_cacher^�_ephem_cache)r,r%)r-r!r"r'�s
zWheelCache.__init__)r.rcCs|j�|�S)N)rsr@)r,r.r!r!r"r@�szWheelCache.get_path_for_linkcCs|j�|�S)N)rtr@)r,r.r!r!r"�get_ephem_path_for_link�sz"WheelCache.get_ephem_path_for_link)r.rFrGrcCs |�|||�}|dkr|S|jS)N)�get_cache_entryr.)r,r.rFrG�cache_entryr!r!r"rH�szWheelCache.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.rFrGT)rdFN)rsrHrcrt)r,r.rFrG�retvalr!r!r"rv�s
zWheelCache.get_cache_entry)r%�
download_inforc
Cs�t|�t}|��r|yt�|jdd��}Wn0tk
rZ}zt�d||�Wdd}~XYn"X|j	|j	kr|t�d|j	||j	�|j
|��dd�dS)Nzutf-8)rezPCould not read origin file %s in cache entry (%s). Will attempt to overwrite it.z�Origin 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.)rrirjrrkrlrmrSrnr/�
write_text�to_json)r%ryZorigin_pathrfrpr!r!r"�record_download_origin	s z!WheelCache.record_download_origin)rIrJrKrLrMr'r
r@rurrrrHrcrv�staticmethodrr|rNr!r!)r-r"rr�srr)*rLrr�loggingr(�pathlibr�typingrrrr�pip._vendor.packaging.tagsrrr	�pip._vendor.packaging.utilsr
�pip._internal.exceptionsr�pip._internal.models.direct_urlr�pip._internal.models.linkr
�pip._internal.models.wheelr�pip._internal.utils.temp_dirrr�pip._internal.utils.urlsr�	getLoggerrIrSrirMr#r$rOr^rcrrr!r!r!r"�<module>s,
FF