Current File : //lib/python3.9/site-packages/pip/_internal/metadata/__pycache__/base.cpython-39.pyc
a

[��f_+�@sRddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZmZddlmZmZmZddlmZdd	l m!Z!dd
l"m#Z#er�ddlm$Z$ne%Z$eeefZ&e�'e(�Z)Gdd
�d
e$�Z*Gdd�de$�Z+Gdd�d�Z,Gdd�de$�Z-Gdd�de-�Z.Gdd�de-�Z/dS)�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@sBeZdZeed�dd��Zeed�dd��Zeed�dd��ZdS)	�BaseEntryPoint��returncCs
t��dS�N��NotImplementedError��self�r �?/usr/lib/python3.9/site-packages/pip/_internal/metadata/base.py�name+szBaseEntryPoint.namecCs
t��dSrrrr r r!�value/szBaseEntryPoint.valuecCs
t��dSrrrr r r!�group3szBaseEntryPoint.groupN)�__name__�
__module__�__qualname__�property�strr"r#r$r r r r!r*src@s�eZdZed�dd�Zed�dd�Zeeed�dd��Zeeed�dd	��Z	eeed�d
d��Z
eed�dd
��Zee
d�dd��Zeeed�dd��Zeed�dd��Zeed�dd��Zeed�dd��Zeed�dd��Zeed�dd��Zeed�dd�Zeed�dd �Zeejjd�d!d"��Zeeed�d#d$��Zeed�d%d&��Z ee!d�d'd(��Z"d0e#eee$d*�d+d,�Z%eed�d-d.�Z&d/S)1�BaseDistributionrcCs|j�d|j�d|j�d�S)N� z (�))�raw_name�version�locationrr r r!�__repr__9szBaseDistribution.__repr__cCs|j�d|j��S)Nr+)r-r.rr r r!�__str__<szBaseDistribution.__str__cCs
t��dS)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.
        Nrrr r r!r/?szBaseDistribution.locationcCs6|j}|r|��r2t|j�Snt|j�}|r2|jSdS)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_urlZis_local_editabler�urlrr-r/)rr2Z
egg_link_pathr r r!�editable_project_locationMs
z*BaseDistribution.editable_project_locationcCs
t��dS)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.
        Nrrr r r!�info_directorycszBaseDistribution.info_directorycCs
t��dSrrrr r r!�canonical_namesszBaseDistribution.canonical_namecCs
t��dSrrrr r r!r.wszBaseDistribution.versionc
Csvz|�t�}Wnty"YdS0zt�|�WSttjtfyp}z t	�
dt|j|�WYd}~dSd}~00dS)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.
        NzError parsing %s for %s: %s)�	read_textr�FileNotFoundErrorrZ	from_json�UnicodeDecodeError�jsonZJSONDecodeErrorr�logger�warningr6)rZcontent�er r r!r2{s$��zBaseDistribution.direct_urlcCs
t��dSrrrr r r!�	installer�szBaseDistribution.installercCs
t|j�Sr)�boolr4rr r r!�editable�szBaseDistribution.editablecCs
t��dSrrrr r r!�local�szBaseDistribution.localcCs
t��dSrrrr r r!�in_usersite�szBaseDistribution.in_usersitecCs
t��dSrrrr r r!�in_site_packages�sz!BaseDistribution.in_site_packages�r"rcCs
t��dS)z�Read a file in the .dist-info (or .egg-info) directory.

        Should raise ``FileNotFoundError`` if ``name`` does not exist in the
        metadata directory.
        Nr�rr"r r r!r7�szBaseDistribution.read_textcCs
t��dSrrrr r r!�iter_entry_points�sz"BaseDistribution.iter_entry_pointscCs
t��dS)z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.Nrrr r r!�metadata�szBaseDistribution.metadatacCs|j�d�S)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rG�getrr r r!�metadata_version�sz!BaseDistribution.metadata_versioncCs|j�d|j�S)z*Value of "Name:" in distribution metadata.�Name)rGrHr6rr r r!r-�szBaseDistribution.raw_namec
Csn|j�d�}|durt�Sztt|��}Wn>tyh}z&d}t�||j|�t�WYd}~Sd}~00|S)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.
        zRequires-PythonNz-Package %r has an invalid Requires-Python: %s)rGrHr
