U ja@sddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z ddlmZddlmZmZddlmZmZmZddlmZerddlmZddlmZneZe eefZeeZ Gd d d eZ!Gd d d eZ"Gd ddZ#dS)N) TYPE_CHECKING Collection ContainerIterableIteratorListOptionalUnion) Requirement) LegacyVersionVersion)DIRECT_URL_METADATA_NAME DirectUrlDirectUrlValidationError) stdlib_pkgs)Protocol)NormalizedNamec@sBeZdZeedddZeedddZeedddZdS) BaseEntryPointreturncCs tdSNNotImplementedErrorselfrs/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-bug3gbve/pip/_internal/metadata/base.pyname'szBaseEntryPoint.namecCs tdSrrrrrrvalue+szBaseEntryPoint.valuecCs tdSrrrrrrgroup/szBaseEntryPoint.groupN)__name__ __module__ __qualname__propertystrrrrrrrrr&s rc@sFeZdZeeedddZeeedddZeddddZee dd d Z eee dd d Z eedd dZ eedddZeedddZeedddZeedddZeedddZeedddZeejjdddZeeedddZeedd d!Zd'eeeed#d$d%Zd&S)(BaseDistributionrcCs 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. Nrrrrrlocation5s zBaseDistribution.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. Nrrrrrinfo_directoryCszBaseDistribution.info_directoryrcCs tdSrrrrrrcanonical_nameSszBaseDistribution.canonical_namecCs tdSrrrrrrversionWszBaseDistribution.versionc Cszz|t}Wntk r$YdSXz t|WSttjtfk rt}zt dt|j |WYdSd}~XYnXdS)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_textr FileNotFoundErrorr from_jsonUnicodeDecodeErrorjsonJSONDecodeErrorrloggerwarningr()rcontenterrr direct_url[s$ zBaseDistribution.direct_urlcCs tdSrrrrrr installeruszBaseDistribution.installercCs tdSrrrrrreditableyszBaseDistribution.editablecCs tdSrrrrrrlocal}szBaseDistribution.localcCs tdSrrrrrr in_usersiteszBaseDistribution.in_usersitecCs tdSrrrrrrin_site_packagessz!BaseDistribution.in_site_packagesrrcCs tdS)zRead a file in the .dist-info (or .egg-info) directory. Should raise ``FileNotFoundError`` if ``name`` does not exist in the metadata directory. Nrrrrrrr*szBaseDistribution.read_textcCs tdSrrrrrriter_entry_pointssz"BaseDistribution.iter_entry_pointscCs tdS)z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.NrrrrrmetadataszBaseDistribution.metadatacCs |jdS)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)r=getrrrrmetadata_versionsz!BaseDistribution.metadata_versioncCs|jd|jS)z*Value of "Name:" in distribution metadata.Name)r=r>r(rrrrraw_nameszBaseDistribution.raw_namer)extrasrcCs tdSrr)rrBrrriter_dependenciessz"BaseDistribution.iter_dependenciesN)r) r r!r"r#rr$r&r'r(DistributionVersionr)rr4r5boolr6r7r8r9r*rrr<emailmessageMessager=r?rArr rCrrrrr%4s: r%c@seZdZdZeddddZeeeeddddZ eedd d d Z e ddd d Z e ddddZ dedddfeeeeeee edddZdS)BaseEnvironmentz6An environment containing distributions to introspect.rcCs tdSrr)clsrrrdefaultszBaseEnvironment.default)pathsrcCs tdSrr)rJrLrrr from_pathsszBaseEnvironment.from_pathsr%r:cCs tdS)z=Given a requirement name, return the installed distributions.Nrr;rrrget_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. Nrrrrr_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)rOrematchr( IGNORECASEr0r1r&)rdistZproject_name_validrrriter_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)r7.0drrr sz?BaseEnvironment.iter_installed_distributions..css|]}|js|VqdSrr6r[rrrr^scss|]}|jr|VqdSrr_r[rrrr^scss|]}|jr|VqdSr)r8r[rrrr^sc3s|]}|jkr|VqdSr)r(r[rWrrr^s )rU)rrVrWrXrYrZitrr`riter_installed_distributionssz,BaseEnvironment.iter_installed_distributionsN)r r!r"__doc__ classmethodrKrrr$rMrNrrOrUrrErr%rbrrrrrIs* rI)$ email.messagerFr.loggingrQtypingrrrrrrrr Z"pip._vendor.packaging.requirementsr pip._vendor.packaging.versionr r pip._internal.models.direct_urlr rrpip._internal.utils.miscrrpip._vendor.packaging.utilsrobjectrD getLoggerr r0rr%rIrrrrs"(     u