
    *,h@                     (   d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z(m)Z) g dZ* ejV                  e,      Z-ej\                  j_                         Z0de1de	e1ee1   f   fdZ2dee1   dee1   fdZ3de1de	ee1   e1ee1   f   fdZ4de1ddfdZ5de1de1fdZ6 G d d      Z7de1de7fd Z8	 d;dd!ddd!d!d!dd"de1d#ee
ee1f      d$ee9   d%e9d&eee1      d'eee1ee1   f      d(e9d)e9d*e9d+eee1e
e1ee1   f   f      defd,Z:d-e1de9fd.Z;de1d-e1dee1   fd/Z<d-e1d0ee1   de7fd1Z=	 d;dd!ddd!dd!dd2d-e1d#ee
e1ef      d$ee9   d%e9d&eee1      d'eee1ee1   f      d(e9d0ee1   d)e9d+eee1e
e1ee1   f   f      defd3Z>	 	 	 	 d<d4e1d#ee   d%e9d$ee9   d)e9defd5Z?	 	 	 	 d=d6ed%e9d$ee9   d)e9d+eee1e
e1ee1   f   f      defd7Z@d8ed9edefd:ZAy)>a~  Backing implementation for InstallRequirement's various constructors

The idea here is that these formed a major chunk of InstallRequirement's size
so, moving them and support code dedicated to them outside of that class
helps creates for better understandability for the rest of the code.

These are meant to be used elsewhere within pip to create instances of
InstallRequirement.
    N)DictListOptionalSetTupleUnion)Marker)InvalidRequirementRequirement)	Specifier)InstallationError)PyPITestPyPI)Link)Wheel)ParsedRequirement)InstallRequirement)is_archive_file)is_installable_dir)get_requirement)path_to_url)is_urlvcs)install_req_from_editableinstall_req_from_lineparse_editablepathreturnc                     t        j                  d|       }d }|r&|j                  d      }|j                  d      }||fS | }||fS )Nz^(.+)(\[[^\]]+\])$      )rematchgroup)r   mextraspath_no_extrass       `/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_internal/req/constructors.py_strip_extrasr)   *   sT    
&-AF 6!! 6!!    r&   c                 f    | s
t               S t        d| j                         z         j                  S )Nplaceholder)setr   lowerr&   )r&   s    r(   convert_extrasr/   6   s(    u=6<<>9:AAAr*   editable_reqc                    | }t        |      \  }}t        j                  j                  |      rt	        |      }|j                         j                  d      rMt        |      j                  }|r)||t        d|j                         z         j                  fS ||t               fS t        D ]-  }|j                         j                  | d      s&| d| } n t        |      }|j                  s0dj                  t        j                        }t!        |  d| d      |j                  }|st!        dj#                  |             ||t               fS )	a   Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    zfile:r,   :+z, zq is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with z).zZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r)   osr   isdirr   r.   
startswithr   egg_fragmentr   r&   r-   r   is_vcsjoinall_schemesr   format)r0   urlurl_no_extrasr&   package_nameversion_controllinkbackendss           r(   r   r   <   s[    C *#.M6	ww}}]##M2''0M*77 >?FF   55 99;!!_$5Q"78$%Qse,C
 9D;;99S__-n 'j,
 	
 $$L**0&*>
 	
 ce##r*   filenamec                 4   t        | dd      5 }d d |D        D        }|D ]_  }d|v r|d|j                  d       }|j                  d      r |dd	 j                         t	        |d
      z   }t        |        ddd       y 	 ddd       y# 1 sw Y   yxY w)a   Check if file is parsable as a requirements file.

    This is heavily based on ``pkg_resources.parse_requirements``, but
    simplified to just check the first meaningful line.

    :raises InvalidRequirement: If the first meaningful line cannot be parsed
        as an requirement.
    zutf-8ignore)encodingerrorsc              3   F   K   | ]  }|r|j                  d       s|  yw)#N)r6   .0lines     r(   	<genexpr>z2check_first_requirement_in_file.<locals>.<genexpr>~   s&      
DOOC0 
s   !c              3   <   K   | ]  }|j                           y wN)striprI   s     r(   rL   z2check_first_requirement_in_file.<locals>.<genexpr>   s     4$4s   z #N\ )openfindendswithrO   nextr   )rB   flinesrK   s       r(   check_first_requirement_in_filerY   s   s     
h	: a
4!4
  	Dt|-diio.}}T"CRy(4r?:! 	  s   A+BBBreqc                     t         j                  j                  |       sd|  dS d}	 t        |        |d|  dz  }|S # t        $ r t
        j                  d|        Y |S w xY w)zReturns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    z File 'z' does not exist.z The path does exist. zThe argument you provided (zx) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.z&Cannot parse '%s' as requirements file)r4   r   existsrY   r
   loggerdebug)rZ   msgs     r(   deduce_helpful_msgr`      s     77>>#.//
