o
    g}”e_+  ã                   @   sR  d dl Zd dl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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mZ d dlmZmZmZ d dlmZ d d	l m!Z! d d
l"m#Z# erkd dlm$Z$ ne%Z$eeef Z&e 'e(¡Z)G dd„ de$ƒZ*G dd„ de$ƒZ+G dd„ dƒZ,G dd„ de$ƒZ-G dd„ de-ƒZ.G dd„ de-ƒZ/dS )é    N)	ÚIOÚTYPE_CHECKINGÚ
CollectionÚ	ContainerÚIterableÚIteratorÚListÚOptionalÚUnion)ÚRequirement)ÚInvalidSpecifierÚSpecifierSet)ÚNormalizedName)ÚLegacyVersionÚVersion)ÚDIRECT_URL_METADATA_NAMEÚ	DirectUrlÚDirectUrlValidationError)Ústdlib_pkgs)Úegg_link_path_from_sys_path)Úurl_to_path)ÚProtocolc                   @   sB   e Zd Zedefdd„ƒZedefdd„ƒZedefdd„ƒZdS )	ÚBaseEntryPointÚreturnc                 C   ó   t ƒ ‚©N©ÚNotImplementedError©Úself© r    úd/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/pip/_internal/metadata/base.pyÚname+   ó   zBaseEntryPoint.namec                 C   r   r   r   r   r    r    r!   Úvalue/   r#   zBaseEntryPoint.valuec                 C   r   r   r   r   r    r    r!   Úgroup3   r#   zBaseEntryPoint.groupN)Ú__name__Ú
__module__Ú__qualname__ÚpropertyÚstrr"   r$   r%   r    r    r    r!   r   *   s    r   c                   @   s   e Zd Zdefdd„Zdefdd„Zedee fdd„ƒZedee fdd	„ƒZ	edee fd
d„ƒZ
edefdd„ƒZedefdd„ƒZedee fdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZdedefdd„Zdee fdd „Zedejjfd!d"„ƒZedee fd#d$„ƒZedefd%d&„ƒZ ede!fd'd(„ƒZ"d0d*e#e dee$ fd+d,„Z%dee fd-d.„Z&d/S )1ÚBaseDistributionr   c                 C   s   | j › d| j› d| j› d�S )Nú z (ú))Úraw_nameÚversionÚlocationr   r    r    r!   Ú__repr__9   s   zBaseDistribution.__repr__c                 C   s   | j › d| j› �S )Nr,   )r.   r/   r   r    r    r!   Ú__str__<   s   zBaseDistribution.__str__c                 C   r   )aÐ  Where the distribution is loaded from.

        A string value is not necessarily a filesystem path, since distributions
        can be loaded from other sources, e.g. arbitrary zip archives. ``None``
        means the distribution is created in-memory.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and files in the distribution.
        r   r   r    r    r!   r0   ?   s   zBaseDistribution.locationc                 C   s8   | j }|r| ¡ rt|jƒS dS t| jƒ}|r| jS dS )zÉThe project location for editable distributions.

        This is the directory where pyproject.toml or setup.py is located.
        None if the distribution is not installed in editable mode.
        N)Ú
direct_urlZis_local_editabler   Úurlr   r.   r0   )r   r3   Zegg_link_pathr    r    r!   Úeditable_project_locationM   s   
	
ûz*BaseDistribution.editable_project_locationc                 C   r   )a'  Location of the .[egg|dist]-info directory.

        Similarly to ``location``, a string value is not necessarily a
        filesystem path. ``None`` means the distribution is created in-memory.

        For a modern .dist-info installation on disk, this should be something
        like ``{location}/{raw_name}-{version}.dist-info``.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and other files in the distribution.
        r   r   r    r    r!   Úinfo_directoryc   s   zBaseDistribution.info_directoryc                 C   r   r   r   r   r    r    r!   Úcanonical_names   r#   zBaseDistribution.canonical_namec                 C   r   r   r   r   r    r    r!   r/   w   r#   zBaseDistribution.versionc              
   C   sr   z|   t¡}W n
 ty   Y dS w zt |¡W S  ttjtfy8 } zt	 
