a
    <BìjLc  ã                   @  sÄ  d dl mZ d dlZd dlZd dlZ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 d dl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mZ d dl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.m/Z/ d dl0m1Z1 ddl2m3Z3 ee4ej5f Z6e 7e8¡Z9G dd„ deƒZ:ddddœdd„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?ƒZAdS )%é    )ÚannotationsN)Ú
CollectionÚ	ContainerÚIterableÚIterator)ÚIOÚAnyÚ
NamedTupleÚProtocolÚUnion)ÚRequirement)ÚInvalidSpecifierÚSpecifierSet)ÚNormalizedNameÚcanonicalize_name)ÚVersion)ÚNoneMetadataError)Úsite_packagesÚ	user_site)ÚDIRECT_URL_METADATA_NAMEÚ	DirectUrlÚDirectUrlValidationError)Ústdlib_pkgs)Úegg_link_path_from_sys_path)Úis_localÚnormalize_path)Úurl_to_pathé   )Úmsg_to_jsonc                   @  sB   e Zd Zeddœdd„ƒZeddœdd„ƒZeddœdd„ƒZd	S )
ÚBaseEntryPointÚstr©Úreturnc                 C  s
   t ƒ ‚d S ©N©ÚNotImplementedError©Úself© r(   úZ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_internal/metadata/base.pyÚname-   s    zBaseEntryPoint.namec                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Úvalue1   s    zBaseEntryPoint.valuec                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Úgroup5   s    zBaseEntryPoint.groupN)Ú__name__Ú
