3 (\#@sdZddlmZddlmZmZmZddlmZddl m Z e rXddl m Z ddl mZGdd d eZGd d d eZGd d d eZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGd d!d!eZGd"d#d#eZGd$d%d%eZGd&d'd'eZGd(d)d)eZ Gd*d+d+eZ!Gd,d-d-eZ"Gd.d/d/eZ#Gd0d1d1eZ$d2S)3z"Exceptions used throughout package)absolute_import)chaingroupbyrepeat) iteritems)MYPY_CHECK_RUNNING)Optional)InstallRequirementc@seZdZdZdS)PipErrorzBase pip exceptionN)__name__ __module__ __qualname____doc__rrk/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/pip/_internal/exceptions.pyr sr c@seZdZdZdS)ConfigurationErrorz"General exception in configurationN)r r r rrrrrrsrc@seZdZdZdS)InstallationErrorz%General exception during installationN)r r r rrrrrrsrc@seZdZdZdS)UninstallationErrorz'General exception during uninstallationN)r r r rrrrrrsrc@seZdZdZdS)DistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementN)r r r rrrrrrsrc@seZdZdZdS)RequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.N)r r r rrrrrr#src@seZdZdZdS)BestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.N)r r r rrrrrr'src@seZdZdZdS) BadCommandz0Raised when virtualenv or a command is not foundN)r r r rrrrrr,src@seZdZdZdS) CommandErrorz7Raised when there is an error in command-line argumentsN)r r r rrrrrr0src@seZdZdZdS)PreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryN)r r r rrrrrr4src@seZdZdZdS)InvalidWheelFilenamezInvalid wheel filename.N)r r r rrrrrr8src@seZdZdZdS)UnsupportedWheelzUnsupported wheel.N)r r r rrrrrr<src@s8eZdZdZddZddZddZdd Zd d Zd S) HashErrorsz:Multiple HashError instances rolled into one for reportingcCs g|_dS)N)errors)selfrrr__init__CszHashErrors.__init__cCs|jj|dS)N)rappend)rerrorrrrr FszHashErrors.appendcCsfg}|jjdddxKsz$HashErrors.__str__..)keycSs|jS)N) __class__)r#rrrr$Lscss|]}|jVqdS)N)body).0r#rrr Nsz%HashErrors.__str__.. )rsortrr headextendjoin)rlinescls errors_of_clsrrr__str__Is zHashErrors.__str__cCs t|jS)N)boolr)rrrr __nonzero__RszHashErrors.__nonzero__cCs|jS)N)r4)rrrr__bool__UszHashErrors.__bool__N) r r r rrr r2r4r5rrrrr@s  rc@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. NcCs d|jS)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 populate_link() having already been called z %s)_requirement_name)rrrrr'ls zHashError.bodycCsd|j|jfS)Nz%s %s)r,r')rrrrr2xszHashError.__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 zunknown package)reqstr)rrrrr8{szHashError._requirement_name) r r r rr9r,r'r2r8rrrrr6Ys  r6c@seZdZdZdZdZdS)VcsHashUnsupportedzuA 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:N)r r r rr"r,rrrrr;sr;c@seZdZdZdZdZdS)DirectoryUrlHashUnsupportedzuA hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.zUCan't verify hashes for these file:// requirements because they point to directories:N)r r r rr"r,rrrrr<sr<c@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)rr@rrrrszHashMissing.__init__cCsHddlm}d}|jr4|jjr&|jjn t|jdd}d|ps r>c@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:N)r r r rr"r,rrrrrEsrEc@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)rrIrJrrrrszHashMismatch.__init__cCsd|j|jfS)Nz %s: %s)r8_hash_comparison)rrrrr'szHashMismatch.bodycsjdd}g}xRt|jD]D\}}|||jfdd|D|jd|j|jdqWdj|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|fVqdS)z Expected %s %sN)next)r(r#)prefixrrr)sz0HashMismatch._hash_comparison..z Got %s z orr*)rrIr-r rJ hexdigestr.)rrMr/rL expectedsr)rOrrKs  zHashMismatch._hash_comparisonN) r r r rr"r,rr'rKrrrrrGs  rGc@seZdZdZdS)UnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.N)r r r rrrrrrRsrRcs*eZdZdZdfdd ZddZZS) !ConfigurationFileCouldNotBeLoadedz=When there are errors while loading a configuration file could not be loadedNcs&tt|j|||_||_||_dS)N)superrSrreasonfnamer!)rrVrWr!)r&rrrsz*ConfigurationFileCouldNotBeLoaded.__init__cCsB|jdk rdj|j}n|jdk s&tdj|jj}dj|j|S)Nz in {}.z. {} zConfiguration file {}{})rWformatr!AssertionErrormessagerV)rZ message_partrrrr2 s  z)ConfigurationFileCouldNotBeLoaded.__str__)rTNN)r r r rrr2 __classcell__rr)r&rrSsrSN)%r __future__r itertoolsrrrpip._vendor.sixrZpip._internal.utils.typingrZtypingrZpip._internal.req.req_installr Exceptionr rrrrrrrrrrrrr6r;r<r>rErGrRrSrrrrs8     ,  % 8