
    q"h(                     f   S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJ	r	J
r
Jr  SSKJrJrJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  \R>                  " \ 5      r!Sr"S\	\#\#4   S\#4S jr$ " S S5      r% " S S\%5      r& " S S\&5      r' " S S5      r( " S S\%5      r)g)zCache Management    N)Path)AnyDictListOptional)Taginterpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename)	DirectUrl)Link)Wheel)TempDirectorytempdir_kinds)path_to_urlzorigin.jsondreturnc                     [         R                  " U SSSS9n[        R                  " UR	                  S5      5      R                  5       $ )z'Return a stable sha224 of a dictionary.T),:)	sort_keys
separatorsensure_asciiascii)jsondumpshashlibsha224encode	hexdigest)r   ss     E/var/www/html/env/lib/python3.13/site-packages/pip/_internal/cache.py
_hash_dictr$      s7    

1$OA>>!((7+,6688    c                      ^  \ rS rSrSrS\SS4U 4S jjrS\S\\   4S jr	S\S	\S\\
   4S
 jrS\S\4S jrS\S\\   S\\   S\4S jrSrU =r$ )Cache   zmAn abstract class - provides cache directories for data from links

:param cache_dir: The root of the cache.
	cache_dirr   Nc                    > [         TU ]  5         U(       a&  [        R                  R	                  U5      (       d   eU=(       d    S U l        g N)super__init__ospathisabsr)   selfr)   	__class__s     r#   r-   Cache.__init__%   s5    i 8 888"*dr%   linkc                 4   SUR                   0nUR                  b%  UR                  b  UR                  X!R                  '   UR                  (       a  UR                  US'   [	        5       US'   [        5       US'   [        U5      nUSS USS USS USS /nU$ )	z<Get parts of part that must be os.path.joined with cache_dirurlNsubdirectoryr	   r
            )url_without_fragment	hash_namehashsubdirectory_fragmentr	   r
   r$   )r2   r5   	key_partshashedpartss        r#   _get_cache_path_partsCache._get_cache_path_parts*   s     D556	>>%$))*?(,		Inn%%%(,(B(BIn% )9(:	$%+>+@	'( I&
 VAa[&1+vabzBr%   canonical_package_namec                 6   U R                   (       + =(       d    U(       + =(       d    U(       + nU(       a  / $ U R                  U5      n[        R                  R	                  U5      (       a(  [        R
                  " U5       Vs/ s H  oUU4PM     sn$ / $ s  snf r+   )r)   get_path_for_linkr.   r/   isdirlistdir)r2   r5   rE   can_not_cacher/   	candidates         r#   _get_candidatesCache._get_candidatesK   sx     NN*T2H.HTPTHI%%d+77==79zz$7GH7G)%7GHH	 Is   Bc                     [        5       e)z5Return a directory to store cached items in for link.NotImplementedErrorr2   r5   s     r#   rG   Cache.get_path_for_linkU   s    !##r%   package_namesupported_tagsc                     [        5       e)zQReturns a link to a cached item if it exists, otherwise returns the
passed link.
rO   )r2   r5   rS   rT   s       r#   get	Cache.getY   s     "##r%   )r)   )__name__
__module____qualname____firstlineno____doc__strr-   r   r   rC   r   rL   rG   r   r   rV   __static_attributes____classcell__r3   s   @r#   r'   r'      s    
+# +$ +
$ 49 BD # $s) $d $s $	$	$ sm	$ S			$
 
	$ 	$r%   r'   c                   p   ^  \ rS rSrSrS\SS4U 4S jjrS\S\4S jrS\S	\	\   S
\
\   S\4S jrSrU =r$ )SimpleWheelCachee   z&A cache of wheels for future installs.r)   r   Nc                 $   > [         TU ]  U5        g r+   )r,   r-   r1   s     r#   r-   SimpleWheelCache.__init__h   s    #r%   r5   c                     U R                  U5      nU R                  (       d   e[        R                  R                  " U R                  S/UQ76 $ )ac  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)rC   r)   r.   r/   join)r2   r5   rB   s      r#   rG   "SimpleWheelCache.get_path_for_linkk   s>     **40~~~ww||DNNH=u==r%   rS   rT   c                    / nU(       d  U$ [        U5      nU R                  X5       H  u  pg [        U5      n[        UR                  5      U:w  a  [
        R                  SUUU5        MD  UR                  U5      (       d  M\  UR                  UR                  U5      UU45        M     U(       d  U$ [        U5      u  pn[        [        [        R                  R                  Xv5      5      5      $ ! [         a     M  f = f)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r   rL   r   r   nameloggerdebug	supportedappendsupport_index_minminr   r   r.   r/   rh   )
r2   r5   rS   rT   
candidatesrE   
wheel_name	wheel_dirwheel_s
             r#   rV   SimpleWheelCache.get   s     
K!2<!@%)%9%9$%W!Jj) !,0FFH  ??>22++N;# &X2 K#&z? yKY CDEE5 ( s   C33
D D )rX   rY   rZ   r[   r\   r]   r-   r   rG   r   r   r   rV   r^   r_   r`   s   @r#   rb   rb   e   sj    0$# $$ $>d >s >()F)F sm)F S		)F
 
)F )Fr%   rb   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )EphemWheelCache   zBA SimpleWheelCache that creates it's own temporary cache directoryc                    > [        [        R                  SS9U l        [        TU ]  U R                  R                  5        g )NT)kindglobally_managed)r   r   EPHEM_WHEEL_CACHE	_temp_dirr,   r-   r/   )r2   r3   s    r#   r-   EphemWheelCache.__init__   s4    &00!

 	,,-r%   )r   )r   N)rX   rY   rZ   r[   r\   r-   r^   r_   r`   s   @r#   rz   rz      s    L. .r%   rz   c                   &    \ rS rSrS\S\4S jrSrg)
CacheEntry   r5   
persistentc                 z   Xl         X l        S U l        [        U R                   R                  5      R
                  [        -  nUR                  5       (       a*   [        R                  " UR                  SS95      U l        g g ! [         a,  n[        R                  SUUR                  U5         S nAg S nAff = f)Nutf-8encodingz7Ignoring invalid cache entry origin file %s for %s (%s))r5   r   originr   	file_pathparentORIGIN_JSON_NAMEexistsr   	from_json	read_text	Exceptionrl   warningfilename)r2   r5   r   origin_direct_url_pathes        r#   r-   CacheEntry.__init__   s    
 	$+/!%dii&9&9!:!A!ADT!T!((**
'11*44g4F +
  M*MM	 s   (B 
B:"B55B:)r5   r   r   N)rX   rY   rZ   r[   r   boolr-   r^   rx   r%   r#   r   r      s     r%   r   c            	          ^  \ rS rSrSrS\SS4U 4S jjrS\S\4S jrS\S\4S	 jr	S\S
\
\   S\\   S\4S jrS\S
\
\   S\\   S\
\   4S jr\S\S\SS4S j5       rSrU =r$ )
WheelCache   zWraps 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)   r   Nc                 b   > [         TU ]  U5        [        U5      U l        [	        5       U l        g r+   )r,   r-   rb   _wheel_cacherz   _ephem_cacher1   s     r#   r-   WheelCache.__init__   s(    #,Y7+-r%   r5   c                 8    U R                   R                  U5      $ r+   )r   rG   rQ   s     r#   rG   WheelCache.get_path_for_link         22488r%   c                 8    U R                   R                  U5      $ r+   )r   rG   rQ   s     r#   get_ephem_path_for_link"WheelCache.get_ephem_path_for_link   r   r%   rS   rT   c                 H    U R                  XU5      nUc  U$ UR                  $ r+   )get_cache_entryr5   )r2   r5   rS   rT   cache_entrys        r#   rV   WheelCache.get   s-     **4~NKr%   c                     U R                   R                  UUUS9nXALa
  [        USS9$ U R                  R                  UUUS9nXALa
  [        USS9$ g)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.
)r5   rS   rT   T)r   FN)r   rV   r   r   )r2   r5   rS   rT   retvals        r#   r   WheelCache.get_cache_entry   sy     ""&&%) ' 

 f66""&&%) ' 

 f77r%   download_infoc                    [        U 5      [        -  nUR                  5       (       aj   [        R                  " UR                  SS95      nUR                  UR                  :w  a,  [        R                  SUR                  U UR                  5        UR                  UR                  5       SS9  g ! [         a!  n[        R                  SUU5         S nANES nAff = f)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.)r   r   r   r   r   r   r7   rl   r   r   
write_textto_json)r)   r   origin_pathr   r   s        r#   record_download_origin!WheelCache.record_download_origin  s    9o(88",,[-B-BG-B-TU ::!2!22NN@ 

!%)) 	}446I'  4	 s   #B1 1
C;CC)r   r   )rX   rY   rZ   r[   r\   r]   r-   r   rG   r   r   r   r   rV   r   r   staticmethodr   r   r^   r_   r`   s   @r#   r   r      s    .# .$ .
9d 9s 99D 9S 9	 	  sm	  S			 
 
	  sm S		
 
*	8 J# Ji JD J Jr%   r   )*r\   r   r   loggingr.   pathlibr   typingr   r   r   r   pip._vendor.packaging.tagsr   r	   r
   pip._vendor.packaging.utilsr   pip._internal.exceptionsr   pip._internal.models.direct_urlr   pip._internal.models.linkr   pip._internal.models.wheelr   pip._internal.utils.temp_dirr   r   pip._internal.utils.urlsr   	getLoggerrX   rl   r   r]   r$   r'   rb   rz   r   r   rx   r%   r#   <module>r      s        	  , , Q Q 9 9 5 * , E 0			8	$  9$sCx. 9S 9C$ C$LCFu CFL	.& 	. 0RJ RJr%   