dt| j|¡ W Y d}~dS d}~ww )z¬Obtain a DirectUrl from this distribution.

        Returns None if the distribution has no `direct_url.json` metadata,
        or if `direct_url.json` is invalid.
        NzError parsing %s for %s: %s)Ú	read_textr   ÚFileNotFoundErrorr   Z	from_jsonÚUnicodeDecodeErrorÚjsonÚJSONDecodeErrorr   ÚloggerÚwarningr7   )r   ÚcontentÚer    r    r!   r3   {   s*   ÿýü€õzBaseDistribution.direct_urlc                 C   r   r   r   r   r    r    r!   Ú	installer•   r#   zBaseDistribution.installerc                 C   s
   t | jƒS r   )Úboolr5   r   r    r    r!   Úeditable™   s   
zBaseDistribution.editablec                 C   r   r   r   r   r    r    r!   Úlocal�   r#   zBaseDistribution.localc                 C   r   r   r   r   r    r    r!   Úin_usersite¡   r#   zBaseDistribution.in_usersitec                 C   r   r   r   r   r    r    r!   Úin_site_packages¥   r#   z!BaseDistribution.in_site_packagesr"   c                 C   r   )zªRead a file in the .dist-info (or .egg-info) directory.

        Should raise ``FileNotFoundError`` if ``name`` does not exist in the
        metadata directory.
        r   ©r   r"   r    r    r!   r8   ©   ó   zBaseDistribution.read_textc                 C   r   r   r   r   r    r    r!   Úiter_entry_points±   ó   z"BaseDistribution.iter_entry_pointsc                 C   r   )z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.r   r   r    r    r!   Úmetadata´   s   zBaseDistribution.metadatac                 C   s   | j  d¡S )zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rK   Úgetr   r    r    r!   Úmetadata_version¹   s   z!BaseDistribution.metadata_versionc                 C   s   | j  d| j¡S )z*Value of "Name:" in distribution metadata.ÚName)rK   rL   r7   r   r    r    r!   r.   ¾   s   zBaseDistribution.raw_namec              
   C   sl   | j  d¡}|du rtƒ S z	tt|ƒƒ}W |S  ty5 } zd}t || j|¡ tƒ W  Y d}~S d}~ww )z±Value of "Requires-Python:" in distribution metadata.

        If the key does not exist or contains an invalid value, an empty
        SpecifierSet should be returned.
        zRequires-PythonNz-Package %r has an invalid Requires-Python: %s)rK   rL   r   r*   r   r=   r>   r.   )r   r$   Úspecr@   Úmessager    r    r!   Úrequires_pythonÅ   s   ü€ýz BaseDistribution.requires_pythonr    Úextrasc                 C   r   )z®Dependencies of this distribution.

        For modern .dist-info distributions, this is the collection of
        "Requires-Dist:" entries in distribution metadata.
        r   )r   rR   r    r    r!   Úiter_dependenciesØ   rH   z"BaseDistribution.iter_dependenciesc                 C   r   )z²Extras provided by this distribution.

        For modern .dist-info distributions, this is the collection of
        "Provides-Extra:" entries in distribution metadata.
        r   r   r    r    r!   Úiter_provided_extrasà   rH   z%BaseDistribution.iter_provided_extrasN)r    )'r&   r'   r(   r*   r1   r2   r)   r	   r0   r5   r6   r   r7   ÚDistributionVersionr/   r   r3   rA   rB   rC   rD   rE   rF   r8   r   r   rI   ÚemailrP   ÚMessagerK   rM   r.   r   rQ   r   r   rS   rT   r    r    r    r!   r+   8   sJ    r+   c                   @   s¬   e Zd ZdZeddd„ƒZedeee  dd fdd„ƒZ	deded	 fd
d„Z
ded	 fdd„Zded	 fdd„Zdedddfdedee dedededee fdd„ZdS )ÚBaseEnvironmentz6An environment containing distributions to introspect.r   c                 C   r   r   r   )Úclsr    r    r!   Údefaultì   r#   zBaseEnvironment.defaultÚpathsc                 C   r   r   r   )rY   r[   r    r    r!   Ú
from_pathsð   r#   zBaseEnvironment.from_pathsr"   r+   c                 C   r   )z=Given a requirement name, return the installed distributions.r   rG   r    r    r!   Úget_distributionô   r#   z BaseEnvironment.get_distributionc                 C   r   )a  Iterate through installed distributions.

        This function should be implemented by subclass, but never called
        directly. Use the public ``iter_distribution()`` instead, which
        implements additional logic to make sure the distributions are valid.
        r   r   r    r    r!   Ú_iter_distributionsø   s   z#BaseEnvironment._iter_distributionsc                 c   sF   � |   ¡ D ]}tjd|jtjd�}|st d|j|j¡ q|V  qdS )z(Iterate through installed distributions.z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$)Úflagsz%Ignoring invalid distribution %s (%s)N)r^   ÚreÚmatchr7   Ú
