o EcJ@sDddlZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$dd l%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m,Z0ddl1m2Z3ddl4m5Z5ddl4m6Z7ddl8m9Z9ddl:m;Z;mZ>ddl?m@Z@ddlAmBZBmCZCddlDmEZEddlFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOddlPmQZQddlRmSZSddlTmUZUmVZVddlWmXZXdd lYmZZZe[e\Z]d!e^d"e!fd#d$Z_Gd%d&d&Z`d'e`d"e^fd(d)ZadS)*N)Any CollectionDictIterableListOptionalSequenceUnion) pkg_resources)Marker) Requirement) SpecifierSet)canonicalize_name)Version)parse)Pep517HookCaller) Distribution)BuildEnvironmentNoOpBuildEnvironment)InstallationError) get_scheme)Link)generate_metadata)generate_editable_metadata)install_editable)LegacyInstallFailure)install) install_wheel)load_pyproject_tomlmake_pyproject_path)UninstallPathSet) deprecated)direct_url_for_editabledirect_url_from_link)Hashes) ask_path_exists backup_dir display_pathdist_in_install_pathdist_in_site_packagesdist_in_usersiteget_distributionhide_urlredact_auth_from_url) get_metadata)runner_with_spinner_message) TempDirectory tempdir_kinds)running_under_virtualenv)vcsmetadata_directoryreturncCs|tj}tj|\}}t||}|dr%tj}tj |d}n|ds,Jtj }tj |ddd}||||dS)zQReturn a pkg_resources.Distribution for the provided metadata directory. z .egg-inforz .dist-info-) project_namemetadata) rstriposseppathsplitr Z PathMetadataendswithrsplitextZDistInfoDistribution)r4Zdist_dirZbase_dirZ dist_dir_namer8Zdist_clsZ dist_namer@P/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/req/req_install.py _get_distBs   rBc@s.eZdZdZ            dhdeedeeedfdedee d ee d eed ed ee ed ee edee ee efdede edededdfddZdefddZdefddZdefddZedeefddZedefddZedefd d!Zedefd"d#Zdid$eeedefd%d&Zedefd'd(Zdjd*edefd+d,Zdeefd-d.Zd/ed0ed1edefd2d3Z dkd4d5Z!dkd6d7Z"d8eddfd9d:Z#edefd;d<Z$edefd=d>Z%edefd?d@Z&edefdAdBZ'edefdCdDZ(dkdEdFZ)dkdGdHZ*dkdIdJZ+ede,fdKdLZ-de.fdMdNZ/dkdOdPZ0  dldQed0ed1eddfdRdSZ1dkdTdUZ2 dldVedWedee3fdXdYZ4dZed[ed\edefd]d^Z5d/eeddfd_d`Z6     )  )dmd e ed ee7edaeedbeedceedded8edeeddfdfdgZ8dS)nInstallRequirementz Represents something that may be installed later on, may have information about where to fetch the relevant requirement and also contains logic for installing the said requirement. FNr@req comes_fromeditablelinkmarkers use_pep517isolatedinstall_optionsglobal_options hash_options constraintextras user_suppliedpermit_editable_wheelsr5cCs|dus t|ts J|||_||_| |_||_||_d|_d|_|jr8|s)J|j r8t j t j |j|_|durF|rF|jrFt|j}||_|_d|_d|_|jr^|jj r^|jj|_| rd| |_n|rpdd|jD|_nt|_|dur}|r}|j}||_d|_d|_d|_d|_|r|ng|_| r| ng|_| r| ni|_d|_ | |_!||_"t#|_$d|_%d|_&g|_'d|_(||_)d|_*dS)NFcSsh|]}t|qSr@)r Z safe_extra.0extrar@r@rA sz.InstallRequirement.__init__..)+ isinstancer rDrErNrFrQlegacy_install_reason source_diris_filer:r<normpathabspathZ file_pathurlrrG original_linkoriginal_link_is_in_wheel_cachelocal_file_pathrOsetZmarkerrH satisfied_byshould_reinstall_temp_build_dirinstall_succeededrKrLrMZpreparedrPrJr build_envr4pyproject_requiresrequirements_to_checkpep517_backendrIZneeds_more_preparation)selfrDrErFrGrHrIrJrKrLrMrNrOrPrQr@r@rA__init__csX     zInstallRequirement.__init__cCs|jrt|j}|jr|dt|jj7}n |jr!t|jj}nd}|jdur3|dt|jj7}|j rOt |j tr@|j }n|j }|rO|d|d7}|S)Nz from {}zz in {}z (from )) rDstrrGformatr-r\rar'locationrErV from_pathrisrEr@r@rA__str__s"    zInstallRequirement.__str__cCsd|jjt||jS)Nz<{} object: {} editable={!r}>)rm __class____name__rlrFrir@r@rA__repr__szInstallRequirement.__repr__cs>t|t}fddt|D}dj|jjd|dS)z5An un-tested helper for getting state, for debugging.c3s |] }d||VqdS)z{}={!r}N)rm)rSattrZ attributesr@rA sz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )namestate)varssortedrmrsrtjoin)rinamesr{r@rxrA format_debugszInstallRequirement.format_debugcCs|jdurdSt|jjSN)rDr Z safe_namerzrur@r@rArzs zInstallRequirement.namec Cs|jsdS|js J|j1td}|j|d|jvWdWdS1s1wYWddS1sAwYdS)NFz1Checking if build backend supports build_editableZbuild_editable)rIrhrer/Zsubprocess_runnerZ_supported_features)riZrunnerr@r@rAsupports_pyproject_editables  "z.InstallRequirement.supports_pyproject_editablecCs|jjSr)rD specifierrur@r@rArszInstallRequirement.specifiercCs$|j}t|dkott|jdvS)zReturn whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. >=====)rlennextiteroperator)riZ specifiersr@r@rA is_pinnedszInstallRequirement.is_pinnedextras_requestedcs,|sd}jdurtfdd|DSdS)N)c3s |] }jd|iVqdS)rTN)rHZevaluaterRrur@rArys z3InstallRequirement.match_markers..T)rHany)rirr@rurA match_markerss  z InstallRequirement.match_markerscC t|jS)zReturn whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. )boolrMrur@r@rAhas_hash_optionss z#InstallRequirement.has_hash_optionsTtrust_internetcCsB|j}|r |jn|j}|r|jr||jg|jt|S)aReturn a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones from flags. They satisfy --require-hashes (whether it was implicitly or explicitly activated) but do not activate it. md5 and sha224 are not allowed in flags, which should nudge people toward good algos. We always OR all hashes together, even ones from URLs. :param trust_internet: Whether to trust URL-based (#md5=...) hashes downloaded from the internet, as by populate_link() ) rMcopyrGr]hash setdefaultZ hash_nameappendr$)rirZ good_hashesrGr@r@rAhashes's  zInstallRequirement.hashescCsP|jdurdSt|j}|jr&t|jtr|j}n|j}|r&|d|7}|S)z8Format a nice indicator to show where this "comes from" Nz->)rDrlrErVrorpr@r@rAro<s     zInstallRequirement.from_path build_dir autodeleteparallel_buildscCs|dusJ|jdur|jjsJ|jjS|jdur&ttjdd|_|jjSt|j}|r7|dt j }t j |sHt d|t |t j||}|rSdnd}t||tjddjS)NT)kindglobally_managed_zCreating directory %sF)r<deleterr)rcr<rDr0r1Z REQ_BUILDrrzuuidZuuid4hexr:existsloggerdebugmakedirsr~)rirrrZdir_nameZactual_build_dirZ delete_argr@r@rAensure_build_locationJs2         z(InstallRequirement.ensure_build_locationcCsn|jdusJ|jdusJ|jdusJtt|jdtr"d}nd}td|jd||jdg|_dS)z*Set requirement after generating metadata.NrrrrName)rDr8rXrV parse_versionrr r~)riopr@r@rA_set_requirementus z#InstallRequirement._set_requirementcCsDt|jd}t|jj|krdStd|j||jt||_dS)NrzeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)rr8rDrzrwarningr )riZ metadata_namer@r@rAwarn_on_mismatching_namesz+InstallRequirement.warn_on_mismatching_name use_user_sitecCs|jdurdSt|jj}|sdS|j}|duo |jjj|dd}|sQd|_|rFt|r1d|_dSt rBt |rDt d |j |jdSdSt|rOd|_dSdS|jr\d|_d|_dS||_dS)zFind an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. NT)Z prereleaseszVWill not install to the user site because it will lack sys.path precedence to {} in {})rDr+rzversionrcontainsrar*rbr2r)rrmr7rnr(rF)rirZ existing_distZexisting_versionZversion_compatibler@r@rAcheck_if_existss>      z"InstallRequirement.check_if_existscCs|jsdS|jjS)NF)rGis_wheelrur@r@rArszInstallRequirement.is_wheelcCstj|j|jr |jjp dS)Nr)r:r<r~rXrGZsubdirectory_fragmentrur@r@rAunpacked_source_directorysz,InstallRequirement.unpacked_source_directorycC(|js Jd|tj|jd}|S)NNo source dir for zsetup.pyrXr:r<r~r)riZsetup_pyr@r@rA setup_py_pathz InstallRequirement.setup_py_pathcCr)Nrz setup.cfgr)riZ setup_cfgr@r@rAsetup_cfg_pathrz!InstallRequirement.setup_cfg_pathcCs|js Jd|t|jS)Nr)rXrrrur@r@rApyproject_toml_paths z&InstallRequirement.pyproject_toml_pathcCs^t|j|j|jt|}|durd|_dSd|_|\}}}}||_||_t|j||d|_ dS)aALoad the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. NFT) backend_path) rrIrrrlrgrfrrrh)riZpyproject_toml_dataZrequiresbackendZcheckrr@r@rArs  z&InstallRequirement.load_pyproject_tomlcCsT|jr |jr"|s$tj|js&tj|js(td|ddSdSdSdSdS)zCheck that an editable requirement if valid for use with PEP 517/518. This verifies that an editable that has a pyproject.toml either supports PEP 660 or as a setup.py or a setup.cfg zProject z has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.N) rFrIrr:r<isfilerrrrur@r@rAisolated_editable_sanity_checks   z1InstallRequirement.isolated_editable_sanity_checkcCs|jsJ|jr-|jdusJ|jr#|jr#|r#t|j|jd|_nt |j|jd|_nt |j|j |j |j |jp>d|jd|_|jsJ|n||dS)zEnsure that project metadata is available. Under PEP 517 and PEP 660, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. N)rerzfrom )rerrXrJZdetails)rXrIrhrFrQrrrer4rgenerate_metadata_legacyrrrJrzrGrrassert_source_matches_versionrur@r@rAprepare_metadatas8     z#InstallRequirement.prepare_metadatacCst|ds t||_|jS)N _metadata)hasattrr.get_distrrur@r@rAr8Bs zInstallRequirement.metadatacCrr)rBr4rur@r@rArIs zInstallRequirement.get_distcCsT|jsJ|jd}|jjr||jjvrtd||dStdt|j||dS)Nrz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s)rXr8rDrrrrr')rirr@r@rArLs  z0InstallRequirement.assert_source_matches_version parent_dircCs$|jdur|j|||d|_dSdS)aAEnsure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. :param parent_dir: The ideal pip parent_dir for the source_dir. Generally src_dir for editables and build_dir for sdists. :return: self.source_dir N)rr)rXr)rirrrr@r@rAensure_has_source_dir^s  z(InstallRequirement.ensure_has_source_dircCs|js td|jdS|jsJ|jsJ|jjdkrdSt|jj}|s0Jd|jjt |jj}|j |j|ddS)Nz>Cannot update repository at %s; repository location is unknownfilezUnsupported VCS URL )r\) rGrrrXrFschemer3Zget_backend_for_schemer\r,Zobtain)riZ vcs_backendZ hidden_urlr@r@rAupdate_editableus    z"InstallRequirement.update_editable auto_confirmverbosecCsR|jsJt|jj}|std|jdStd|t|}||||S)a Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete or modify files outside of ``sys.prefix`` - thus uninstallation within a virtual environment can only modify that virtual environment, even if the virtualenv is linked to global site-packages. z#Skipping %s as it is not installed.NzFound existing installation: %s) rDr+rzrrinfor Z from_distremove)rirrZdistZuninstalled_pathsetr@r@rA uninstalls     zInstallRequirement.uninstallr< parentdirrootdircCs<dtdtdtfdd}tj||}|||}|jd|S)Nrzprefixr5cSsN||tjjsJd|d||t|dd}|tjjd}|S)Nzname z doesn't start with prefix r/) startswithr:r<r;rreplace)rzrr@r@rA_clean_zip_names z=InstallRequirement._get_archive_name.._clean_zip_namer)rlr:r<r~rz)rir<rrrrzr@r@rA_get_archive_names z$InstallRequirement._get_archive_namecCs|jsJ|dur dSd}d|j|jd}tj||}tj|rjtdt |d}|dkr5d}n5|d krGt d t |t |n#|d krat |}t d t |t |t||n |d krjtd|sndStj|d tjdd}|Utjtj|j}t|D]<\} } } | D]} |j| | |d} t| d}d|_||dq| D]}|j|| |d}tj| |}|||qqWdn1swYt dt |dS)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. NTz {}-{}.ziprz8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )iwbarFrz Deleting %srzBacking up %s to %sr)Z allowZip64)rrrirzSaved %s)rXrmrzr8r:r<r~rr%r'rrrr&shutilZmovesysexitzipfileZZipFileZ ZIP_DEFLATEDnormcaser[rwalkrZZipInfoZ external_attrZwritestrwriter)rirZcreate_archiveZ archive_nameZ archive_pathZresponseZ dest_fileZ zip_outputdirdirpathZdirnames filenamesdirnameZ dir_arcnameZzipdirfilenameZ file_arcnamer@r@rAarchivesv     zInstallRequirement.archiveroothomerwarn_script_location pycompilec Cst|j||||j|d} |dur|ng}|jr2|js2t||||||j|j|j|j|jd d|_ dS|jrh|j s:Jd} |jrEt |j} n |j rQt |j |j|j} t|j|j | t|j||| |jdd|_ dSt||j}t||j}zt|||||||| |j|j|j|j|jt|jd} Wnty} zd|_ | jd} ~ wtyd|_ w| |_ | r|jdkrtd|jd ddd dSdSdS) N)userrrrJr)rrrrzrrJrerT)rreq_descriptionrr direct_urlZ requested)rKrLrrrrrrrrJZreq_namererrFi zg{} was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.z+to fix the wheel build issue reported abovereasonZ replacementZgone_inZissue)rrzrJrFrinstall_editable_legacyrrerrdr_r"r]r#rXr^rrlrDrPlistrLrKinstall_legacyr __cause__ ExceptionrWr!rm) rirKrLrrrrrrrrsuccessexcr@r@rArs          zInstallRequirement.install) FNNNFNNNFr@FFr)T)r5N)FF)NNNNTFT)9rt __module__ __qualname____doc__rr r rlrrr rrrrjrrrvrpropertyrz functools lru_cacherr rrrrrr$rrorrrrrrrrrrrrrr8rrrrrr rrrrrr@r@r@rArC\s       j     + .   )    F   rCrDcCs>d}|jsd}n |jrd}n|jrd}|rtddddd|S) Nrz3Unnamed requirements are not allowed as constraintsz4Editable requirements are not allowed as constraintszConstraints cannot have extrasaConstraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms.z+replacing the constraint with a requirementi r)rzrFrOr!)rDZproblemr@r@rAcheck_invalid_constraint_typebsr)brZloggingr:rrrrtypingrrrrrrrr Z pip._vendorr Zpip._vendor.packaging.markersr Z"pip._vendor.packaging.requirementsr Z pip._vendor.packaging.specifiersr Zpip._vendor.packaging.utilsrZpip._vendor.packaging.versionrrrZpip._vendor.pep517.wrappersrZpip._vendor.pkg_resourcesrZpip._internal.build_envrrZpip._internal.exceptionsrZpip._internal.locationsrZpip._internal.models.linkrZ'pip._internal.operations.build.metadatarZ0pip._internal.operations.build.metadata_editablerZ.pip._internal.operations.build.metadata_legacyrZ0pip._internal.operations.install.editable_legacyrrZ'pip._internal.operations.install.legacyrrrZ&pip._internal.operations.install.wheelrZpip._internal.pyprojectrrZpip._internal.req.req_uninstallr Zpip._internal.utils.deprecationr!Z&pip._internal.utils.direct_url_helpersr"r#Zpip._internal.utils.hashesr$Zpip._internal.utils.miscr%r&r'r(r)r*r+r,r-Zpip._internal.utils.packagingr.Zpip._internal.utils.subprocessr/Zpip._internal.utils.temp_dirr0r1Zpip._internal.utils.virtualenvr2Zpip._internal.vcsr3Z getLoggerrtrrlrBrCrr@r@r@rAsb(                      ,