__module__Ú__qualname__Úpropertyr*   r+   r,   r(   r(   r(   r)   r   ,   s   r   ztuple[str, ...]r    )ÚentryÚinfor"   c                 C  s\   | rD| d dkrD|r |d dkr*|d7 }n|dd… }| dd… } q t tjg |¢| ¢R Ž ƒS )aì  Convert a legacy installed-files.txt path into modern RECORD path.

    The legacy format stores paths relative to the info directory, while the
    modern format stores paths relative to the package root, e.g. the
    site-packages directory.

    :param entry: Path parts of the installed-files.txt entry.
    :param info: Path parts of the egg-info directory relative to package root.
    :returns: The converted entry.

    For best compatibility with symlinks, this does not use ``abspath()`` or
    ``Path.resolve()``, but tries to work with path parts:

    1. While ``entry`` starts with ``..``, remove the equal amounts of parts
       from ``info``; if ``info`` is empty, start appending ``..`` instead.
    2. Join the two directly.
    r   ú..éÿÿÿÿ)r3   Nr   ©r    ÚpathlibÚPath)r1   r2   r(   r(   r)   Ú_convert_installed_files_path:   s    
r8   c                   @  s&   e Zd ZU ded< ded< ded< dS )ÚRequiresEntryr    ÚrequirementÚextraÚmarkerN)r-   r.   r/   Ú__annotations__r(   r(   r(   r)   r9   X   s   
r9   c                   @  sø  e Zd Zedd dœdd„ƒZedddd dœdd„ƒZed	dd d
œdd„ƒZddœdd„Zddœdd„Ze	ddœdd„ƒZ
e	ddœdd„ƒZe	ddœdd„ƒZe	ddœdd„ƒZe	ddœdd„ƒZe	ddœdd„ƒZe	ddœd d!„ƒZe	ddœd"d#„ƒZe	d$dœd%d&„ƒZe	d'dœd(d)„ƒZe	ddœd*d+„ƒZe	ddœd,d-„ƒZe	d.dœd/d0„ƒZe	ddœd1d2„ƒZe	ddœd3d4„ƒZe	ddœd5d6„ƒZe	ddœd7d8„ƒZe	ddœd9d:„ƒZe	ddœd;d<„ƒZd=dd>œd?d@„ZdAdœdBdC„Zd=dd>œdDdE„ZdFdœdGdH„Z dIdœdJdK„Z!e"j#dIdœdLdM„ƒZ$e	dNdœdOdP„ƒZ%e	ddœdQdR„ƒZ&e	ddœdSdT„ƒZ'e	dUdœdVdW„ƒZ(dwdYdZd[œd\d]„Z)d^dœd_d`„Z*dadœdbdc„Z+dddœdedf„Z,dddœdgdh„Z-dddœdidj„Z.dkdœdldm„Z/d^dœdndo„Z0d^dœdpdq„Z1dIdrdsœdtdu„Z2dvS )xÚBaseDistributionr    )Ú	directoryr"   c                 C  s
   t ƒ ‚dS )z‡Load the distribution from a metadata directory.

        :param directory: Path to a metadata directory, e.g. ``.dist-info``.
        Nr$   )Úclsr?   r(   r(   r)   Úfrom_directory_   s    zBaseDistribution.from_directoryÚbytes)Úmetadata_contentsÚfilenameÚproject_namer"   c                 C  s
   t ƒ ‚dS )aÁ  Load the distribution from the contents of a METADATA file.

        This is used to implement PEP 658 by generating a "shallow" dist object that can
        be used for resolution without downloading or building the actual dist yet.

        :param metadata_contents: The contents of a METADATA file.
        :param filename: File name for the dist with this metadata.
        :param project_name: Name of the project this dist represents.
        Nr$   )r@   rC   rD   rE   r(   r(   r)   Úfrom_metadata_file_contentsg   s    z,BaseDistribution.from_metadata_file_contentsÚWheel)Úwheelr*   r"   c                 C  s
   t ƒ ‚dS )a  Load the distribution from a given wheel.

        :param wheel: A concrete wheel definition.
        :param name: File name of the wheel.

        :raises InvalidWheel: Whenever loading of the wheel causes a
            :py:exc:`zipfile.BadZipFile` exception to be thrown.
        :raises UnsupportedWheel: If the wheel is a valid zip, but malformed
            internally.
        Nr$   )r@   rH   r*   r(   r(   r)   Ú
from_wheely   s    zBaseDistribution.from_wheelr!   c                 C  s   | j › d| j› d| j› d�S )Nú z (ú))Úraw_nameÚraw_versionÚlocationr&   r(   r(   r)   Ú__repr__‡   s    zBaseDistribution.__repr__c                 C  s   | j › d| j› �S )NrJ   )rL   rM   r&   r(   r(   r)   Ú__str__Š   s    zBaseDistribution.__str__z
str | Nonec                 C  s
   t ƒ ‚dS )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.
        Nr$   r&   r(   r(   r)   rN   �   s    zBaseDistribution.locationc                 C  s6   | j }|r| ¡ r2t|jƒS nt| jƒ}|r2| 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   rL   rN   )r'   rQ   Úegg_link_pathr(   r(   r)   Úeditable_project_location›   s    
