o gQ @sdZddlZddlZddlmZmZmZddlmZm Z m Z m Z m Z ddl mZmZddlmZmZmZddlmZddlmZerZdd lmZdd lmZdd lmZdd lmZd ede fddZ!d e eefdedededef ddZ"Gddde#Z$Gddde$Z%Gddde$Z&Gddde$Z'Gddde$Z(Gd d!d!e%Z)Gd"d#d#e%Z*Gd$d%d%e$Z+Gd&d'd'e'Z,Gd(d)d)e'Z-Gd*d+d+e'Z.Gd,d-d-e'Z/Gd.d/d/e$Z0Gd0d1d1e$Z1Gd2d3d3e$Z2Gd4d5d5e$Z3Gd6d7d7e$Z4Gd8d9d9e'Z5Gd:d;d;e'Z6Gdd?d?e'Z8Gd@dAdAe%Z9GdBdCdCe%e'Z:GdDdEdEe:e'Z;GdFdGdGe'ZGdLdMdMe=Z?GdNdOdOe=Z@GdPdQdQe=ZAGdRdSdSe=ZBGdTdUdUe'ZCGdVdWdWe&ZDdS)XzExceptions used throughout package. This module MUST NOT try to import from anything within `pip._internal` to operate. This is expected to be importable from any/all files within the subpackage and, thus, should not depend on them. N)chaingroupbyrepeat) TYPE_CHECKINGDictListOptionalUnion)RequestResponse)ConsoleConsoleOptions RenderResult)escape)Text)_Hash)Literal)BaseDistribution)InstallRequirementsreturncCstd|duS)Nz^[a-z]+(-[a-z]+)*$)rematch)rr:/usr/lib/python3/dist-packages/pip/_internal/exceptions.py_is_kebab_caserconsoleprefixindentcCsJt|tr|}n||}|j|dd|jd|dd|jddS)Nignore)overflow T) allow_blank) isinstancer render_strjoinsplit)rrrrtextrrr_prefix_with_indent!s   r)c@eZdZdZdS)PipErrorzThe base pip error.N__name__ __module__ __qualname____doc__rrrrr+2r+cseZdZUdZeed<ddddddddeedeeefd eeeefd eeeefd eeeefd eed dffddZ d efddZ de de d e fddZZS)DiagnosticPipErroraAn error, that presents diagnostic information to the user. This contains a bunch of logic, to enable pretty presentation of our error messages. Each error gets a unique reference. Each error can also include additional context, a hint and/or a note -- which are presented with the main error message in a consistent style. This is adapted from the error output styling in `sphinx-theme-builder`. referenceerrorN)kindr3 note_stmtlinkr5zLiteral["error", "warning"]messagecontext hint_stmtr6r7rcs~|durt|ds Jd|j}t|sJd||_||_||_||_||_||_||_t d|j j d|jddS)Nr3zerror reference not provided!z#error reference must be kebab-case!) hasattrr3rr5r8r9r6r:r7super__init__ __class__r-)selfr5r3r8r9r:r6r7r@rrr?Cs $zDiagnosticPipError.__init__c Cs8d|jjd|jd|jd|jd|jd|jd S)Nr;z (reference=z , message=z , context=z , note_stmt=z , hint_stmt=z)>)r@r-r3r8r9r6r:rArrr__repr__as zDiagnosticPipError.__repr__roptionsccsD|jdkrdnd}d|d|jd|jdVdV|jsT|jdurIt|j|d|d d|d d Vt|j|d|d d|d d Vnt|j|ddd Vn|jV|jdurddV|jV|jdusn|jdurqdV|jdurt|j|ddd V|jdurt|j|ddd V|jdurdVd|jVdSdS)Nr4redyellow[z bold]z [/]: [bold]z[/]u]×[/] u]│[/] )rru ]╰─>[/] z] [/] u [red]×[/] z z[magenta bold]note[/]: z z[cyan bold]hint[/]: zLink: ) r5r3 ascii_onlyr9r)r8r6r:r7)rArrEcolourrrr__rich_console__ls`           z#DiagnosticPipError.__rich_console__)r-r.r/r0str__annotations__rr rr?rDr r rrL __classcell__rrrBrr26s@      r2c@r*)ConfigurationErrorz"General exception in configurationNr,rrrrrPr1rPc@r*)InstallationErrorz%General exception during installationNr,rrrrrQr1rQc@r*)UninstallationErrorz'General exception during uninstallationNr,rrrrrRr1rRc.eZdZdZdZdeddffdd ZZS)MissingPyProjectBuildRequireszNRaised when pyproject.toml has `build-system`, but no `build-system.requires`.z'missing-pyproject-build-system-requirespackagerNcs*tjdt|tddtdddS)NCan not process zrThis package has an invalid pyproject.toml file. The [build-system] table is missing the mandatory `requires` key.;This is an issue with the package mentioned above, not pip.+See PEP 518 for the detailed specification.r8r9r6r:r>r?rr)rArUrBrrr?s  z&MissingPyProjectBuildRequires.__init__r-r.r/r0r3rMr?rOrrrBrrTrTcs2eZdZdZdZdededdffdd ZZS) InvalidPyProjectBuildRequiresz>Raised when pyproject.toml an invalid `build-system.requires`.z'invalid-pyproject-build-system-requiresrUreasonrNcs0tjdt|td|dtdddS)NrVzKThis package has an invalid `build-system.requires` key in pyproject.toml. rWrXrYrZ)rArUr^rBrrr?s  z&InvalidPyProjectBuildRequires.__init__r[rrrBrr]s"r]c@s4eZdZdZdddeddfddZdefd d ZdS) NoneMetadataErrora4Raised when accessing a Distribution's "METADATA" or "PKG-INFO". This signifies an inconsistency, when the Distribution claims to have the metadata file (if not, raise ``FileNotFoundError`` instead), but is not actually able to produce its content. This may be due to permission errors. distr metadata_namerNcC||_||_dS)z :param dist: A Distribution object. :param metadata_name: The name of the metadata being accessed (can be "METADATA" or "PKG-INFO"). N)r`ra)rAr`rarrrr?s zNoneMetadataError.__init__cCsd|j|jS)Nz+None {} metadata found for distribution: {})formatrar`rCrrr__str__szNoneMetadataError.__str__r-r.r/r0rMr?rdrrrrr_s  r_c@seZdZdZdefddZdS)UserInstallationInvalidzBA --user install is requested on an environment without user site.rcCdS)Nz$User base directory is not specifiedrrCrrrrdzUserInstallationInvalid.__str__N)r-r.r/r0rMrdrrrrrfsrfc@seZdZdefddZdS)InvalidSchemeCombinationrcCs6ddd|jddD}d|d|jddS)Nz, css|]}t|VqdSN)rM).0arrr z3InvalidSchemeCombination.__str__..z Cannot set z and z together)r&args)rAbeforerrrrdsz InvalidSchemeCombination.__str__N)r-r.r/rMrdrrrrrisric@r*)DistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementNr,rrrrrrr1rrc@r*)RequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.Nr,rrrrrs r1rsc@r*)BestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.Nr,rrrrrtr1rtc@r*) BadCommandz0Raised when virtualenv or a command is not foundNr,rrrrrur1ruc@r*) CommandErrorz7Raised when there is an error in command-line argumentsNr,rrrrrvr1rvc@r*)PreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryNr,rrrrrwr1rwc sDeZdZdZ d dedededdffdd Zdefd d ZZ S) NetworkConnectionErrorzHTTP connection errorN error_msgresponserequestrcsJ||_||_||_|jdur|jst|dr|jj|_t|||dS)zc Initialize NetworkConnectionError with `request` and `response` objects. Nr{)rzr{ryr=r>r?)rAryrzr{rBrrr?"s  zNetworkConnectionError.__init__cC t|jSrj)rMryrCrrrrd4 zNetworkConnectionError.__str__)NN) r-r.r/r0rMr r r?rdrOrrrBrrxsrxc@r*)InvalidWheelFilenamezInvalid wheel filename.Nr,rrrrr~8r1r~c@r*)UnsupportedWheelzUnsupported wheel.Nr,rrrrr<r1rc@s0eZdZdZdedefddZdefddZd S) InvalidWheelzInvalid (e.g. corrupt) wheel.locationnamecCs||_||_dSrj)rr)rArrrrrr?Cs zInvalidWheel.__init__rcCsd|jd|jdS)NzWheel 'z ' located at z is invalid.)rrrCrrrrdGszInvalidWheel.__str__Nrerrrrr@src @s<eZdZdZdddedededdf d d Zdefd d ZdS) MetadataInconsistentzBuilt metadata contains inconsistent information. This is raised when the metadata contains values (e.g. name and version) that do not match the information previously obtained from sdist filename or user-supplied ``#egg=`` value. ireqrfieldf_valm_valrNcCs||_||_||_||_dSrj)rrrr)rArrrrrrrr?Ss zMetadataInconsistent.__init__cCsd}||j|j|j|jS)NzJRequested {} has inconsistent {}: filename has {!r}, but metadata has {!r})rcrrrr)rAtemplaterrrrd[szMetadataInconsistent.__str__rerrrrrKs rcrS)LegacyInstallFailurez1Error occurred while executing `setup.py install`zlegacy-install-failurepackage_detailsrNcstjd|ddddS)Nz2Encountered error while trying to install package.z&See above for output from the failure.rWr8r9r:r6)r>r?rArrBrrr?hs  zLegacyInstallFailure.__init__r[rrrBrrcr\rcsLeZdZdZdZdededeeeddffdd Z defd d Z Z S) InstallationSubprocessErrorzA subprocess call failed.zsubprocess-exited-with-errorcommand_description exit_code output_linesrNcst|dur td}ntdt|dtd|td}tjdt|d||ddd ||_||_dS) NzSee above for output.z[red][z lines of output][/] rIz[red]\[end of output][/]z[green]z)[/] did not run successfully. exit code: zNThis error originates from a subprocess, and is likely not a problem with pip.r) r from_markuplenr&r>r?rrr)rArrr output_promptrBrrr?vs$    z$InstallationSubprocessError.__init__cCs|jd|jS)Nz exited with )rrrCrrrrdsz#InstallationSubprocessError.__str__) r-r.r/r0r3rMintrrr?rdrOrrrBrrqs  rcs8eZdZdZdeddffdd ZdefddZZS) MetadataGenerationFailedzmetadata-generation-failedrrNcs tt|jdt|ddddS)Nz4Encountered error while generating package metadata.zSee above for details.rWr)r>rr?rrrBrrr?s  z!MetadataGenerationFailed.__init__cCrg)Nzmetadata generation failedrrCrrrrdrhz MetadataGenerationFailed.__str__)r-r.r/r3rMr?rdrOrrrBrrs rc@s@eZdZdZdddZddd Zdefd d Zdefd d Z dS) HashErrorsz:Multiple HashError instances rolled into one for reportingrNcCs g|_dSrj)errorsrCrrrr?r}zHashErrors.__init__r4 HashErrorcCs|j|dSrj)rappend)rAr4rrrrrzHashErrors.appendcCsbg}|jjdddt|jddD]\}}||j|dd|Dq|r/d|SdS) NcS|jSrj)ordererrrz$HashErrors.__str__..)keycSrrjrBrrrrrrcss|]}|VqdSrj)bodyrkrrrrrmrnz%HashErrors.__str__..r"rI)rsortrrheadextendr&)rAlinescls errors_of_clsrrrrds  zHashErrors.__str__cCr|rj)boolrrCrrr__bool__r}zHashErrors.__bool__)rN)r4rrN) r-r.r/r0r?rrMrdrrrrrrrs    rc@s\eZdZUdZdZeded<dZdZe ed<de fd d Z de fd d Z de fd dZ dS)ra A failure to verify a package against known-good hashes :cvar order: An int sorting hash exception classes by difficulty of recovery (lower being harder), so the user doesn't bother fretting about unpinned packages when he has deeper issues, like VCS dependencies, to deal with. Also keeps error reports in a deterministic order. :cvar head: A section heading for display above potentially many exceptions of this kind :ivar req: The InstallRequirement that triggered this error. This is pasted on after the exception is instantiated, because it's not typically available earlier. NrreqrIrorrcCsd|S)a=Return a summary of me for display under the heading. This default implementation simply prints a description of the triggering requirement. :param req: The InstallRequirement that provoked this error, with its link already populated by the resolver's _populate_link(). z )_requirement_namerCrrrrs zHashError.bodycCs|jd|S)Nr")rrrCrrrrdzHashError.__str__cCs|jrt|jSdS)zReturn a description of the requirement that triggered me. This default implementation returns long description of the req, with line numbers unknown package)rrMrCrrrrszHashError._requirement_name)r-r.r/r0rrrNrrrrMrrdrrrrrrs   rc@eZdZdZdZdZdS)VcsHashUnsupporteduA hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.rzlCan't verify hashes for these requirements because we don't have a way to hash version control repositories:Nr-r.r/r0rrrrrrr rc@r)DirectoryUrlHashUnsupportedrzUCan't verify hashes for these file:// requirements because they point to directories:Nrrrrrrrrc@s8eZdZdZdZdZdeddfddZdefd d ZdS) HashMissingz2A hash was needed for a requirement but is absent.awHashes are required in --require-hashes mode, but they are missing from some requirements. Here is a list of those requirements along with the hashes their downloaded archives actually had. Add lines like these to your requirements files to prevent tampering. (If you did not enable --require-hashes manually, note that it turns on automatically when any package has a hash.) gotten_hashrNcCs ||_dS)zq :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded N)r)rArrrrr?s zHashMissing.__init__cCsHddlm}d}|jr|jjr|jjnt|jdd}d|pd||jS)Nr) FAVORITE_HASHrz {} --hash={}:{}r)pip._internal.utils.hashesrr original_linkgetattrrcr)rArrUrrrrs   zHashMissing.body) r-r.r/r0rrrMr?rrrrrrs rc@r) HashUnpinnedzPA requirement had a hash specified but was not pinned to a specific version.zaIn --require-hashes mode, all requirements must have their versions pinned with ==. These do not:Nrrrrrr2rrc@s^eZdZdZdZdZdeeeefdeedfddfd d Z defd d Z defd dZ dS) HashMismatchz Distribution file hash values don't match. :ivar package_name: The name of the package that triggered the hash mismatch. Feel free to write to this after the exception is raise to improve its error message. zTHESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.allowedgotsrrNcCrb)z :param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the files under suspicion N)rr)rArrrrrr?Os zHashMismatch.__init__cCsd||S)Nz {}: {})rcr_hash_comparisonrCrrrrYrzHashMismatch.bodycsndtddfdd}g}|jD]!\}}|||fdd|D|d|j|qd |S) aE Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef hash_namerz chain[str]cSst|gtdS)Nz or)rr)rrrr hash_then_orhsz3HashMismatch._hash_comparison..hash_then_orc3s |] }dt|VqdS)z Expected {} {}N)rcnextrrrrrmps z0HashMismatch._hash_comparison..z Got {} r") rMritemsrrrcr hexdigestr&)rArrr expectedsrrrr\s  zHashMismatch._hash_comparison) r-r.r/r0rrrrMrr?rrrrrrr=s * rc@r*)UnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.Nr,rrrrryr1rc sReZdZdZ   d dedeedeejddffdd Zdefd d Z Z S) !ConfigurationFileCouldNotBeLoadedz8When there are errors while loading a configuration filecould not be loadedNr^fnamer4rcs"t|||_||_||_dSrj)r>r?r^rr4)rAr^rr4rBrrr?s  z*ConfigurationFileCouldNotBeLoaded.__init__cCsF|jdur d|jd}n|jdusJd|jd}d|j|S)Nz in .z. r"zConfiguration file )rr4r^)rA message_partrrrrds z)ConfigurationFileCouldNotBeLoaded.__str__)rNN) r-r.r/r0rMr configparserErrorr?rdrOrrrBrr~s r)Er0rr itertoolsrrrtypingrrrrr pip._vendor.requests.modelsr r pip._vendor.rich.consoler r rpip._vendor.rich.markuprpip._vendor.rich.textrhashlibrrpip._internal.metadatarpip._internal.req.req_installrrMrrr) Exceptionr+r2rPrQrRrTr]r_rfrirrrsrtrurvrwrxr~rrrrrrrrrrrrrrrrrrrsv        v ).  * <