IGNORECASEr=   r>   r0   )r   ÚdistZproject_name_validr    r    r!   Úiter_distributions  s    €ýýïz"BaseEnvironment.iter_distributionsTFÚ
local_onlyÚskipÚinclude_editablesÚeditables_onlyÚ	user_onlyc                    sb   |   ¡ }|rdd„ |D ƒ}|sdd„ |D ƒ}|rdd„ |D ƒ}|r(dd„ |D ƒ}‡ fdd„|D ƒS )a  Return a list of installed distributions.

        :param local_only: If True (default), only return installations
        local to the current virtualenv, if in a virtualenv.
        :param skip: An iterable of canonicalized project names to ignore;
            defaults to ``stdlib_pkgs``.
        :param include_editables: If False, don't report editables.
        :param editables_only: If True, only report editables.
        :param user_only: If True, only report installations in the user
        site directory.
        c                 s   ó   � | ]}|j r|V  qd S r   )rD   ©Ú.0Údr    r    r!   Ú	<genexpr>+  ó   € z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>c                 s   s   � | ]}|j s|V  qd S r   ©rC   rk   r    r    r!   rn   -  ro   c                 s   rj   r   rp   rk   r    r    r!   rn   /  ro   c                 s   rj   r   )rE   rk   r    r    r!   rn   1  ro   c                 3   s   � | ]
}|j ˆ vr|V  qd S r   )r7   rk   ©rf   r    r!   rn   2  s   € )rd   )r   re   rf   rg   rh   ri   Úitr    rq   r!   Úiter_installed_distributions  s   z,BaseEnvironment.iter_installed_distributionsN)r   rX   )r&   r'   r(   Ú__doc__ÚclassmethodrZ   r	   r   r*   r\   r]   r   r^   rd   r   rB   r   r+   rs   r    r    r    r!   rX   é   s6    	úþýüûúùrX   c                   @   s&   e Zd ZU eed< dejfdd„ZdS )ÚWheelr0   r   c                 C   r   r   r   r   r    r    r!   Ú
as_zipfile8  rJ   zWheel.as_zipfileN)r&   r'   r(   r*   Ú__annotations__ÚzipfileÚZipFilerw   r    r    r    r!   rv   5  s   
 rv   c                   @   s.   e Zd Zdeddfdd„Zdejfdd„ZdS )ÚFilesystemWheelr0   r   Nc                 C   s
   || _ d S r   )r0   )r   r0   r    r    r!   Ú__init__=  s   
zFilesystemWheel.__init__c                 C   ó   t j| jdd�S ©NT)Ú
allowZip64)ry   rz   r0   r   r    r    r!   rw   @  ó   zFilesystemWheel.as_zipfile)r&   r'   r(   r*   r|   ry   rz   rw   r    r    r    r!   r{   <  s    r{   c                   @   s6   e Zd Zdedee ddfdd„Zdejfdd„Z	dS )	ÚMemoryWheelr0   Ústreamr   Nc                 C   s   || _ || _d S r   )r0   r‚   )r   r0   r‚   r    r    r!   r|   E  s   
zMemoryWheel.__init__c                 C   r}   r~   )ry   rz   r‚   r   r    r    r!   rw   I  r€   zMemoryWheel.as_zipfile)
r&   r'   r(   r*   r   Úbytesr|   ry   rz   rw   r    r    r    r!   r�   D  s    r�   )0Úemail.messagerV   r;   Úloggingr`   ry   Útypingr   r   r   r   r   r   r   r	   r
   Z"pip._vendor.packaging.requirementsr   Z pip._vendor.packaging.specifiersr   r   Úpip._vendor.packaging.utilsr   Zpip._vendor.packaging.versionr   r   Zpip._internal.models.direct_urlr   r   r   Úpip._internal.utils.compatr   Úpip._internal.utils.egg_linkr   Zpip._internal.utils.urlsr   r   ÚobjectrU   Ú	getLoggerr&   r=   r   r+   rX   rv   r{   r�   r    r    r    r!   Ú<module>   s4    ,
 2L