z*BaseDistribution.editable_project_locationc                 C  s
   t ƒ ‚dS )a’  The distribution's "installed" location.

        This should generally be a ``site-packages`` directory. This is
        usually ``dist.location``, except for legacy develop-installed packages,
        where ``dist.location`` is the source code location, and this is where
        the ``.egg-link`` file is.

        The returned location is normalized (in particular, with symlinks removed).
        Nr$   r&   r(   r(   r)   Úinstalled_location±   s    z#BaseDistribution.installed_locationc                 C  s
   t ƒ ‚dS )a/  Location of the .[egg|dist]-info directory or file.

        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.
        Nr$   r&   r(   r(   r)   Úinfo_location¾   s    zBaseDistribution.info_locationÚboolc                 C  s   | j }|sdS t |¡ ¡ S )a  Whether this distribution is installed with legacy distutils format.

        A distribution installed with "raw" distutils not patched by setuptools
        uses one single file at ``info_location`` to store metadata. We need to
        treat this specially on uninstallation.
        F)rV   r6   r7   Úis_file©r'   rV   r(   r(   r)   Úinstalled_by_distutilsÎ   s    z'BaseDistribution.installed_by_distutilsc                 C  s   | j }|sdS t |¡jdkS )z¦Whether this distribution is installed as an egg.

        This usually indicates the distribution was installed by (older versions
        of) easy_install.
        Fz.egg)rN   r6   r7   Úsuffix©r'   rN   r(   r(   r)   Úinstalled_as_eggÛ   s    z!BaseDistribution.installed_as_eggc                 C  s*   | j }|sdS | d¡sdS t |¡ ¡ S )aÙ  Whether this distribution is installed with the ``.egg-info`` format.

        This usually indicates the distribution was installed with setuptools
        with an old pip version or with ``single-version-externally-managed``.

        Note that this ensure the metadata store is a directory. distutils can
        also installs an ``.egg-info``, but as a file, not a directory. This
        property is *False* for that case. Also see ``installed_by_distutils``.
        Fz	.egg-info©rV   Úendswithr6   r7   Úis_dirrY   r(   r(   r)   Ú"installed_with_setuptools_egg_infoé   s    
z3BaseDistribution.installed_with_setuptools_egg_infoc                 C  s*   | j }|sdS | d¡sdS t |¡ ¡ S )aa  Whether this distribution is installed with the "modern format".

        This indicates a "modern" installation, e.g. storing metadata in the
        ``.dist-info`` directory. This applies to installations made by
        setuptools (but through pip, not directly), or anything using the
        standardized build backend interface (PEP 517).
        Fz
.dist-infor^   rY   r(   r(   r)   Úinstalled_with_dist_infoû   s    	
z)BaseDistribution.installed_with_dist_infor   c                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Úcanonical_name  s    zBaseDistribution.canonical_namer   c                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Úversion  s    zBaseDistribution.versionc                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   rM     s    zBaseDistribution.raw_versionc                 C  s   | j  dd¡S )z”Convert a project name to its setuptools-compatible filename.

        This is a copy of ``pkg_resources.to_filename()`` for compatibility.
        ú-Ú_)rL   Úreplacer&   r(   r(   r)   Úsetuptools_filename  s    z$BaseDistribution.setuptools_filenamezDirectUrl | Nonec              
   C  sv   z|   t¡}W n ty"   Y dS 0 zt |¡W S  ttjtfyp } z t	 
dt| j|¡ W Y d}~dS d}~0 0 dS )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   Ú	from_jsonÚUnicodeDecodeErrorÚjsonÚJSONDecodeErrorr   ÚloggerÚwarningrc   )r'   ÚcontentÚer(   r(   r)   rQ     s$    ýüzBaseDistribution.direct_urlc              
   C  sP   z|   d¡}W n tttfy(   Y dS 0 | ¡ D ]}| ¡ }|r2|  S q2dS )NÚ	INSTALLERÚ )ri   ÚOSErrorÚ
