U n aD(@sdZddlmZddlmZmZmZddlmZddl m Z e rdddl m Z ddl mZddlmZGd d d eZGd d d eZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZGd#d$d$eZGd%d&d&eZ Gd'd(d(e Z!Gd)d*d*e Z"Gd+d,d,e Z#Gd-d.d.e Z$Gd/d0d0e Z%Gd1d2d2eZ&Gd3d4d4eZ'd5S)6z"Exceptions used throughout package)absolute_import)chaingroupbyrepeat) iteritems)MYPY_CHECK_RUNNING)Optional) Distribution)InstallRequirementc@seZdZdZdS)PipErrorzBase pip exceptionN__name__ __module__ __qualname____doc__rrYC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\exceptions.pyr sr c@seZdZdZdS)ConfigurationErrorz"General exception in configurationNr rrrrrsrc@seZdZdZdS)InstallationErrorz%General exception during installationNr rrrrrsrc@seZdZdZdS)UninstallationErrorz'General exception during uninstallationNr rrrrr src@s eZdZdZddZddZdS)NoneMetadataErrora Raised when accessing "METADATA" or "PKG-INFO" metadata for a pip._vendor.pkg_resources.Distribution object and `dist.has_metadata('METADATA')` returns True but `dist.get_metadata('METADATA')` returns None (and similarly for "PKG-INFO"). cCs||_||_dS)z :param dist: A Distribution object. :param metadata_name: The name of the metadata being accessed (can be "METADATA" or "PKG-INFO"). N)dist metadata_name)selfrrrrr__init__-szNoneMetadataError.__init__cCsd|j|jS)Nz+None {} metadata found for distribution: {})formatrrrrrr__str__7s zNoneMetadataError.__str__N)r rrrrrrrrrr$s rc@seZdZdZdS)DistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementNr rrrrrBsrc@seZdZdZdS)RequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.Nr rrrrrFsrc@seZdZdZdS)BestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.Nr rrrrr Jsr c@seZdZdZdS) BadCommandz0Raised when virtualenv or a command is not foundNr rrrrr!Osr!c@seZdZdZdS) CommandErrorz7Raised when there is an error in command-line argumentsNr rrrrr"Ssr"c@seZdZdZdS)PreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryNr rrrrr#Wsr#c@seZdZdZdS)InvalidWheelFilenamezInvalid wheel filename.Nr rrrrr$[sr$c@seZdZdZdS)UnsupportedWheelzUnsupported wheel.Nr rrrrr%_sr%c@s8eZdZdZddZddZddZdd Zd d Zd S) HashErrorsz:Multiple HashError instances rolled into one for reportingcCs g|_dSN)errorsrrrrrfszHashErrors.__init__cCs|j|dSr')r(append)rerrorrrrr)iszHashErrors.appendcCsbg}|jjdddt|jddD](\}}||j|dd|Dq&|r^d|SdS)NcSs|jSr')ordererrrnz$HashErrors.__str__..)keycSs|jSr' __class__r,rrrr.or/css|]}|VqdSr')body.0r-rrr qsz%HashErrors.__str__.. )r(sortrr)headextendjoin)rlinescls errors_of_clsrrrrls zHashErrors.__str__cCs t|jSr')boolr(rrrr __nonzero__uszHashErrors.__nonzero__cCs|Sr')r@rrrr__bool__xszHashErrors.__bool__N) r rrrrr)rr@rArrrrr&cs  r&c@s0eZdZdZdZdZddZddZdd ZdS) HashErrora 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. NcCsd|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 {})r_requirement_namerrrrr3s zHashError.bodycCsd|j|S)Nz{} {})rr9r3rrrrrszHashError.__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)reqstrrrrrrDszHashError._requirement_name) r rrrrFr9r3rrDrrrrrB|s  rBc@seZdZdZdZdZdS)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 rrrr+r9rrrrrHsrHc@seZdZdZdZdZdS)DirectoryUrlHashUnsupportedrIzUCan't verify hashes for these file:// requirements because they point to directories:NrJrrrrrKsrKc@s(eZdZdZdZdZddZddZdS) 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.)cCs ||_dS)zq :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded N) gotten_hash)rrOrrrrszHashMissing.__init__cCsHddlm}d}|jr4|jjr&|jjn t|jdd}d|p>d||jS)Nr) FAVORITE_HASHrFz {} --hash={}:{}rE)pip._internal.utils.hashesrPrF original_linkgetattrrrO)rrPpackagerrrr3s   zHashMissing.bodyN)r rrrr+r9rr3rrrrrMs rMc@seZdZdZdZdZdS) 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:NrJrrrrrUsrUc@s0eZdZdZdZdZddZddZdd Zd S) 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.cCs||_||_dS)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)allowedgots)rrYrZrrrrszHashMismatch.__init__cCsd||S)Nz {}: {})rrD_hash_comparisonrrrrr3s zHashMismatch.bodycsddd}g}t|jD]B\}}|||fdd|D|d|j|qd|S)aE Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef cSst|gtdS)Nz or)rr) hash_namerrr hash_then_orsz3HashMismatch._hash_comparison..hash_then_orc3s|]}dt|VqdS)z Expected {} {}N)rnextr4prefixrrr6sz0HashMismatch._hash_comparison..z Got {} r7)rrYr:r)rrZ hexdigestr;)rr]r<r\ expectedsrr_rr[s  zHashMismatch._hash_comparisonN) r rrrr+r9rr3r[rrrrrWs  rWc@seZdZdZdS)UnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.Nr rrrrrcsrccs*eZdZdZdfdd ZddZZS) !ConfigurationFileCouldNotBeLoadedz=When there are errors while loading a configuration file could not be loadedNcs&tt||||_||_||_dSr')superrdrreasonfnamer*)rrgrhr*r1rrr(sz*ConfigurationFileCouldNotBeLoaded.__init__cCsB|jdk rd|j}n|jdk s&td|jj}d|j|S)Nz in {}.z. {} zConfiguration file {}{})rhrr*AssertionErrormessagerg)r message_partrrrr.s  z)ConfigurationFileCouldNotBeLoaded.__str__)reNN)r rrrrr __classcell__rrr1rrd$srdN)(r __future__r itertoolsrrrZpip._vendor.sixrpip._internal.utils.typingrtypingrZpip._vendor.pkg_resourcesr Zpip._internal.req.req_installr Exceptionr rrrrrrr r!r"r#r$r%r&rBrHrKrMrUrWrcrdrrrrs<      ,  % 7