"C
', 	u 12	
 J  D=sC JDs   ? A"!A"c            	       <    e Zd Zdee   dee   dee   dee   fdZ	y)RequirementPartsrequirementr@   markersr&   c                 <    || _         || _        || _        || _        y rN   )rc   r@   rd   r&   )selfrc   r@   rd   r&   s        r(   __init__zRequirementParts.__init__   s!     '	r*   N)
__name__
__module____qualname__r   r   r   r	   r   strrg    r*   r(   rb   rb      s?    
k*
 tn
 &!	

 C
r*   rb   c                     t        |       \  }}}|	 t        |      }nd }t	        |      }t        ||d |      S # t        $ r t        d| d      w xY w)NInvalid requirement: '')r   r   r
   r   r   rb   )r0   namer<   extras_overriderZ   r@   s         r(   parse_req_from_editablerr      sr    !/!=D#	F)4T):C 9DCt_== " 	F#&<TF!$DEE	Fs	   : AF)
use_pep517isolatedglobal_optionshash_options
constraintuser_suppliedpermit_editable_wheelsconfig_settings
comes_fromrs   rt   ru   rv   rw   rx   ry   rz   c                    t        |       }
t        |
j                  ||d||
j                  ||||||	|
j                        S )NT)r{   rx   editablery   r@   rw   rs   rt   ru   rv   rz   r&   )rr   r   rc   r@   r&   )r0   r{   rs   rt   ru   rv   rw   rx   ry   rz   partss              r(   r   r      sP     $L1E#5ZZ%!'|| r*   rp   c                     t         j                  j                  | v ryt         j                  j                  t         j                  j                  | v ry| j	                  d      ryy)ak  Checks whether the string "looks like" a path on the filesystem.

    This does not check whether the target actually exists, only judge from the
    appearance.

    Returns true if any of the following conditions is true:
    * a path separator is found (either os.path.sep or os.path.altsep);
    * a dot is found (which represents the current directory).
    T.F)r4   r   sepaltsepr6   )rp   s    r(   _looks_like_pathr      sI     
ww{{d	ww~~!bggnn&<sr*   c                    t        |      rDt        j                  j                  |       r%t	        |       rt        |       S t        d|d      t        |       syt        j                  j                  |       rt        |       S |j                  dd      }t        |      dk\  rt        |d         syt        j                  d|       t        |       S )	aK  
    First, it checks whether a provided path is an installable directory. If it
    is, returns the path.

    If false, check if the path is an archive file (such as a .whl).
    The function checks if the path is a file. If false, if the path has
    an @, it will treat it as a PEP 440 URL requirement and return the path.
    z
Directory zC is not installable. Neither 'setup.py' nor 'pyproject.toml' found.N@r    r!   r   zARequirement %r looks like a filename, but the file does not exist)r   r4   r   r5   r   r   r   r   isfilesplitlenr]   warning)r   rp   urlreq_partss      r(   _get_url_from_pathr      s     "''--"5d#t$$   !* *
 	
 4 	ww~~d4  ::c1%L
<A&6|A&G 
NNK tr*   line_sourcec           	         t        |       rd}nd}|| v r6| j                  |d      \  } }|j                         }|sd }nt        |      }nd }| j                         } d }t        j
                  j                  t        j
                  j                  |             }d }d }t        |       rt        |       }n't        |      \  }	}t        |	|       }
|
t        |
      }|r|j                  dk(  rxt        j                  d|j                        rXt        t        t        j
                  j                  t        j
                  j                  |j
                                          }|j                   r1t#        |j$                        }|j&                   d|j(                   }n|j*                  }n| }t-        |      }dt.        dt.        ffd	d
t.        dt0        ffd}|	 ||      }nd }t3        ||||      S )Nz; ;r    filez\.\./z==textr   c                     s| S |  d dS )Nz (from )rl   )r   r   s    r(   with_sourcez(parse_req_from_line.<locals>.with_sourceN  s    Kw{m1--r*   req_as_stringc                     	 t               }|j                  D ]/  }t        |      }|j                  d      s d| d}t	        |       |S # t
        $ ro t        j                  j                   v rd}|t               z  }n!d v rt         fdt        D              sd}nd} d	       }|r|d