ValueErrorr   Ú
splitlinesÚstrip)r'   Zinstaller_textÚlineZcleaned_liner(   r(   r)   Ú	installer9  s    
zBaseDistribution.installerc                 C  s
   |   d¡S )NÚ	REQUESTED)rX   r&   r(   r(   r)   Ú	requestedE  s    zBaseDistribution.requestedc                 C  s
   t | jƒS r#   )rW   rT   r&   r(   r(   r)   ÚeditableI  s    zBaseDistribution.editablec                 C  s   | j du rdS t| j ƒS )z|If distribution is installed in the current virtual environment.

        Always True if we're not in a virtualenv.
        NF)rU   r   r&   r(   r(   r)   ÚlocalM  s    
zBaseDistribution.localc                 C  s&   | j d u std u rdS | j  ttƒ¡S ©NF)rU   r   Ú
startswithr   r&   r(   r(   r)   Úin_usersiteW  s    zBaseDistribution.in_usersitec                 C  s&   | j d u std u rdS | j  ttƒ¡S r   )rU   r   r€   r   r&   r(   r(   r)   Úin_site_packages]  s    z!BaseDistribution.in_site_packagesÚInfoPath)Úpathr"   c                 C  s
   t ƒ ‚dS )z7Check whether an entry in the info directory is a file.Nr$   ©r'   r„   r(   r(   r)   rX   c  s    zBaseDistribution.is_filezIterator[str]c                 C  s
   t ƒ ‚dS )zÕFind distutils 'scripts' entries metadata.

        If 'scripts' is supplied in ``setup.py``, distutils records those in the
        installed distribution's ``scripts`` directory, a file for each script.
        Nr$   r&   r(   r(   r)   Úiter_distutils_script_namesg  s    z,BaseDistribution.iter_distutils_script_namesc                 C  s
   t ƒ ‚dS )zçRead a file in the info directory.

        :raise FileNotFoundError: If ``path`` does not exist in the directory.
        :raise NoneMetadataError: If ``path`` exists in the info directory, but
            cannot be read.
        Nr$   r…   r(   r(   r)   ri   o  s    zBaseDistribution.read_textzIterable[BaseEntryPoint]c                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Úiter_entry_pointsx  s    z"BaseDistribution.iter_entry_pointszemail.message.Messagec                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Ú_metadata_impl{  s    zBaseDistribution._metadata_implc                 C  s   |   ¡ }|  |¡ |S )a  Metadata of distribution parsed from e.g. METADATA or PKG-INFO.

        This should return an empty message if the metadata file is unavailable.

        :raises NoneMetadataError: If the metadata file is available, but does
            not contain valid metadata.
        )rˆ   Ú_add_egg_info_requires)r'   Úmetadatar(   r(   r)   rŠ   ~  s    	
zBaseDistribution.metadatazdict[str, Any]c                 C  s
   t | jƒS )a  PEP 566 compliant JSON-serializable representation of METADATA or PKG-INFO.

        This should return an empty dict if the metadata file is unavailable.

        :raises NoneMetadataError: If the metadata file is available, but does
            not contain valid metadata.
        )r   rŠ   r&   r(   r(   r)   Úmetadata_dict‹  s    	zBaseDistribution.metadata_dictc                 C  s   | j  d¡S )zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rŠ   Ú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)rŠ   rŒ   rc   r&   r(   r(   r)   rL   ›  s    zBaseDistribution.raw_namer   c              
   C  sn   | j  d¡}|du rtƒ S ztt|ƒƒ}W n> tyh } z&d}t || j|¡ tƒ W  Y d}~S d}~0 0 |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.
        zRequires-PythonNz-Package %r has an invalid Requires-Python: %s)rŠ   rŒ   r   r    r   ro   rp   rL   )r'   r+   Úspecrr   Úmessager(   r(   r)   Úrequires_python¢  s    z BaseDistribution.requires_pythonr(   zCollection[str]zIterable[Requirement])Úextrasr"   c                 C  s
   t ƒ ‚dS )z®Dependencies of this distribution.

        For modern .dist-info distributions, this is the collection of
        "Requires-Dist:" entries in distribution metadata.
        Nr$   )r'   r’   r(   r(   r)   Úiter_dependenciesµ  s    z"BaseDistribution.iter_dependencieszIterable[str]c                 C  s   | j  dg ¡S )zRaw Requires-Dist metadata.úRequires-Dist)rŠ   Úget_allr&   r(   r(   r)   Úiter_raw_dependencies½  s    z&BaseDistribution.iter_raw_dependencieszIterable[NormalizedName]c                 C  s
   t ƒ ‚dS )aj  Extras provided by this distribution.

        For modern .dist-info distributions, this is the collection of
        "Provides-Extra:" entries in distribution metadata.

        The return value of this function is expected to be normalised names,
        per PEP 685, with the returned value being handled appropriately by
        `iter_dependencies`.
        Nr$   r&   r(   r(   r)   Úiter_provided_extrasÁ  s    
z%BaseDistribution.iter_provided_extraszIterator[str] | Nonec                 C  s<   z|   d¡}W n ty"   Y d S 0 dd„ t | ¡ ¡D ƒS )NÚRECORDc                 s  s    | ]}t t |d  ¡ƒV  qdS )r   Nr5   )Ú.0Úrowr(   r(   r)   Ú	<genexpr>Ó  ó    zFBaseDistribution._iter_declared_entries_from_record.<locals>.<genexpr>)ri   rj   ÚcsvÚreaderrw   )r'   Útextr(   r(   r)   Ú"_iter_declared_entries_from_recordÍ  s
    z3BaseDistribution._iter_declared_entries_from_recordc                   s¢   z|   d¡}W n ty"   Y d S 0 dd„ |jdd�D ƒ}| j}| j}|d u sV|d u rZ|S zt |¡ |¡‰ W n ty„   | Y S 0 ˆ j	s�|S ‡ fdd„|D ƒS )Nzinstalled-files.txtc                 s  s   | ]}|r|V  qd S r#   r(   ©r™   Úpr(   r(   r)   r›   Ú  rœ   zFBaseDistribution._iter_declared_entries_from_legacy.<locals>.<genexpr>F)Úkeependsc                 3  s"   | ]}t t |¡jˆ jƒV  qd S r#   )r8   r6   r7   Úpartsr¡   ©Zinfo_relr(   r)   r›   å  s   ÿ)
