U ja4@s$dZddlZddlmZmZmZddlmZmZm Z m Z ddl m Z ddl mZmZerpddlmZddlmZGd d d eZGd d d eZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZ Gd!d"d"eZ!Gd#d$d$eZ"Gd%d&d&eZ#Gd'd(d(eZ$Gd)d*d*eZ%Gd+d,d,eZ&Gd-d.d.eZ'Gd/d0d0eZ(Gd1d2d2e(Z)Gd3d4d4e(Z*Gd5d6d6e(Z+Gd7d8d8e(Z,Gd9d:d:e(Z-Gd;d<dd>eZ/dS)?z"Exceptions used throughout packageN)chaingroupbyrepeat) TYPE_CHECKINGDictListOptional) Distribution)RequestResponse)_Hash)InstallRequirementc@seZdZdZdS)PipErrorzBase pip exceptionN__name__ __module__ __qualname____doc__rrp/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-bug3gbve/pip/_internal/exceptions.pyrsrc@seZdZdZdS)ConfigurationErrorz"General exception in configurationNrrrrrrsrc@seZdZdZdS)InstallationErrorz%General exception during installationNrrrrrrsrc@seZdZdZdS)UninstallationErrorz'General exception during uninstallationNrrrrrrsrc@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__3s zNoneMetadataError.__str__Nrrrrrr rrrrr s rc@seZdZdZddZdS)UserInstallationInvalidzBA --user install is requested on an environment without user site.cCsdS)Nz$User base directory is not specifiedrrrrrr AszUserInstallationInvalid.__str__N)rrrrr rrrrr">sr"c@seZdZddZdS)InvalidSchemeCombinationcCs6ddd|jddD}d|d|jddS)Nz, css|]}t|VqdSN)str).0arrr Isz3InvalidSchemeCombination.__str__..z Cannot set z and z together)joinargs)rbeforerrrr Gsz InvalidSchemeCombination.__str__N)rrrr rrrrr#Fsr#c@seZdZdZdS)DistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementNrrrrrr-Msr-c@seZdZdZdS)RequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.Nrrrrrr.Qsr.c@seZdZdZdS)BestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.Nrrrrrr/Usr/c@seZdZdZdS) BadCommandz0Raised when virtualenv or a command is not foundNrrrrrr0Zsr0c@seZdZdZdS) CommandErrorz7Raised when there is an error in command-line argumentsNrrrrrr1^sr1c@seZdZdZdS)PreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryNrrrrrr2bsr2cs*eZdZdZdfdd ZddZZS)NetworkConnectionErrorzHTTP connection errorNcsJ||_||_||_|jdk r6|js6t|dr6|jj|_t|||dS)zc Initialize NetworkConnectionError with `request` and `response` objects. Nrequest)responser4 error_msghasattrsuperr)rr6r5r4 __class__rrris zNetworkConnectionError.__init__cCs t|jSr$)r%r6rrrrr wszNetworkConnectionError.__str__)NNrrrrrr __classcell__rrr9rr3fsr3c@seZdZdZdS)InvalidWheelFilenamezInvalid wheel filename.Nrrrrrr=|sr=c@seZdZdZdS)UnsupportedWheelzUnsupported wheel.Nrrrrrr>sr>c@s eZdZdZddZddZdS)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. cCs||_||_||_||_dSr$)ireqfieldf_valm_val)rr@rArBrCrrrrszMetadataInconsistent.__init__cCsd}||j|j|j|jS)NzJRequested {} has inconsistent {}: filename has {!r}, but metadata has {!r})rr@rArBrC)rtemplaterrrr szMetadataInconsistent.__str__Nr!rrrrr?sr?c@s eZdZdZddZddZdS)InstallationSubprocessErrorz-A subprocess call failed during installation.cCs||_||_dSr$) returncode description)rrFrGrrrrsz$InstallationSubprocessError.__init__cCsd|j|jS)NzSCommand errored out with exit status {}: {} Check the logs for full command output.)rrFrGrrrrr s z#InstallationSubprocessError.__str__Nr!rrrrrEsrEc@s8eZdZdZddZddZddZdd Zd d Zd S) HashErrorsz:Multiple HashError instances rolled into one for reportingcCs g|_dSr$)errorsrrrrrszHashErrors.__init__cCs|j|dSr$)rIappend)rerrorrrrrJszHashErrors.appendcCsbg}|jjdddt|jddD](\}}||j|dd|Dq&|r^d|SdS) NcSs|jSr$)ordererrrz$HashErrors.__str__..)keycSs|jSr$r9rMrrrrOrPcss|]}|VqdSr$)bodyr&rNrrrr(sz%HashErrors.__str__.. )rIsortrrJheadextendr*)rlinescls errors_of_clsrrrr s  zHashErrors.__str__cCs t|jSr$)boolrIrrrr __nonzero__szHashErrors.__nonzero__cCs|Sr$)r]rrrr__bool__szHashErrors.__bool__N) rrrrrrJr r]r^rrrrrHs  rHc@s4eZdZdZdZdZdZddZddZd d Z dS) 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. NrUr)cCsd|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_namerrrrrRs zHashError.bodycCs|jd|S)NrT)rWrRrrrrr szHashError.__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)reqr%rrrrr`szHashError._requirement_name) rrrrrbrWrLrRr r`rrrrr_s r_c@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:NrrrrrLrWrrrrrcsrcc@seZdZdZdZdZdS)DirectoryUrlHashUnsupportedrdzUCan't verify hashes for these file:// requirements because they point to directories:Nrerrrrrfsrfc@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)rrjrrrrszHashMissing.__init__cCsHddlm}d}|jr4|jjr&|jjn t|jdd}d|p>d||jS)Nr) FAVORITE_HASHrbz {} --hash={}:{}ra)pip._internal.utils.hashesrkrb original_linkgetattrrrj)rrkpackagerrrrRs   zHashMissing.bodyN)rrrrrLrWrrRrrrrrh s rhc@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:Nrerrrrrp2srpc@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)rrtrurrrrJszHashMismatch.__init__cCsd||S)Nz {}: {})rr`_hash_comparisonrrrrrRUs zHashMismatch.bodycsddd}g}|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_orfsz3HashMismatch._hash_comparison..hash_then_orc3s|]}dt|VqdS)z Expected {} {}N)rnextrSprefixrrr(osz0HashMismatch._hash_comparison..z Got {} rT)rtitemsrXrJrru hexdigestr*)rrxrYrw expectedsrrzrrvZs  zHashMismatch._hash_comparisonN) rrrrrLrWrrRrvrrrrrr;s  rrc@seZdZdZdS)UnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.Nrrrrrrvsrcs*eZdZdZdfdd ZddZZS) !ConfigurationFileCouldNotBeLoadedz=When there are errors while loading a configuration file could not be loadedNcs"t|||_||_||_dSr$)r8rreasonfnamerK)rrrrKr9rrrs z*ConfigurationFileCouldNotBeLoaded.__init__cCsF|jdk rd|jd}n|jdk s(td|jd}d|j|S)Nz in .z. rTzConfiguration file )rrKAssertionErrorr)r message_partrrrr s  z)ConfigurationFileCouldNotBeLoaded.__str__)rNNr;rrr9rr{sr)0r configparser itertoolsrrrtypingrrrrZpip._vendor.pkg_resourcesr Zpip._vendor.requests.modelsr r hashlibr Zpip._internal.req.req_installr Exceptionrrrrrr"r#r-r.r/r0r1r2r3r=r>r?rErHr_rcrfrhrprrrrrrrrsF   0  ' ;