a Ra_+@sRddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZddlmZddlmZmZddlmZmZmZddlmZdd l m!Z!dd l"m#Z#erdd 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@sBeZdZeedddZeedddZeedddZdS) BaseEntryPointreturncCs tdSNNotImplementedErrorselfr L/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/metadata/base.pyname+szBaseEntryPoint.namecCs tdSrrrr r r!value/szBaseEntryPoint.valuecCs tdSrrrr r r!group3szBaseEntryPoint.groupN)__name__ __module__ __qualname__propertystrr"r#r$r r r r!r*s rc@seZdZedddZedddZeeedddZeeeddd Z eeedd d Z ee dd d Z ee dddZeeedddZeedddZeedddZeedddZeedddZeedddZeedddZeeddd Zeejjdd!d"Zeeedd#d$Zeedd%d&Z ee!dd'd(Z"d0e#eee$d*d+d,Z%eedd-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__cCs tdS)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. Nrrr r r!r/?s zBaseDistribution.locationcCs6|j}|r|r2t|jSnt|j}|r2|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-r/)rr2Z egg_link_pathr r r!editable_project_locationMs  z*BaseDistribution.editable_project_locationcCs tdS)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 tdSrrrr r r!canonical_namesszBaseDistribution.canonical_namecCs tdSrrrr r r!r.wszBaseDistribution.versionc Csvz|t}Wnty"YdS0z t|WSttjtfyp}z t dt|j |WYd}~dSd}~00dS)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_jsonUnicodeDecodeErrorjsonZJSONDecodeErrorrloggerwarningr6)rZcontenter r r!r2{s$   zBaseDistribution.direct_urlcCs tdSrrrr r r! installerszBaseDistribution.installercCs t|jSr)boolr4rr r r!editableszBaseDistribution.editablecCs tdSrrrr r r!localszBaseDistribution.localcCs tdSrrrr r r! in_usersiteszBaseDistribution.in_usersitecCs tdSrrrr r r!in_site_packagessz!BaseDistribution.in_site_packagesr"rcCs tdS)zRead a file in the .dist-info (or .egg-info) directory. Should raise ``FileNotFoundError`` if ``name`` does not exist in the metadata directory. Nrrr"r r r!r7szBaseDistribution.read_textcCs tdSrrrr r r!iter_entry_pointssz"BaseDistribution.iter_entry_pointscCs tdS)z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.Nrrr r r!metadataszBaseDistribution.metadatacCs |jdS)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rGgetrr r r!metadata_versionsz!BaseDistribution.metadata_versioncCs|jd|jS)z*Value of "Name:" in distribution metadata.Name)rGrHr6rr r r!r-szBaseDistribution.raw_namec Csn|jd}|durtSztt|}Wn>tyh}z&d}t||j|tWYd}~Sd}~00|S)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)rGrHr r)r r;r<r-)rr#specr=messager r r!requires_pythons z BaseDistribution.requires_pythonr )extrasrcCs tdS)zDependencies of this distribution. For modern .dist-info distributions, this is the collection of "Requires-Dist:" entries in distribution metadata. Nr)rrNr r r!iter_dependenciessz"BaseDistribution.iter_dependenciescCs tdS)zExtras 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_extrassz%BaseDistribution.iter_provided_extrasN)r )'r%r&r'r)r0r1r(r r/r4r5rr6DistributionVersionr.rr2r>r?r@rArBrCr7rrrFemailrLZMessagerGrIr-r rMrr rOrPr r r r!r*8sH r*c@seZdZdZeddddZeeeeddddZ eedd d d Z e ddd d Z e ddddZ dedddfeeeeeee edddZdS)BaseEnvironmentz6An environment containing distributions to introspect.rcCs tdSrr)clsr r r!defaultszBaseEnvironment.default)pathsrcCs tdSrr)rTrVr r r! from_pathsszBaseEnvironment.from_pathsr*rDcCs tdS)z=Given a requirement name, return the installed distributions.NrrEr r r!get_distributionsz BaseEnvironment.get_distributioncCs tdS)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_distributionssz#BaseEnvironment._iter_distributionsccsD|D]6}tjd|jtjd}|s8td|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)rYrematchr6 IGNORECASEr;r<r/)rZdistZproject_name_validr r r!iter_distributionss z"BaseEnvironment.iter_distributionsTF) local_onlyskipinclude_editableseditables_only user_onlyrcsb|}|rdd|D}|s,dd|D}|r>dd|D}|rPdd|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. css|]}|jr|VqdSr)rA.0dr r r! +z?BaseEnvironment.iter_installed_distributions..css|]}|js|VqdSrr@rdr r r!rg-rhcss|]}|jr|VqdSrrirdr r r!rg/rhcss|]}|jr|VqdSr)rBrdr r r!rg1rhc3s|]}|jvr|VqdSr)r6rdr`r r!rg2rh)r^)rr_r`rarbrcitr rjr!iter_installed_distributionssz,BaseEnvironment.iter_installed_distributionsN)r%r&r'__doc__ classmethodrUr rr)rWrXrrYr^rr?rr*rlr r r r!rSs* rSc@s&eZdZUeed<ejdddZdS)Wheelr/rcCs tdSrrrr r r! as_zipfile8szWheel.as_zipfileN)r%r&r'r)__annotations__zipfileZipFilerpr r r r!ro5s roc@s,eZdZeddddZejdddZdS)FilesystemWheelN)r/rcCs ||_dSr)r/)rr/r r r!__init__=szFilesystemWheel.__init__rcCstj|jddSNT)Z allowZip64)rrrsr/rr r r!rp@szFilesystemWheel.as_zipfile)r%r&r'r)rurrrsrpr r r r!rt<srtc@s2eZdZeeeddddZejdddZ dS) MemoryWheelN)r/streamrcCs||_||_dSr)r/rx)rr/rxr r r!ruEszMemoryWheel.__init__rcCstj|jddSrv)rrrsrxrr r r!rpIszMemoryWheel.as_zipfile) r%r&r'r)rbytesrurrrsrpr r r r!rwDsrw)0Z email.messagerRr:Zloggingr[rrtypingrrrrrrrr 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.urlsrrobjectrQZ getLoggerr%r;rr*rSrortrwr r r r!s2,       2L