ri   rj   rw   rN   rV   r6   r7   Úrelative_torv   r¤   )r'   rŸ   ÚpathsÚrootr2   r(   r¥   r)   Ú"_iter_declared_entries_from_legacyÕ  s$    

þz3BaseDistribution._iter_declared_entries_from_legacyc                 C  s   |   ¡ p|  ¡ S )aò  Iterate through file entries declared in this distribution.

        For modern .dist-info distributions, this is the files listed in the
        ``RECORD`` metadata file. For legacy setuptools distributions, this
        comes from ``installed-files.txt``, with entries normalized to be
        compatible with the format used by ``RECORD``.

        :return: An iterator for listed entries, or None if the distribution
            contains neither ``RECORD`` nor ``installed-files.txt``.
        )r    r©   r&   r(   r(   r)   Úiter_declared_entriesê  s    þz&BaseDistribution.iter_declared_entrieszIterator[RequiresEntry]c                 c  s’   z|   d¡}W n ty"   Y dS 0 d }}| ¡ D ]X}| ¡ }|r4| d¡rPq4| d¡r|| d¡r|| d¡ d¡\}}}q4t|||d	�V  q4dS )
aö  Parse a ``requires.txt`` in an egg-info directory.

        This is an INI-ish format where an egg-info stores dependencies. A
        section name describes extra other environment markers, while each entry
        is an arbitrary string (not a key-value pair) representing a dependency
        as a requirement string (no markers).

        There is a construct in ``importlib.metadata`` called ``Sectioned`` that
        does mostly the same, but the format is currently considered private.
        zrequires.txtNrt   ú#ú[ú]z[]ú:)r:   r;   r<   )ri   rj   rw   rx   r€   r_   Ú	partitionr9   )r'   rq   r;   r<   ry   rf   r(   r(   r)   Ú_iter_requires_txt_entriesú  s    z+BaseDistribution._iter_requires_txt_entriesc                 c  s<   dh}|   ¡ D ](}t|jƒ}||v r&q| |¡ |V  qdS )z'Get extras from the egg-info directory.rt   N)r°   r   r;   Úadd)r'   Zknown_extrasr1   r;   r(   r(   r)   Ú_iter_egg_info_extras  s    