| z  }t	        |      w xY w)N]zExtras after version 'z'.zIt looks like a path.=c              3   &   K   | ]  }|v  
 y wrN   rl   )rJ   opr   s     r(   rL   zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>Z  s      2(*m#2s   z,= is not a valid operator. Did you mean == ?rR   zInvalid requirement: z
Hint: )r   	specifierrk   rU   r   r
   r4   r   r   r`   any	operators)r   rZ   specspec_strr_   add_msgr   s   `     r(   _parse_req_stringz.parse_req_from_line.<locals>._parse_req_stringS  s    	1!-0C(  1t9$$S)28*B?C+C00	1
 
1 " 	)ww{{m+1-m<<%c 2.72 / I 5m5FGHC'++#C((	)s   A A8C)r   r   rO   r	   r4   r   normpathabspathr   r)   r   schemer"   searchr<   r   is_wheelr   rB   rp   versionr7   r/   rk   r   rb   )rp   r   
marker_sepmarkers_as_stringrd   r   r   r@   extras_as_stringpr<   wheelr&   r   rZ   r   s    `             @r(   parse_req_from_liner     s   d|

T"&**Z";-335 G./G::<DM77BGGOOD12DDd|Dz+D1 D)?9D ;;& RYYx%BBGG$4$4RWW__TYY5O$PQRD==$--(E$zzl"U]]O<M !--M ,-F.# .# .
  :  %6}%ECw77r*   )rs   rt   ru   rv   rw   r   rx   rz   c                    t        | |      }
t        |
j                  ||
j                  |
j                  |||||	||
j
                  |      S )a  Creates an InstallRequirement from a name, which might be a
    requirement, directory containing 'setup.py', filename, or URL.

    :param line_source: An optional string describing where the line is from,
        for logging purposes in case of an error.
    )
r@   rd   rs   rt   ru   rv   rz   rw   r&   rx   )r   r   rc   r@   rd   r&   )rp   r{   rs   rt   ru   rv   rw   r   rx   rz   r~   s              r(   r   r   x  sS    &  k2EZZ%!'||# r*   
req_stringc                 `   	 t        |       }t        j                  t
        j                  g}|j                  rK|rI|j                  r=|j                  j                  |v r%t        dj                  |j                  |            t        |||||      S # t        $ r t        d|  d      w xY w)Nrn   ro   zkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
{} depends on {} )rt   rs   rx   )r   r
   r   r   file_storage_domainr   r<   r@   netlocr;   rp   r   )r   r{   rt   rs   rx   rZ   domains_not_alloweds          r(   install_req_from_req_stringr     s    Hj)
 	  $$
 	OOOO""&99    &z <
 	
 # )  H"8A FGGHs   B B-
parsed_reqc                    | j                   r2t        | j                  | j                  || j                  |||      }|S t        | j                  | j                  ||| j                  r| j                  j                  dg       ng | j                  r| j                  j                  di       ni | j                  | j                  ||
      }|S )N)r{   rs   rw   rt   rx   rz   ru   hashes)	r{   rs   rt   ru   rv   rw   r   rx   rz   )	is_editabler   rc   r{   rw   r   optionsgetr   )r   rt   rs   rx   rz   rZ   s         r(   #install_req_from_parsed_requirementr     s     '""!,,!!,,'+
: J% $""!,,! %% ""&&'7< 9C8J8J
""&&x4PR!,,"..'+!
$ Jr*   r@   ireqc                     t        |j                  |j                  |j                  | |j                  |j
                  |j                  |j                  |j                  |j                  |j                        S )N)rZ   r{   r}   r@   rd   rs   rt   ru   rv   rz   rx   )r   rZ   r{   r}   rd   rs   rt   ru   rv   rz   rx   )r@   r   s     r(   install_req_from_link_and_ireqr     sb     HH????**&&,,(( r*   rN   )NFNF)FNFN)B__doc__loggingr4   r"   typingr   r   r   r   r   r   pip._vendor.packaging.markersr	   "pip._vendor.packaging.requirementsr
   r    pip._vendor.packaging.specifiersr   pip._internal.exceptionsr   pip._internal.models.indexr   r   pip._internal.models.linkr   pip._internal.models.wheelr   pip._internal.req.req_filer   pip._internal.req.req_installr   pip._internal.utils.filetypesr   pip._internal.utils.miscr   pip._internal.utils.packagingr   pip._internal.utils.urlsr   pip._internal.vcsr   r   __all__	getLoggerrh   r]   
_operatorskeysr   rk   r)   r/   r   rY   r`   rb   rr   boolr   r   r   r   r   r   r   r   rl   r*   r(   <module>r      s    	 	 : : 0 N 6 6 5 * , 8 < 9 7 9 0 ) 
		8	$  %%'		" 	"c8C=&8 9 	"B8C= BSX B4$ 4$x}c3s8/K)L 4$nc d 8C C 2 ># >2B >* <@ "&*.37#(BF13678 	
  T#Y' 4T#Y/0   ! d3c49n(=#=>? @3 4 &S   DW8c W8 W8BR W8x <@" "&*.37!%BF"
"s$6678" 	"
 " T#Y'" 4T#Y/0" " #" " d3c49n(=#=>?" "N 04!%##+,# # 	#
 # #P !%BF%!%% % 	%
 d3c49n(=#=>?% %P
(r*   