idbddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZddlmZddlmZmZddlmZddlmZm Z ddl!m"Z"ddl#m$Z$m%Z%dd l&m'Z'm(Z(m)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/m0Z0dd l1m2Z2ddl3m4Z4ddl5m6Z6e rddl m7Z7ne8Z7eee fZ9ee:ej;fZ<ej=e>Z?Gdde7Z@dee:dfdee:dfde:fdZAGddeZBGdde7ZCGddZDGdd e7ZEGd!d"eEZFGd#d$eEZGdS)%N) IO TYPE_CHECKINGAny Collection ContainerDictIterableIteratorList NamedTupleOptionalTupleUnion) Requirement)InvalidSpecifier SpecifierSet)NormalizedName) LegacyVersionVersion)NoneMetadataError) 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)ProtocolcbeZdZedefdZedefdZedefdZdS)BaseEntryPointreturnctNNotImplementedErrorselfs P/opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_internal/metadata/base.pynamezBaseEntryPoint.name:!###ctr)r*r,s r.valuezBaseEntryPoint.value>r0r1ctr)r*r,s r.groupzBaseEntryPoint.groupBr0r1N)__name__ __module__ __qualname__propertystrr/r3r5r1r.r&r&9s $c$$$X$$s$$$X$$s$$$X$$$r1r&entry.infor'c|rB|ddkr6|r |ddkr|dz }n |dd}|dd}|r |ddk6ttjg||RS)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..)r?Nr"r:pathlibPath)r<r=s r._convert_installed_files_pathrDGs* E!H$$ tBx4'' GODD9Dabb  E!H$$ w|*T*E*** + ++r1c.eZdZUeed<eed<eed<dS) RequiresEntry requirementextramarkerN)r6r7r8r:__annotations__r;r1r.rFrFes. JJJ KKKKKr1rFc ZeZdZededdfdZededededdfdZedd d eddfd Zdefd Z defd Z e de efdZ e de efdZe de efdZe de efdZe defdZe defdZe defdZe defdZe defdZe defdZe defdZe de efdZe defdZe defdZe defdZe defdZ e defdZ!e defdZ"d e#defd!Z$de%efd"Z&d e#defd#Z'de(e)fd$Z*de+j,j-fd%Z.e/j0d&'de+j,j-fd(Z1e de+j,j-fd)Z2e de3ee4ffd*Z5e de efd+Z6e defd,Z7e de8fd-Z9d;d/e:ede(e;fd0Zde e%efd3Z?de e%efd4Z@de%eAfd5ZBde(efd6ZCde(efd7ZDd8e+j,j-dd9fd:ZEd9S)<BaseDistribution directoryr'ct)zLoad the distribution from a metadata directory. :param directory: Path to a metadata directory, e.g. ``.dist-info``. r*)clsrMs r.from_directoryzBaseDistribution.from_directoryl "###r1metadata_contentsfilename project_namect)aLoad 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. r*)rOrRrSrTs r.from_metadata_file_contentsz,BaseDistribution.from_metadata_file_contentsts "###r1wheelWheelr/ct)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. r*)rOrWr/s r. from_wheelzBaseDistribution.from_wheel"###r1c6|jd|jd|jdS)N z ())raw_nameversionlocationr,s r.__repr__zBaseDistribution.__repr__s'-BB$,BB$-BBBBr1c$|jd|jS)Nr])r_r`r,s r.__str__zBaseDistribution.__str__s-00$,000r1ct)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. r*r,s r.razBaseDistribution.locationr[r1c|j}|r)|rt|jSnt |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_urlis_local_editabler!urlrr_ra)r-rg egg_link_paths r.editable_project_locationz*BaseDistribution.editable_project_locationsd_  %++-- 3":>222 3 8 FFM %}$tr1ct)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). r*r,s r.installed_locationz#BaseDistribution.installed_locations"###r1ct)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. r*r,s r. info_locationzBaseDistribution.info_locations"###r1cd|j}|sdStj|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)rorBrCis_filer-ros r.installed_by_distutilsz'BaseDistribution.installed_by_distutilss5*  5|M**22444r1cB|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)raendswithr-ras r.installed_as_eggz!BaseDistribution.installed_as_eggs,= 5  (((r1c|j}|sdS|dsdStj|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-infororurBrCis_dirrrs r."installed_with_setuptools_egg_infoz3BaseDistribution.installed_with_setuptools_egg_infosP*  5%%k22 5|M**11333r1c|j}|sdS|dsdStj|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-inforyrrs r.installed_with_dist_infoz)BaseDistribution.installed_with_dist_infosP*  5%%l33 5|M**11333r1ctr)r*r,s r.canonical_namezBaseDistribution.canonical_namer0r1ctr)r*r,s r.r`zBaseDistribution.versionr0r1c8|jddS)zConvert a project name to its setuptools-compatible filename. This is a copy of ``pkg_resources.to_filename()`` for compatibility. -_)r_replacer,s r.setuptools_filenamez$BaseDistribution.setuptools_filenames }$$S#...r1c( |t}n#t$rYdSwxYw tj|S#t t jtf$r2}t dt|j |Yd}~dSd}~wwxYw)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_jsonUnicodeDecodeErrorjsonJSONDecodeErrorrloggerwarningr)r-contentes r.rgzBaseDistribution.direct_url&s nn%=>>GG    44  &w// /   $    NN-(#     44444 s# ++AB'B  Bc |d}n#tttf$rYdSwxYw|D]}|}|r|cSdS)N INSTALLER)rOSError ValueErrorr splitlinesstrip)r-installer_textline cleaned_lines r. installerzBaseDistribution.installer@s !^^K88NN%67   22 "--// $ $D::<> ! "E ++DD " " "EG NN7DM1 5 5 5>> ! ! ! ! ! ! " sA B0B B Br;extrasct)zDependencies of this distribution. For modern .dist-info distributions, this is the collection of "Requires-Dist:" entries in distribution metadata. r*)r-rs r.iter_dependenciesz"BaseDistribution.iter_dependenciesrQr1ct)zExtras provided by this distribution. For modern .dist-info distributions, this is the collection of "Provides-Extra:" entries in distribution metadata. r*r,s r.iter_provided_extrasz%BaseDistribution.iter_provided_extrasrQr1c |d}n#t$rYdSwxYwdtj|DS)NRECORDc3dK|]+}ttj|dV,dS)rNrA).0rows r. zFBaseDistribution._iter_declared_entries_from_record..s8SScGLQ(())SSSSSSr1)rrcsvreaderr)r-texts r."_iter_declared_entries_from_recordz3BaseDistribution._iter_declared_entries_from_recordsg >>(++DD    44 TSSZ@Q@Q5R5RSSSSs  &&c` |d}n#t$rYdSwxYwd|dD}|j}|j}|||S t j||n#t$r|cYSwxYwj s|Sfd|DS)Nzinstalled-files.txtc3K|]}||V dSr)r;)rps r.rzFBaseDistribution._iter_declared_entries_from_legacy..s'AAqqAAAAAAAr1F)keependsc3pK|]0}ttj|jjV1dSr))rDrBrCparts)rrinfo_rels r.rzFBaseDistribution._iter_declared_entries_from_legacy..sN   *',q//*? P P      r1) rrrrarorBrC relative_torr)r-rpathsrootr=rs @r."_iter_declared_entries_from_legacyz3BaseDistribution._iter_declared_entries_from_legacys >>"788DD    44 AADOOUO;;AAA}! <4<L |D))55d;;HH   LLL ~ L        s '''B BBcR|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,s r.iter_declared_entriesz&BaseDistribution.iter_declared_entriess,  3 3 5 5 96688 r1c#K |d}n#t$rYdSwxYwdx}}|D]}|}|r|dr.|drB|dr-|dd\}}}t||| VdS) 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.txtNr#[]z[]:)rGrHrI)rrrrrru partitionrF)r-rrHrIrrs r._iter_requires_txt_entriesz+BaseDistribution._iter_requires_txt_entriess  nn^44GG     FF &&(( N ND::<#>>>X> X$$$ 3$+AV$$$$$hsm$$$$THXc]4KTTTT HXc]4K    * x '>    NH],CNNNN2x}(Xc]((((63u}/D3333333r1rLceZdZdZeddZedeeeddfdZ dededfdZ de dfd Z de e fd Zd ed d d fd edeedededede e f dZdS)BaseEnvironmentz6An environment containing distributions to introspect.r'ctr)r*)rOs r.defaultzBaseEnvironment.defaultIr0r1rctr)r*)rOrs r. from_pathszBaseEnvironment.from_pathsMr0r1r/rLct)zGiven a requirement name, return the installed distributions. The name may not be normalized. The implementation must canonicalize it for lookup. r*)r-r/s r.get_distributionz BaseEnvironment.get_distributionQrQr1ct)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. r*r,s r._iter_distributionsz#BaseEnvironment._iter_distributionsYrr1c#K|D]U}tjd|jtj}|s't d|j|jQ|VVdS)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)rrematchr IGNORECASErrra)r-distproject_name_valids r.iter_all_distributionsz&BaseEnvironment.iter_all_distributionsbs,,..  D "$<#m"""  & ;'M JJJJ#  r1TF local_onlyskipinclude_editableseditables_only user_onlyc|}|r d|D}|s d|D}|r d|D}|r d|D}fd|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. c3(K|] }|j |VdSr))rrds r.rz?BaseEnvironment.iter_installed_distributions..s)++17+!++++++r1c3(K|] }|j |VdSr)rrs r.rz?BaseEnvironment.iter_installed_distributions..s)22qz2!222222r1c3(K|] }|j |VdSr)rrs r.rz?BaseEnvironment.iter_installed_distributions..s)..1:.!......r1c3(K|] }|j |VdSr))rrs r.rz?BaseEnvironment.iter_installed_distributions..s)111=1!111111r1c3.K|]}|jv |VdSr))r)rrrs r.rz?BaseEnvironment.iter_installed_distributions..s0>>a!1!=!=!=!=!=!=>>r1)r)r-rrrrrits ` r.iter_installed_distributionsz,BaseEnvironment.iter_installed_distributionsws0 ( ( * *  ,++R+++B  322R222B  /..R...B  211R111B>>>>2>>>>r1N)r'r)r6r7r8__doc__rrr r r:rrr rrLrrrrrr;r1r.rrFsH@@$$$[$$xS 2$7H$$$[$$S$X6H-I$$$$$X.@%A$$$$1A(B. *"&$ !?!?!?n!? !?  !?  !? " #!?!?!?!?!?!?r1rc0eZdZUeed<dejfdZdS)rXrar'ctr)r*r,s r. as_zipfilezWheel.as_zipfilerr1N)r6r7r8r:rJzipfileZipFiler"r;r1r.rXrXs<MMM$GO$$$$$$r1rXc4eZdZdeddfdZdejfdZdS)FilesystemWheelrar'Nc||_dSr))rarvs r.__init__zFilesystemWheel.__init__s   r1c8tj|jdSNT) allowZip64)r#r$rar,s r.r"zFilesystemWheel.as_zipfilest}>>>>r1)r6r7r8r:r(r#r$r"r;r1r.r&r&sS!!!!!!?GO??????r1r&cDeZdZdedeeddfdZdejfdZ dS) MemoryWheelrastreamr'Nc"||_||_dSr))rar.)r-rar.s r.r(zMemoryWheel.__init__s   r1c8tj|jdSr*)r#r$r.r,s r.r"zMemoryWheel.as_zipfilest{t<<<rDs    ;:::::KKKKKKKK666666@@@@@@@@666666<<<<<<<< 322222DDDDDD========444444000000HM723 g&& '  8 $ $ $ $ $ $ $X $ $ $, c?, S/, ,,,,<J X3X3X3X3X3xX3X3X3vR?R?R?R?R?R?R?R?j$$$$$H$$$?????e???=====%=====r1