HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3.9/site-packages/pip/_internal/req/__pycache__/constructors.cpython-39.pyc
a

g��e�=�@s�dZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZddlmZddlmZmZddlmZdd	lmZmZdd
lmZddlmZddlmZdd
l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,gd�Z-e�.e/�Z0ej1�2�Z3e4e	e4ee4fd�dd�Z5ee4ee4d�dd�Z6e4e	ee4e4ee4fd�dd�Z7e4e4d�dd�Z8Gd d!�d!�Z9e4e9d�d"d#�Z:d=e4ee
e#e4fee;e;eee4efe;e;e#d%�d&d'�Z<e4e;d(�d)d*�Z=e4e4ee4d+�d,d-�Z>e4ee4e9d.�d/d0�Z?d>e4ee
e4e#fee;e;eee4efe;ee4e;e#d1�	d2d3�Z@d?e4ee#e;ee;e;e#d4�d5d6�ZAd@e!e;ee;e;e#d7�d8d9�ZBee#e#d:�d;d<�ZCdS)Aa~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)�RequirementParseError�parse_requirements)�InstallationError)�PyPI�TestPyPI)�Link)�Wheel)�make_pyproject_path)�ParsedRequirement)�InstallRequirement)�is_archive_file)�is_installable_dir)�path_to_url)�is_url�vcs)�install_req_from_editable�install_req_from_line�parse_editable)�path�returncCs6t�d|�}d}|r*|�d�}|�d�}n|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)r�m�extrasZpath_no_extras�r'�B/usr/lib/python3.9/site-packages/pip/_internal/req/constructors.py�
_strip_extras*s
r))r&rcCs|s
t�Std|���jS)N�placeholder)�setr
�lowerr&)r&r'r'r(�convert_extras6sr-)�editable_reqrcCsV|}t|�\}}tj�|�r�tj�|d�}tj�|d�}tj�|�s�tj�|�s�d�tj�|��}t|�}tj�	|�r~|d7}t
|��t|�}|���
d�r�t|�j}|r�||td|���jfS||t�fStD],}	|���
|	�d��r�|	�d|��}�qq�t|�}
|
j�s0d	�tj�}t
|�d
|�d���|
j}|�sJt
d�|���||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]
    zsetup.pyz	setup.cfgz\File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: {}zd