r)rr;r<r-)rr#�specr=�messager r r!�requires_python�sz BaseDistribution.requires_pythonr )�extrasrcCs
t��dS)z�Dependencies of this distribution.

        For modern .dist-info distributions, this is the collection of
        "Requires-Dist:" entries in distribution metadata.
        Nr)rrNr r r!�iter_dependencies�sz"BaseDistribution.iter_dependenciescCs
t��dS)z�Extras provided by this distribution.

        For modern .dist-info distributions, this is the collection of
        "Provides-Extra:" entries in distribution metadata.
        Nrrr r r!�iter_provided_extras�sz%BaseDistribution.iter_provided_extrasN)r )'r%r&r'r)r0r1r(r	r/r4r5rr6�DistributionVersionr.rr2r>r?r@rArBrCr7rrrF�emailrLZMessagerGrIr-r
rMrrrOrPr r r r!r*8sH
r*c@s�eZdZdZedd�dd��Zeeeedd�dd��Z	eedd	�d
d�Z
edd�dd
�Zedd�dd�Z
dedddfeeeeeeeed�dd�ZdS)�BaseEnvironmentz6An environment containing distributions to introspect.rcCs
t��dSrr)�clsr r r!�default�szBaseEnvironment.default)�pathsrcCs
t��dSrr)rTrVr r r!�
from_paths�szBaseEnvironment.from_pathsr*rDcCs
t��dS)z=Given a requirement name, return the installed distributions.NrrEr r r!�get_distribution�sz BaseEnvironment.get_distributioncCs
t��dS)aIterate 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.
        Nrrr r r!�_iter_distributions�sz#BaseEnvironment._iter_distributionsccsD|��D]6}tjd|jtjd�}|s8t�d|j|j�q|VqdS)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)rY�re�matchr6�
IGNORECASEr;r<r/)rZdistZproject_name_validr r r!�iter_distributionss��z"BaseEnvironment.iter_distributionsTF)�
local_only�skip�include_editables�editables_only�	user_onlyrcsb|��}|rdd�|D�}|s,dd�|D�}|r>dd�|D�}|rPdd�|D�}�fdd�|D�S)aReturn 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.
        css|]}|jr|VqdSr)rA��.0�dr r r!�	<genexpr>+�z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>css|]}|js|VqdSr�r@rdr r r!rg-rhcss|]}|jr|VqdSrrirdr r r!rg/rhcss|]}|jr|VqdSr)rBrdr r r!rg1rhc3s|]}|j�vr|VqdSr)r6rd�r`r r!rg2rh)r^)rr_r`rarbrc�itr rjr!�iter_installed_distributionssz,BaseEnvironment.iter_installed_distributionsN)r%r&r'�__doc__�classmethodrUr	rr)rWrXrrYr^rr?rr*rlr r r r!rS�s*	��rSc@s&eZdZUeed<ejd�dd�ZdS)�Wheelr/rcCs
t��dSrrrr r r!�
as_zipfile8szWheel.as_zipfileN)r%r&r'r)�__annotations__�zipfile�ZipFilerpr r r r!ro5s
roc@s,eZdZedd�dd�Zejd�dd�ZdS)�FilesystemWheelN)r/rcCs
||_dSr)r/)rr/r r r!�__init__=szFilesystemWheel.__init__rcCstj|jdd�S�NT)Z
allowZip64)rrrsr/rr r r!rp@szFilesystemWheel.as_zipfile)r%r&r'r)rurrrsrpr r r r!rt<srtc@s2eZdZeeedd�dd�Zejd�dd�Z	dS)�MemoryWheelN)r/�streamrcCs||_||_dSr)r/rx)rr/rxr r r!ruEszMemoryWheel.__init__rcCstj|jdd�Srv)rrrsrxrr r r!rpIszMemoryWheel.as_zipfile)
r%r&r'r)r�bytesrurrrsrpr r r r!rwDsrw)0Z
email.messagerRr:Zloggingr[rr�typingrrrrrrrr	r
Z"pip._vendor.packaging.requirementsrZ pip._vendor.packaging.specifiersrr
Zpip._vendor.packaging.utilsrZpip._vendor.packaging.versionrrZpip._internal.models.direct_urlrrrZpip._internal.utils.compatrZpip._internal.utils.egg_linkrZpip._internal.utils.urlsrr�objectrQZ	getLoggerr%r;rr*rSrortrwr r r r!�<module>s2,
2L