z&BaseDistribution._iter_egg_info_extrasc                 c  s€   |   ¡ D ]r}t|jƒ}|r6|jr6d|j› d|› d�}n$|rHd|› d�}n|jrV|j}nd}|rr|j› d|› �V  q|jV  qdS )a‰  Get distribution dependencies from the egg-info directory.

        To ease parsing, this converts a legacy dependency entry into a PEP 508
        requirement string. Like ``_iter_requires_txt_entries()``, there is code
        in ``importlib.metadata`` that does mostly the same, but not do exactly
        what we need.

        Namely, ``importlib.metadata`` does not normalize the extra name before
        putting it into the requirement string, which causes marker comparison
        to fail because the dist-info format do normalize. This is consistent in
        all currently available PEP 517 backends, although not standardized.
        ú(z) and extra == "ú"z
extra == "rt   z ; N)r°   r   r;   r<   r:   )r'   r1   r;   r<   r(   r(   r)   Ú_iter_egg_info_dependencies  s    

z,BaseDistribution._iter_egg_info_dependenciesÚNone)rŠ   r"   c                 C  sD   |  d¡s |  ¡ D ]}||d< q|  d¡s@|  ¡ D ]}||d< q2dS )z6Add egg-info requires.txt information to the metadata.r”   zProvides-ExtraN)r•   rµ   r²   )r'   rŠ   Údepr;   r(   r(   r)   r‰   9  s    


z'BaseDistribution._add_egg_info_requiresN)r(   )3r-   r.   r/   ÚclassmethodrA   rF   rI   rO   rP   r0   rN   rT   rU   rV   rZ   r]   ra   rb   rc   rd   rM   rh   rQ   rz   r|   r}   r~   r�   r‚   rX   r†   ri   r‡   rˆ   Ú	functoolsÚcached_propertyrŠ   r‹   r�   rL   r‘   r“   r–   r—   r    r©   rª   r°   r²   rµ   r‰   r(   r(   r(   r)   r>   ^   sŽ   		

r>   c                   @  s†   e Zd ZdZed dœdd„ƒZedd dœdd„ƒZd	d
dœdd„Zddœdd„Zddœdd„Z	de
dddfdddddddœdd„ZdS )ÚBaseEnvironmentz6An environment containing distributions to introspect.r!   c                 C  s
   t ƒ ‚d S r#   r$   )r@   r(   r(   r)   ÚdefaultF  s    zBaseEnvironment.defaultzlist[str] | None)r§   r"   c                 C  s
   t ƒ ‚d S r#   r$   )r@   r§   r(   r(   r)   Ú
