HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/req/__pycache__/constructors.cpython-310.pyc
o

@%Ne�>�@s"dZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZddlmZdd
lm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)gd�Z*e�+e,�Z-ej.�/�Z0de1de	e1ee1ffdd�Z2dee1dee1fdd�Z3de1de	ee1e1ee1ffdd�Z4de1ddfdd�Z5d e1de1fd!d"�Z6Gd#d$�d$�Z7de1de7fd%d&�Z8			'		'	'	'dEde1d(ee
ee1fd)ee9d*e9d+eee1efd,e9d-e9d.e9defd/d0�Z:d1e1de9fd2d3�Z;de1d1e1dee1fd4d5�Z<d1e1d6ee1de7fd7d8�Z=			'		'		'dFd1e1d(ee
e1efd)ee9d*e9d+eee1efd,e9d6ee1d-e9defd9d:�Z>		'		'dGd;e1d(eed*e9d)ee9d-e9defd<d=�Z?	'		'dHd>ed*e9d)ee9d-e9def
d?d@�Z@dAedBedefdCdD�ZAdS)Ia~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)�Any�Dict�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�returncCs<t�d|�}d}|r|�d�}|�d�}||fS|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)r�m�extras�path_no_extras�r&�@/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py�
_strip_extras*s

�r(r$cCs|st�Std|���jS)N�placeholder)�setr�lowerr$)r$r&r&r'�convert_extras6sr,�editable_reqcCs�|}t|�\}}tj�|�rt|�}|���d�r2t|�j}|r,||t	d|���j
fS||t�fStD]}|���|�d��rI|�d|��}nq4t|�}|j
sad�tj�}t|�d|�d���|j}|smtd�|���||t�fS)	aParses 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]
    zfile: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�isdirrr+�
startswithr�egg_fragmentrr$r*r�is_vcs�join�all_schemesr�format)r-�url�
url_no_extrasr$�package_name�version_control�link�backendsr&r&r'r<s@
�����r�filenamecCs�t|ddd��E}dd�dd�|D�D�}|D]-}d|vr%|d|�d��}|�d	�r7|dd
���t|d�}t|�Wd�dSWd�dS1sOwYdS)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.
    zutf-8�ignore)�encoding�errorscss"�|]}|r|�d�s|VqdS)�#N)r2��.0�liner&r&r'�	<genexpr>~s���
�z2check_first_requirement_in_file.<locals>.<genexpr>css�|]}|��VqdS�N)�striprCr&r&r'rF�s�z #N�\����)�open�find�endswithrH�nextr
)r>�f�linesrEr&r&r'�check_first_requirement_in_filess	�
�"�rR�reqcCs^tj�|�sd|�d�Sd}zt|�Wnty$t�d|�Y|Sw|d|�d�7}|S)z�Returns 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&Cannot parse '%s' as requirements filezThe 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.)r0r�existsrRr	�logger�debug)rS�msgr&r&r'�deduce_helpful_msg�s	���rXc	@s6eZdZdeedeedeedeefdd�Z	dS)�RequirementParts�requirementr<�markersr$cCs||_||_||_||_dSrG)rZr<r[r$)�selfrZr<r[r$r&r&r'�__init__�s
zRequirementParts.__init__N)
�__name__�
__module__�__qualname__rr
rrr�strr]r&r&r&r'rY�s����rYcCs\t|�\}}}|dur!zt|�}Wnty td|�d���wd}t|�}t||d|�S)N�Invalid requirement: '�')rr
r	rrrY)r-�namer8�extras_overriderSr<r&r&r'�parse_req_from_editable�s�rfF�
comes_from�
use_pep517�isolated�options�
constraint�
user_supplied�permit_editable_wheelsc	Cs`t|�}t|j||d||j||||r|�dg�ng|r!|�dg�ng|r*|�di�ni|jd�
S)NT�install_options�global_options�hashes)rgrl�editablermr<rkrhrirnro�hash_optionsr$)rfrrZr<�getr$)	r-rgrhrirjrkrlrm�partsr&r&r'r�s �rrdcCs>tjj|vrdStjjdurtjj|vrdS|�d�rdSdS)akChecks 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).
    TN�.F)r0r�sep�altsepr2)rdr&r&r'�_looks_like_path�s

rxcCs�t|�rtj�|�rt|�rt|�Std|�d���t|�s dStj�|�r*t|�S|�	dd�}t
|�dkr>t|d�s>dSt�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�@rrrzARequirement %r looks like a filename, but the file does not exist)
rxr0rr1rrrr�isfile�split�lenrU�warning)rrd�urlreq_partsr&r&r'�_get_url_from_path�s$	
��r�line_sourcecslt|�rd}nd}||vr#|�|d�\}}|��}|sd}nt|�}nd}|��}d}tj�tj�|��}d}d}t|�rBt|�}nt	|�\}	}t
|	|�}
|
durUt|
�}|r�|jdkrrt�
d|j�rrtttj�tj�|j����}|jr�t|j�}|j�d|j��}n|j}n|}t|�}dtdtf�fd	d
��dtdtf�fdd
�}
|dur�|
|�}nd}t||||�S)Nz; �;r�filez\.\./z==�textrcs�s|S|�d��d�S)Nz (from �)r&)r�)r�r&r'�with_sourceLsz(parse_req_from_line.<locals>.with_source�
req_as_stringcs�zt��}Wn>tyDtjj�vrd}|t��7}nd�vr.t�fdd�tD��s.d}nd}�d����}|r@|d|��7}t|��w|j	D]}t
|�}|�d	�r]d
|�d�}t|��qH|S)NzIt looks like a path.�=c3s�|]}|�vVqdSrGr&)rD�op�r�r&r'rFXs�
�zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?rKzInvalid requirement: z
Hint: �]zExtras after version 'z'.)rr	r0rrvrX�any�	operatorsr�	specifierrarN)r�rS�add_msgrW�spec�spec_str)r�r�r'�_parse_req_stringQs.��

�z.parse_req_from_line.<locals>._parse_req_string)rr{rHrr0r�normpath�abspathrr(r�schemer �searchr8r�is_wheelrr>rd�versionr3r,rar
rY)rdr��
marker_sep�markers_as_stringr[r�rr<�extras_as_string�pr8�wheelr$r�rSr&)r�r�r'�parse_req_from_linesH




r�c	Csbt||�}t|j||j|j|||r|�dg�ng|r |�dg�ng|r)|�di�ni||j|d�S)aCreates 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.
    rnrorp)
r<r[rhrirnrorrrkr$rl)r�rrZr<r[rsr$)	rdrgrhrirjrkr�rlrtr&r&r'rvs
�r�
req_stringcCsxzt|�}Wntytd|�d���wtjtjg}|jr3|r3|jr3|jj|vr3td�	|j
|���t|||||d�S)NrbrczkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
{} depends on {} )rirhrl)rr	rr
�file_storage_domainrr8r<�netlocr7rdr)r�rgrirhrlrS�domains_not_allowedr&r&r'�install_req_from_req_string�s4�����
��r��
parsed_reqc
CsJ|jrt|j|j||j||d�}|St|j|j|||j|j|j|d�}|S)N)rgrhrkrirl)rgrhrirjrkr�rl)�is_editablerrZrgrkrrjr�)r�rirhrlrSr&r&r'�#install_req_from_parsed_requirement�s*���
r�r<�ireqcCs.t|j|j|j||j|j|j|j|j|j	d�
S)N)
rSrgrqr<r[rhrirnrorr)
rrSrgrqr[rhrirnrorr)r<r�r&r&r'�install_req_from_link_and_ireq�s�r�)NNFNFFF)NNFNFNF)NFNF)FNF)B�__doc__�loggingr0r �typingrrrrrr�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.vcsrr�__all__�	getLoggerr^rU�
_operators�keysr�rar(r,rrRrXrYrf�boolrrxrr�rr�r�r�r&r&r&r'�<module>s�
 

$7���������	
�"\���������	
�$������
�(�����
����