o Ec_+@sRddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZddlmZddlmZmZddlmZmZmZddlmZdd l m!Z!dd l"m#Z#erkdd lm$Z$ne%Z$eeefZ&e'e(Z)Gd d d e$Z*Gddde$Z+GdddZ,Gddde$Z-Gddde-Z.Gddde-Z/dS)N) IO TYPE_CHECKING Collection ContainerIterableIteratorListOptionalUnion) Requirement)InvalidSpecifier SpecifierSet)NormalizedName) LegacyVersionVersion)DIRECT_URL_METADATA_NAME DirectUrlDirectUrlValidationError) stdlib_pkgs)egg_link_path_from_sys_path) url_to_path)Protocolc@sBeZdZedefddZedefddZedefddZdS) BaseEntryPointreturncCtNNotImplementedErrorselfr N/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/metadata/base.pyname+zBaseEntryPoint.namecCrrrrr r r!value/r#zBaseEntryPoint.valuecCrrrrr r r!group3r#zBaseEntryPoint.groupN)__name__ __module__ __qualname__propertystrr"r$r%r r r r!r*src@seZdZdefddZdefddZedeefddZedeefdd Z edeefd d Z ede fd d Z ede fddZedeefddZedefddZedefddZedefddZedefddZedefddZdedefddZdeefdd Zedejjfd!d"Zedeefd#d$Zedefd%d&Z ede!fd'd(Z"d0d*e#edee$fd+d,Z%deefd-d.Z&d/S)1BaseDistributionrcCs|jd|jd|jdS)N z ())raw_nameversionlocationrr r r!__repr__9szBaseDistribution.__repr__cCs|jd|jS)Nr,)r.r/rr r r!__str__<szBaseDistribution.__str__cCr)aWhere 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. rrr r r!r0?s zBaseDistribution.locationcCs8|j}|r|rt|jSdSt|j}|r|jSdS)zThe 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_editablerurlrr.r0)rr3Z egg_link_pathr r r!editable_project_locationMs  z*BaseDistribution.editable_project_locationcCr)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. rrr r r!info_directorycszBaseDistribution.info_directorycCrrrrr r r!canonical_namesr#zBaseDistribution.canonical_namecCrrrrr r r!r/wr#zBaseDistribution.versionc Csrz|t}Wn tyYdSwzt|WSttjtfy8}zt dt|j |WYd}~dSd}~ww)zObtain 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_textrFileNotFoundErrorrZ from_jsonUnicodeDecodeErrorjsonZJSONDecodeErrorrloggerwarningr7)rZcontenter r r!r3{s*   zBaseDistribution.direct_urlcCrrrrr r r! installerr#zBaseDistribution.installercCs t|jSr)boolr5rr r r!editables zBaseDistribution.editablecCrrrrr r r!localr#zBaseDistribution.localcCrrrrr r r! in_usersiter#zBaseDistribution.in_usersitecCrrrrr r r!in_site_packagesr#z!BaseDistribution.in_site_packagesr"cCr)zRead a file in the .dist-info (or .egg-info) directory. Should raise ``FileNotFoundError`` if ``name`` does not exist in the metadata directory. rrr"r r r!r8zBaseDistribution.read_textcCrrrrr r r!iter_entry_pointsz"BaseDistribution.iter_entry_pointscCr)z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.rrr r r!metadataszBaseDistribution.metadatacCs |jdS)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rIgetrr r r!metadata_versions z!BaseDistribution.metadata_versioncCs|jd|jS)z*Value of "Name:" in distribution metadata.Name)rIrJr7rr r r!r.szBaseDistribution.raw_namec Csl|jd}|dur tSz tt|}W|Sty5}zd}t||j|tWYd}~Sd}~ww)zValue 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)rIrJr r*r r<r=r.)rr$specr>messager r r!requires_pythons z BaseDistribution.requires_pythonr extrascCr)zDependencies of this distribution. For modern .dist-info distributions, this is the collection of "Requires-Dist:" entries in distribution metadata. r)rrPr r r!iter_dependenciesrFz"BaseDistribution.iter_dependenciescCr)zExtras provided by this distribution. For modern .dist-info distributions, this is the collection of "Provides-Extra:" entries in distribution metadata. rrr r r!iter_provided_extrasrFz%BaseDistribution.iter_provided_extrasN)r )'r&r'r(r*r1r2r)r r0r5r6rr7DistributionVersionr/rr3r?r@rArBrCrDr8rrrGemailrNZMessagerIrKr.r rOrr rQrRr r r r!r+8sJ r+c@seZdZdZedddZedeeeddfddZ deded fd d Z de d fd d Z de d fddZ dedddfdedeedededede ef ddZdS)BaseEnvironmentz6An environment containing distributions to introspect.rcCrrr)clsr r r!defaultr#zBaseEnvironment.defaultpathscCrrr)rVrXr r r! from_pathsr#zBaseEnvironment.from_pathsr"r+cCr)z=Given a requirement name, return the installed distributions.rrEr r r!get_distributionr#z BaseEnvironment.get_distributioncCr)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. rrr r r!_iter_distributionssz#BaseEnvironment._iter_distributionsccsF|D]}tjd|jtjd}|std|j|jq|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)r[rematchr7 IGNORECASEr<r=r0)rZdistZproject_name_validr r r!iter_distributionss  z"BaseEnvironment.iter_distributionsTF local_onlyskipinclude_editableseditables_only user_onlycsb|}|r dd|D}|sdd|D}|rdd|D}|r(dd|D}fdd|DS)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. cs|]}|jr|VqdSr)rB.0dr r r! +z?BaseEnvironment.iter_installed_distributions..css|]}|js|VqdSrrArgr r r!rj-rkcsrfrrlrgr r r!rj/rkcsrfr)rCrgr r r!rj1rkc3s|] }|jvr|VqdSr)r7rgrbr r!rj2s)r`)rrarbrcrdreitr rmr!iter_installed_distributionssz,BaseEnvironment.iter_installed_distributionsN)rrU)r&r'r(__doc__ classmethodrWr rr*rYrZrr[r`rr@rr+ror r r r!rUs6  rUc@s&eZdZUeed<dejfddZdS)Wheelr0rcCrrrrr r r! as_zipfile8rHzWheel.as_zipfileN)r&r'r(r*__annotations__zipfileZipFilersr r r r!rr5s rrc@s.eZdZdeddfddZdejfddZdS)FilesystemWheelr0rNcCs ||_dSr)r0)rr0r r r!__init__=s zFilesystemWheel.__init__cCtj|jddSNT)Z allowZip64)rurvr0rr r r!rs@zFilesystemWheel.as_zipfile)r&r'r(r*rxrurvrsr r r r!rw<srwc@s6eZdZdedeeddfddZdejfddZ dS) MemoryWheelr0streamrNcCs||_||_dSr)r0r})rr0r}r r r!rxEs zMemoryWheel.__init__cCryrz)rurvr}rr r r!rsIr{zMemoryWheel.as_zipfile) r&r'r(r*rbytesrxrurvrsr r r r!r|Dsr|)0Z email.messagerTr;Zloggingr]rutypingrrrrrrrr r Z"pip._vendor.packaging.requirementsr Z 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.urlsrrobjectrSZ getLoggerr&r<rr+rUrrrwr|r r r r!s4,       2L