from_pathsJ  s    zBaseEnvironment.from_pathsr    zBaseDistribution | None)r*   r"   c                 C  s
   t ƒ ‚dS )z«Given a requirement name, return the installed distributions.

        The name may not be normalized. The implementation must canonicalize
        it for lookup.
        Nr$   )r'   r*   r(   r(   r)   Úget_distributionN  s    z BaseEnvironment.get_distributionzIterator[BaseDistribution]c                 C  s
   t ƒ ‚dS )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.
        Nr$   r&   r(   r(   r)   Ú_iter_distributionsV  s    z#BaseEnvironment._iter_distributionsc                 c  sD   |   ¡ D ]6}tjd|jtjd�}|s8t d|j|j¡ q|V  qdS )zBIterate through all installed distributions without any filtering.z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$)Úflagsz%Ignoring invalid distribution %s (%s)N)r¿   ÚreÚmatchrc   Ú
IGNORECASEro   rp   rN   )r'   ÚdistZproject_name_validr(   r(   r)   Úiter_all_distributions_  s    ýýz&BaseEnvironment.iter_all_distributionsTFrW   zContainer[str])Ú
local_onlyÚskipÚinclude_editablesÚeditables_onlyÚ	user_onlyr"   c                   sb   |   ¡ }|rdd„ |D ƒ}|s,dd„ |D ƒ}|r>dd„ |D ƒ}|rPdd„ |D ƒ}‡ fdd„|D ƒS )a/  Return a list of installed distributions.

        This is based on ``iter_all_distributions()`` with additional filtering
        options. Note that ``iter_installed_distributions()`` without arguments
        is *not* equal to ``iter_all_distributions()``, since some of the
        configurations exclude packages by default.

        :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  s   | ]}|j r|V  qd S r#   )r~   ©r™   Údr(   r(   r)   r›   Ž  rœ   z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>c                 s  s   | ]}|j s|V  qd S r#   ©r}   rË   r(   r(   r)   r›   �  rœ   c                 s  s   | ]}|j r|V  qd S r#   rÍ   rË   r(   r(   r)   r›   ’  rœ   c                 s  s   | ]}|j r|V  qd S r#   )r�   rË   r(   r(   r)   r›   ”  rœ   c                 3  s   | ]}|j ˆ vr|V  qd S r#   )rc   rË   ©rÇ   r(   r)   r›   •  rœ   )rÅ   )r'   rÆ   rÇ   rÈ   rÉ   rÊ   Úitr(   rÎ   r)   Úiter_installed_distributionst  s    z,BaseEnvironment.iter_installed_distributionsN)r-   r.   r/   Ú__doc__r¸   r¼   r½   r¾   r¿   rÅ   r   rÐ   r(   r(   r(   r)   r»   C  s   	úr»   c                   @  s$   e Zd ZU ded< ddœdd„ZdS )rG   r    rN   úzipfile.ZipFiler!   c                 C  s
   t ƒ ‚d S r#   r$   r&   r(   r(   r)   Ú
as_zipfile›  s    zWheel.as_zipfileN)r-   r.   r/   r=   rÓ   r(   r(   r(   r)   rG   ˜  s   
rG   c                   @  s*   e Zd Zdddœdd„Zddœdd	„Zd
S )ÚFilesystemWheelr    r¶   )rN   r"   c                 C  s
   || _ d S r#   )rN   r\   r(   r(   r)   Ú__init__   s    zFilesystemWheel.__init__rÒ   r!   c                 C  s   t j| jdd�S ©NT)Ú
allowZip64)ÚzipfileÚZipFilerN   r&   r(   r(   r)   rÓ   £  s    zFilesystemWheel.as_zipfileN©r-   r.   r/   rÕ   rÓ   r(   r(   r(   r)   rÔ   Ÿ  s   rÔ   c                   @  s,   e Zd Zddddœdd„Zddœd	d
„ZdS )ÚMemoryWheelr    z	IO[bytes]r¶   )rN   Ústreamr"   c                 C  s   || _ || _d S r#   )rN   rÜ   )r'   rN   rÜ   r(   r(   r)   rÕ   ¨  s    zMemoryWheel.__init__rÒ   r!   c                 C  s   t j| jdd�S rÖ   )rØ   rÙ   rÜ   r&   r(   r(   r)   rÓ   ¬  s    zMemoryWheel.as_zipfileNrÚ   r(   r(   r(   r)   rÛ   §  s   rÛ   )BÚ
__future__r   r�   Úemail.messageÚemailr¹   rm   Úloggingr6   rÁ   rØ   Úcollections.abcr   r   r   r   Útypingr   r   r	   r
   r   Z"pip._vendor.packaging.requirementsr   Z pip._vendor.packaging.specifiersr   r   Zpip._vendor.packaging.utilsr   r   Úpip._vendor.packaging.versionr   Úpip._internal.exceptionsr   Úpip._internal.locationsr   r   Úpip._internal.models.direct_urlr   r   r   Úpip._internal.utils.compatr   Zpip._internal.utils.egg_linkr   Úpip._internal.utils.miscr   r   Úpip._internal.utils.urlsr   Ú_jsonr   r    ÚPurePathrƒ   Ú	getLoggerr-   ro   r   r8   r9   r>   r»   rG   rÔ   rÛ   r(   r(   r(   r)   Ú<module>   sF   
   hU