(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)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�isdir�join�exists�format�abspathr�isfilerrr,�
startswithr�egg_fragmentr
r&r+rZis_vcsZall_schemes)r.�urlZ
url_no_extrasr&Zsetup_pyZ	setup_cfg�msgZpyproject_pathZpackage_nameZversion_control�linkZbackendsr'r'r(r<sZ
���
�����r)�reqrcCs�d}tj�|�r�d}zJt|��.}tt|����|d�|�7}Wd�n1sR0YWq�ty�t	j
d|dd�Yq�0n|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 The path does exist. z�The argument you provided ({}) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.Nz&Cannot parse '%s' as requirements fileT)�exc_infoz File 'z' does not exist.)r1rr4�open�nextr
�readr5r�logger�debug)r=r;�fpr'r'r(�deduce_helpful_msg�s"
��(�rFc@s0eZdZeeeeeeeed�dd�Z	dS)�RequirementParts��requirementr<�markersr&cCs||_||_||_||_dS�NrH)�selfrIr<rJr&r'r'r(�__init__�szRequirementParts.__init__N)
�__name__�
__module__�__qualname__rr
rrr�strrMr'r'r'r(rG�s
�rGcCsbt|�\}}}|durHzt|�}WqLtyDtd|�d���YqL0nd}t|�}t||d|�S)N�Invalid requirement: '�')rr
r	rrrG)r.�namer:Zextras_overrider=r<r'r'r(�parse_req_from_editable�srUF)r.�
comes_from�
use_pep517�isolated�options�
constraint�
user_suppliedrcCs^t|�}t|j||d|j||||r.|�dg�ng|r@|�dg�ng|rR|�di�ni|jd�S)NT�install_options�global_options�hashes)rVr[�editabler<rZrWrXr\r]�hash_optionsr&)rUrrIr<�getr&)r.rVrWrXrYrZr[�partsr'r'r(r�s
�r)rTrcCs>tjj|vrdStjjdur,tjj|vr,dS|�d�r:dSdS)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)r1r�sep�altsepr8)rTr'r'r(�_looks_like_path�s

rf)rrTrcCs�t|�r4tj�|�r4t|�r$t|�Std|�d���t|�s@dStj�|�rTt|�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�@r r!rzARequirement %r looks like a filename, but the file does not exist)
rfr1rr2rrrrr7�split�lenrCZwarning)rrTZurlreq_partsr'r'r(�_get_url_from_path�s$	
��rj)rT�line_sourcercsnt|�rd}nd}||vrF|�|d�\}}|��}|s<d}qJt|�}nd}|��}d}tj�tj�|��}d}d}t|�r�t|�}n&t	|�\}	}t
|	|�}
|
dur�t|
�}|�r|jdkr�t�
d|j�r�tttj�tj�|j����}|j�rt|j�}|j�d|j��}n|j}n|}t|�}ttd��fdd	��ttd
��fdd�}
|du�r\|
|�}nd}t||||�S)
Nz; �;r �filez\.\./z==)�textrcs�s|S|�d��d�S)Nz (from �)r')rn)rkr'r(�with_sourceCsz(parse_req_from_line.<locals>.with_source)�
req_as_stringrcs�zt��}Wn�ty�tjj�vr8d}|t��7}n(d�vr\t�fdd�tD��s\d}nd}�d����}|r�|d|��7}t|��Yn40|j	D]*}t
|�}|�d	�r�d
|�d�}t|��q�|S)NzIt looks like a path.�=c3s|]}|�vVqdSrKr')�.0�op�rqr'r(�	<genexpr>P�zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?r>zInvalid requirement: z
Hint: �]zExtras after version 'z'.)r
r	r1rrdrF�any�	operatorsrZ	specifierrQ�endswith)rqr=Zadd_msgr;�specZspec_str)rprur(�_parse_req_stringHs.��


z.parse_req_from_line.<locals>._parse_req_string)rrh�striprr1r�normpathr6rr)rj�schemer"�searchr:rZis_wheelr�filenamerT�versionr9r-rQr
rG)rTrkZ
marker_sepZmarkers_as_stringrJrqrr<Zextras_as_string�pr:Zwheelr&r}r=r')rkrpr(�parse_req_from_linesL


�


r�)	rTrVrWrXrYrZrkr[rc	Csbt||�}t|j||j|j|||r.|�dg�ng|r@|�dg�ng|rR|�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.
    r\r]r^)
r<rJrWrXr\r]r`rZr&r[)r�rrIr<rJrar&)	rTrVrWrXrYrZrkr[rbr'r'r(rns
�r)�
req_stringrVrXrWr[rcCs|zt|�}Wn"ty.td|�d���Yn0tjtjg}|jrj|rj|jrj|jj|vrjtd�	|j
|���t|||||d�S)NrRrSzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
{} depends on {} )rXrWr[)r
r	rrZfile_storage_domainrr:r<�netlocr5rTr)r�rVrXrWr[r=Zdomains_not_allowedr'r'r(�install_req_from_req_string�s,�
����r�)�
parsed_reqrXrWr[rc
CsH|jr"t|j|j||j||d�}n"t|j|j|||j|j|j|d�}|S)N)rVrWrZrXr[)rVrWrXrYrZrkr[)Zis_editablerrIrVrZrrYrk)r�rXrWr[r=r'r'r(�#install_req_from_parsed_requirement�s(�
�
r�)r<�ireqrcCs.t|j|j|j||j|j|j|j|j|j	d�
S)N)
r=rVr_r<rJrWrXr\r]r`)
rr=rVr_rJrWrXr\r]r`)r<r�r'r'r(�install_req_from_link_and_ireq�s�r�)NNFNFF)NNFNFNF)NFNF)FNF)D�__doc__Zloggingr1r"�typingrrrrrrZpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsr	r
Z pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrr
Zpip._internal.exceptionsrZpip._internal.models.indexrrZpip._internal.models.linkrZpip._internal.models.wheelrZpip._internal.pyprojectrZpip._internal.req.req_filerZpip._internal.req.req_installrZpip._internal.utils.filetypesrZpip._internal.utils.miscrZpip._internal.utils.urlsrZpip._internal.vcsrr�__all__Z	getLoggerrNrCZ
_operators�keysrzrQr)r-rrFrGrU�boolrrfrjr�rr�r�r�r'r'r'r(�<module>s�
 

"G��!^�� ��$���