U ʗRea@sddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZddlmZddlmZmZddlmZddlmZm Z ddl!m"Z"ddl#m$Z$m%Z%m&Z&dd l'm(Z(m)Z)m*Z*dd l+m,Z,dd l-m.Z.dd l/m0Z0m1Z1dd l2m3Z3ddl4m5Z5ddl6m7Z7e rHddl m8Z8ne9Z8eee fZ:ee;eje?Z@Gddde8ZAee;dfee;dfe;dddZBGdddeZCGddde8ZDGdddZEGddde8ZFGd d!d!eFZGGd"d#d#eFZHdS)$N) IO TYPE_CHECKINGAny Collection ContainerDictIterableIteratorList NamedTupleOptionalTupleUnion) Requirement)InvalidSpecifier SpecifierSet)NormalizedName) LegacyVersionVersion)NoneMetadataError) get_scheme site_packages user_site)DIRECT_URL_METADATA_NAME DirectUrlDirectUrlValidationError) stdlib_pkgs)egg_link_path_from_sys_path)is_localnormalize_path) safe_extra) url_to_path) msg_to_json)Protocolc@sBeZdZeedddZeedddZeedddZdS) BaseEntryPointreturncCs tdSNNotImplementedErrorselfr-/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/metadata/base.pyname:szBaseEntryPoint.namecCs tdSr(r)r+r-r-r.value>szBaseEntryPoint.valuecCs tdSr(r)r+r-r-r.groupBszBaseEntryPoint.groupN)__name__ __module__ __qualname__propertystrr/r0r1r-r-r-r.r%9s r%.)entryinfor'cCsV|rD|ddkrD|r |ddkr*|d7}n |dd}|dd}qttj||S)aConvert 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..)r9Nr"r6pathlibPath)r7r8r-r-r._convert_installed_files_pathGs   r>c@s&eZdZUeed<eed<eed<dS) RequiresEntry requirementextramarkerN)r2r3r4r6__annotations__r-r-r-r.r?es r?c@sReZdZeeddddZededdddZedd d Zedd d Ze e edd dZ e e edddZ e e edddZ e e edddZe edddZe edddZe edddZe edddZe edddZe eddd Ze edd!d"Ze e edd#d$Ze edd%d&Ze edd'd(Ze edd)d*Ze edd+d,Ze edd-d.Ze edd/d0Z e!ed1d2d3Z"e#edd4d5Z$e!ed1d6d7Z%e&e'dd8d9Z(e)j*j+dd:d;Z,e-j.dd?Z/e e)j*j+dd@dAZ0e e1ee2fddBdCZ3e e eddDdEZ4e eddFdGZ5e e6ddHdIZ7dbe8ee&e9dKdLdMZ:e&eddNdOZ;e e#eddPdQZe#e?ddVdWZ@e&eddXdYZAe&eddZd[ZBe)j*j+d\d]d^d_ZCe edd`daZDd\S)cBaseDistribution) directoryr'cCs tdS)zLoad the distribution from a metadata directory. :param directory: Path to a metadata directory, e.g. ``.dist-info``. Nr))clsrEr-r-r.from_directorylszBaseDistribution.from_directoryWheel)wheelr/r'cCs tdS)aLoad 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))rFrIr/r-r-r. from_wheelts zBaseDistribution.from_wheelr&cCs|jd|jd|jdS)N z ())raw_nameversionlocationr+r-r-r.__repr__szBaseDistribution.__repr__cCs|jd|jS)NrK)rMrNr+r-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. Nr)r+r-r-r.rOs 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_urlis_local_editabler!urlrrMrO)r,rR egg_link_pathr-r-r.editable_project_locations  z*BaseDistribution.editable_project_locationcCs tdS)aThe 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_locations z#BaseDistribution.installed_locationcCs tdS)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_locationszBaseDistribution.info_locationcCs|j}|sdSt|S)aWhether 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)rXr<r=is_filer,rXr-r-r.installed_by_distutilssz'BaseDistribution.installed_by_distutilscCs|j}|sdS|dS)zWhether this distribution is installed as an egg. This usually indicates the distribution was installed by (older versions of) easy_install. Fz.egg)rOendswithr,rOr-r-r.installed_as_eggsz!BaseDistribution.installed_as_eggcCs*|j}|sdS|dsdSt|S)aWhether 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-inforXr\r<r=is_dirrZr-r-r."installed_with_setuptools_egg_infos  z3BaseDistribution.installed_with_setuptools_egg_infocCs*|j}|sdS|dsdSt|S)aaWhether 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_rZr-r-r.installed_with_dist_infos  z)BaseDistribution.installed_with_dist_infocCs tdSr(r)r+r-r-r.canonical_nameszBaseDistribution.canonical_namecCs tdSr(r)r+r-r-r.rNszBaseDistribution.versioncCs|jddS)zConvert a project name to its setuptools-compatible filename. This is a copy of ``pkg_resources.to_filename()`` for compatibility. -_)rMreplacer+r-r-r.setuptools_filename sz$BaseDistribution.setuptools_filenamec 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_textrFileNotFoundErrorr from_jsonUnicodeDecodeErrorjsonJSONDecodeErrorrloggerwarningrc)r,contenter-r-r.rRs$ zBaseDistribution.direct_urlc CsRz|d}Wntttfk r*YdSX|D]}|}|r4|Sq4dS)N INSTALLER)rhOSError ValueErrorr splitlinesstrip)r,installer_textline cleaned_liner-r-r. installer.s  zBaseDistribution.installercCs |dS)N REQUESTED)rYr+r-r-r. requested:szBaseDistribution.requestedcCs t|jSr()boolrVr+r-r-r.editable>szBaseDistribution.editablecCs|jdkrdSt|jS)z|If distribution is installed in the current virtual environment. Always True if we're not in a virtualenv. NF)rWrr+r-r-r.localBs zBaseDistribution.localcCs&|jdkstdkrdS|jttSNF)rWr startswithrr+r-r-r. in_usersiteLszBaseDistribution.in_usersitecCs&|jdkstdkrdS|jttSr)rWrrrr+r-r-r.in_site_packagesRsz!BaseDistribution.in_site_packages)pathr'cCs tdS)z7Check whether an entry in the info directory is a file.Nr)r,rr-r-r.rYXszBaseDistribution.is_filecCs tdS)zFind 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_names\sz,BaseDistribution.iter_distutils_script_namescCs tdS)zRead 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)rr-r-r.rhdszBaseDistribution.read_textcCs tdSr(r)r+r-r-r.iter_entry_pointsmsz"BaseDistribution.iter_entry_pointscCs tdSr(r)r+r-r-r._metadata_implpszBaseDistribution._metadata_implr")maxsizecCs|}|||Sr()r_add_egg_info_requires)r,metadatar-r-r._metadata_cachedss z!BaseDistribution._metadata_cachedcCs|S)aMetadata 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. )rr+r-r-r.r{s zBaseDistribution.metadatacCs t|jS)aPEP 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#rr+r-r-r. metadata_dicts zBaseDistribution.metadata_dictcCs |jdS)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rgetr+r-r-r.metadata_versionsz!BaseDistribution.metadata_versioncCs|jd|jS)z*Value of "Name:" in distribution metadata.Name)rrrcr+r-r-r.rMszBaseDistribution.raw_namec Csp|jd}|dkrtSztt|}Wn@tk rj}z"d}t||j|tWYSd}~XYnX|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)rrrr6rrnrorM)r,r0specrqmessager-r-r.requires_pythons z BaseDistribution.requires_pythonr-)extrasr'cCs tdS)zDependencies of this distribution. For modern .dist-info distributions, this is the collection of "Requires-Dist:" entries in distribution metadata. Nr))r,rr-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. Nr)r+r-r-r.iter_provided_extrassz%BaseDistribution.iter_provided_extrascCs>z|d}Wntk r$YdSXddt|DS)NRECORDcss |]}tt|dVqdS)rNr;).0rowr-r-r. szFBaseDistribution._iter_declared_entries_from_record..)rhricsvreaderrv)r,textr-r-r."_iter_declared_entries_from_records z3BaseDistribution._iter_declared_entries_from_recordcsz|d}Wntk r$YdSXdd|jddD}|j}|j}|dksX|dkr\|Szt||Wntk r|YSXj s|Sfdd|DS)Nzinstalled-files.txtcss|]}|r|VqdSr(r-rpr-r-r.rszFBaseDistribution._iter_declared_entries_from_legacy..F)keependsc3s"|]}tt|jjVqdSr()r>r<r=partsrinfo_relr-r.rs) rhrirvrOrXr<r= relative_torur)r,rpathsrootr8r-rr."_iter_declared_entries_from_legacys$  z3BaseDistribution._iter_declared_entries_from_legacycCs|p|S)aIterate 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``. )rrr+r-r-r.iter_declared_entriess z&BaseDistribution.iter_declared_entriesccsz|d}Wntk r$YdSXd}}|D]X}|}|r6|drRq6|dr~|dr~|dd\}}}q6t|||d Vq6dS) aParse 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.txtNrs#[]z[]:)r@rArB)rhrirvrwrr\ partitionr?)r,rprArBryrer-r-r._iter_requires_txt_entriess  z+BaseDistribution._iter_requires_txt_entriesccs8dh}|D]$}|j|krq||j|jVqdS)z'Get extras from the egg-info directory.rsN)rrAadd)r, known_extrasr7r-r-r._iter_egg_info_extrass    z&BaseDistribution._iter_egg_info_extrasccs|D]x}|jr4|jr4d|jdt|jd}n,|jrNdt|jd}n|jr\|j}nd}|rx|jd|Vq|jVqdS)aGet 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 == "rsz ; N)rrArBr r@)r,r7rBr-r-r._iter_egg_info_dependenciess  z,BaseDistribution._iter_egg_info_dependenciesN)rr'cCsD|ds |D] }||d<q|ds@|D] }||d<q2dS)z6Add egg-info requires.txt information to the metadata.z Requires-DistzProvides-ExtraN)get_allrr)r,rdeprAr-r-r.r*s      z'BaseDistribution._add_egg_info_requirescCs(t|j}|ttdjddS)zr Return True if given Distribution is installed in path matching distutils_scheme layout. rspythonr)rrWrrpurelibsplit)r, norm_pathr-r-r.in_install_path3s z BaseDistribution.in_install_path)r-)Er2r3r4 classmethodr6rGrJrPrQr5r rOrVrWrXr~r[r^rarbrrcDistributionVersionrNrgrrRr{r}rrrrInfoPathrYr rrhrr%remailrMessager functools lru_cacherrrrrrrMrrrrrrrrrr?rrrrrr-r-r-r.rDks             rDc@seZdZdZeddddZeeeeddddZ eedd d d Z e ddd d Z e e dddZdedddfeeeeeee e dddZdS)BaseEnvironmentz6An environment containing distributions to introspect.r&cCs tdSr(r))rFr-r-r.defaultAszBaseEnvironment.default)rr'cCs tdSr(r))rFrr-r-r. from_pathsEszBaseEnvironment.from_pathsrD)r/r'cCs tdS)zGiven 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_distributionIsz 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. Nr)r+r-r-r._iter_distributionsQsz#BaseEnvironment._iter_distributionsccsD|D]6}tjd|jtjd}|s8td|j|jq|VqdS)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)rrematchrc IGNORECASErnrorO)r,distproject_name_validr-r-r.iter_all_distributionsZs z&BaseEnvironment.iter_all_distributionsTF) local_onlyskipinclude_editableseditables_only user_onlyr'csb|}|rdd|D}|s,dd|D}|r>dd|D}|rPdd|D}fdd|DS)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. css|]}|jr|VqdSr()rrdr-r-r.rsz?BaseEnvironment.iter_installed_distributions..css|]}|js|VqdSr(rrr-r-r.rscss|]}|jr|VqdSr(rrr-r-r.rscss|]}|jr|VqdSr()rrr-r-r.rsc3s|]}|jkr|VqdSr()rcrrr-r.rs )r)r,rrrrritr-rr.iter_installed_distributionsosz,BaseEnvironment.iter_installed_distributionsN)r2r3r4__doc__rrr r r6rrr rrDrrr~rrr-r-r-r.r>s* rc@s&eZdZUeed<ejdddZdS)rHrOr&cCs tdSr(r)r+r-r-r. as_zipfileszWheel.as_zipfileN)r2r3r4r6rCzipfileZipFilerr-r-r-r.rHs rHc@s,eZdZeddddZejdddZdS)FilesystemWheelN)rOr'cCs ||_dSr()rOr]r-r-r.__init__szFilesystemWheel.__init__r&cCstj|jddSNT) allowZip64)rrrOr+r-r-r.rszFilesystemWheel.as_zipfile)r2r3r4r6rrrrr-r-r-r.rsrc@s2eZdZeeeddddZejdddZ dS) MemoryWheelN)rOstreamr'cCs||_||_dSr()rOr)r,rOrr-r-r.rszMemoryWheel.__init__r&cCstj|jddSr)rrrr+r-r-r.rszMemoryWheel.as_zipfile) r2r3r4r6rbytesrrrrr-r-r-r.rsr)Ir email.messagerrrlloggingr<rrtypingrrrrrrrr r r r r r"pip._vendor.packaging.requirementsrZ pip._vendor.packaging.specifiersrrpip._vendor.packaging.utilsrZpip._vendor.packaging.versionrrpip._internal.exceptionsrpip._internal.locationsrrrpip._internal.models.direct_urlrrrpip._internal.utils.compatrpip._internal.utils.egg_linkrpip._internal.utils.miscrrpip._internal.utils.packagingr pip._internal.utils.urlsr!_jsonr#r$objectrr6PurePathr getLoggerr2rnr%r>r?rDrrHrrr-r-r-r.sR<             VU