U 巀gqg@s~dZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z mZmZmZmZmZmZddlmZddlmZddlmZmZmZddlmZdd lmZe rdd l m!Z!dd l"m#Z#m$Z$dd l%m&Z&dd l'm(Z(e)e*Z+e,e-dddZ.eee,fee,e,edddZ/Gddde0Z1Gddde1Z2Gddde1Z3Gddde1Z4Gddde2Z5Gddde2Z6Gd d!d!e1Z7Gd"d#d#e4Z8Gd$d%d%e4Z9Gd&d'd'e4Z:Gd(d)d)e4Z;Gd*d+d+e1ZGd0d1d1e1Z?Gd2d3d3e1Z@Gd4d5d5e4ZAGd6d7d7e4ZBGd8d9d9e4ZCGd:d;d;e4ZDGdd?d?e2e4ZFGd@dAdAeFe4ZGGdBdCdCe4ZHGdDdEdEe4ZIGdFdGdGeIZJGdHdIdIeIZKGdJdKdKeIZLGdLdMdMeIZMGdNdOdOeIZNGdPdQdQe4ZOGdRdSdSe3ZPdTejQdUZRGdVdWdWe2ZSGdXdYdYe2ZTGdZd[d[e2ZUGd\d]d]e2ZVdS)^zExceptions 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_CHECKINGDictIteratorListLiteralOptionalUnion)InvalidRequirement)InvalidVersion)ConsoleConsoleOptions RenderResult)escape)Text)_Hash)RequestResponse)BaseDistribution)InstallRequirement)sreturncCstd|dk S)Nz^[a-z]+(-[a-z]+)*$)rematch)rrF/opt/hc_python/lib/python3.8/site-packages/pip/_internal/exceptions.py_is_kebab_case&sr)rconsoleprefixindentrcCsJt|tr|}n ||}|j|dd|jd|dd|jddS)Nignore)overflow T) allow_blank) isinstancer render_strjoinsplit)rrr r!textrrr_prefix_with_indent*s   r+c@seZdZdZdS)PipErrorzThe base pip error.N__name__ __module__ __qualname____doc__rrrrr,;sr,c seZdZUdZeed<ddddddeeeeefeeeefeeeefeeeefeeddfdd Z ed d d Z e e e d ddZZS)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_stmtlinkzLiteral["error", "warning"])r5r3messagecontext hint_stmtr6r7rcs~|dkr t|dstd|j}t|s0td||_||_||_||_||_||_||_ t d|j j d|jddS)Nr3zerror reference not provided!z#error reference must be kebab-case!)hasattrAssertionErrorr3rr5r8r9r6r:r7super__init__ __class__r.)selfr5r3r8r9r:r6r7rArrr@Ls zDiagnosticPipError.__init__rc Cs8d|jjd|jd|jd|jd|jd|jd S)Nr;z (reference=z , message=z , context=z , note_stmt=z , hint_stmt=z)>)rAr.r3r8r9r6r:rBrrr__repr__js6zDiagnosticPipError.__repr__)roptionsrccsB|jdkrdnd}d|d|jd|jdVdV|js|jdk rt|j|d|d d|d d Vt|j|d|d d|d d Vqt|j|ddd Vn |jV|jdk rdV|jV|jdk s|jdk rdV|jdk rt|j|ddd V|jdk rt|j|ddd V|jdk r>dVd|jVdS)Nr4redyellow[z bold]z [/]: [bold]z[/]u]×[/] u]│[/] )r r!u ]╰─>[/] z] [/] u [red]×[/] z z[magenta bold]note[/]: z z[cyan bold]hint[/]: zLink: ) r5r3 ascii_onlyr9r+r8r6r:r7)rBrrGcolourrrr__rich_console__us\          z#DiagnosticPipError.__rich_console__)r.r/r0r1str__annotations__r r rr@rFrrrrN __classcell__rrrCrr2?s*    r2c@seZdZdZdS)ConfigurationErrorz"General exception in configurationNr-rrrrrRsrRc@seZdZdZdS)InstallationErrorz%General exception during installationNr-rrrrrSsrScs,eZdZdZdZeddfdd ZZS)MissingPyProjectBuildRequireszNRaised when pyproject.toml has `build-system`, but no `build-system.requires`.z'missing-pyproject-build-system-requiresN)packagercs*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)rBrUrCrrr@s z&MissingPyProjectBuildRequires.__init__r.r/r0r1r3rOr@rQrrrCrrTsrTcs.eZdZdZdZeeddfdd ZZS)InvalidPyProjectBuildRequiresz>Raised when pyproject.toml an invalid `build-system.requires`.z'invalid-pyproject-build-system-requiresN)rUreasonrcs0tjdt|td|dtdddS)NrVzKThis package has an invalid `build-system.requires` key in pyproject.toml. rWrXrYrZ)rBrUr]rCrrr@s z&InvalidPyProjectBuildRequires.__init__r[rrrCrr\sr\c@s0eZdZdZdeddddZeddd 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. rN)dist metadata_namercCs||_||_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_r`)rBr_r`rrrr@s zNoneMetadataError.__init__rDcCsd|jd|jS)NzNone z" metadata found for distribution: )r`r_rErrr__str__szNoneMetadataError.__str__r.r/r0r1rOr@rarrrrr^s   r^c@seZdZdZedddZdS)UserInstallationInvalidzBA --user install is requested on an environment without user site.rDcCsdS)Nz$User base directory is not specifiedrrErrrraszUserInstallationInvalid.__str__N)r.r/r0r1rOrarrrrrcsrcc@seZdZedddZdS)InvalidSchemeCombinationrDcCs6ddd|jddD}d|d|jddS)Nz, css|]}t|VqdSN)rO).0arrr sz3InvalidSchemeCombination.__str__..z Cannot set z and z together)r(args)rBbeforerrrrasz InvalidSchemeCombination.__str__N)r.r/r0rOrarrrrrdsrdc@seZdZdZdS)DistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementNr-rrrrrlsrlc@seZdZdZdS)RequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.Nr-rrrrrm srmc@seZdZdZdS)BestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.Nr-rrrrrnsrnc@seZdZdZdS) BadCommandz0Raised when virtualenv or a command is not foundNr-rrrrrosroc@seZdZdZdS) CommandErrorz7Raised when there is an error in command-line argumentsNr-rrrrrpsrpc@seZdZdZdS)PreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryNr-rrrrrqsrqcsDeZdZdZd eededddfdd Zedd d ZZS) NetworkConnectionErrorzHTTP connection errorNrr) error_msgresponserequestrcsJ||_||_||_|jdk r6|js6t|dr6|jj|_t|||dS)zc Initialize NetworkConnectionError with `request` and `response` objects. Nru)rtrursr=r?r@)rBrsrtrurCrrr@$s  zNetworkConnectionError.__init__rDcCs t|jSre)rOrsrErrrra9szNetworkConnectionError.__str__)NN) r.r/r0r1rOr r@rarQrrrCrrr!srrc@seZdZdZdS)InvalidWheelFilenamezInvalid wheel filename.Nr-rrrrrv=srvc@seZdZdZdS)UnsupportedWheelzUnsupported wheel.Nr-rrrrrwAsrwc@s.eZdZdZeedddZedddZdS) InvalidWheelzInvalid (e.g. corrupt) wheel.locationnamecCs||_||_dSrery)rBrzr{rrrr@HszInvalidWheel.__init__rDcCsd|jd|jdS)NzWheel 'z ' located at z is invalid.)r{rzrErrrraLszInvalidWheel.__str__NrbrrrrrxEsrxc@s4eZdZdZdeeeddddZeddd ZdS) MetadataInconsistentaBuilt 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, user-supplied ``#egg=`` value, or an install requirement name. rN)ireqfieldf_valm_valrcCs||_||_||_||_dSrer}r~rr)rBr}r~rrrrrr@XszMetadataInconsistent.__init__rDcCs$d|jd|jd|jd|jS)N Requested z has inconsistent z : expected z, but metadata has rrErrrra`s"zMetadataInconsistent.__str__rbrrrrr|Ps r|c@s0eZdZdZdeddddZeddd ZdS) MetadataInvalidzMetadata is invalid.rN)r}r4rcCs||_||_dSrer}r4)rBr}r4rrrr@jszMetadataInvalid.__init__rDcCsd|jd|jS)Nrz has invalid metadata: rrErrrranszMetadataInvalid.__str__rbrrrrrgsrcsFeZdZdZdZeeeeeddfdd Z eddd Z Z S) InstallationSubprocessErrorzA subprocess call failed.zsubprocess-exited-with-errorN)command_description exit_code output_linesrcst|dkrtd}n.tdt|dtd|td}tjdt|d||ddd ||_||_dS) NzSee above for output.z[red][z lines of output][/] rKz[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.r8r9r:r6) r from_markuplenr(r?r@rrr)rBrrr output_promptrCrrr@ws    z$InstallationSubprocessError.__init__rDcCs|jd|jS)Nz exited with )rrrErrrrasz#InstallationSubprocessError.__str__) r.r/r0r1r3rOintr rr@rarQrrrCrrrs  rcs6eZdZdZeddfdd ZedddZZS) MetadataGenerationFailedzmetadata-generation-failedN)package_detailsrcs tt|jdt|ddddS)Nz4Encountered error while generating package metadata.zSee above for details.rWr)r?rr@r)rBrrCrrr@s  z!MetadataGenerationFailed.__init__rDcCsdS)Nzmetadata generation failedrrErrrrasz MetadataGenerationFailed.__str__)r.r/r0r3rOr@rarQrrrCrrs  rc@sJeZdZdZddddZddddd Zedd d Zedd d Z dS) HashErrorsz:Multiple HashError instances rolled into one for reportingNrDcCs g|_dSre)errorsrErrrr@szHashErrors.__init__ HashErrorr4rcCs|j|dSre)rappend)rBr4rrrrszHashErrors.appendcCsbg}|jjdddt|jddD](\}}||j|dd|Dq&|r^d|SdS) NcSs|jSre)ordererrrz$HashErrors.__str__..)keycSs|jSrerCrrrrrrcss|]}|VqdSre)bodyrfrrrrrhsz%HashErrors.__str__..r$rK)rsortrrheadextendr()rBlinescls errors_of_clsrrrras  zHashErrors.__str__cCs t|jSre)boolrrErrr__bool__szHashErrors.__bool__) r.r/r0r1r@rrOrarrrrrrrs  rc@s\eZdZUdZdZeded<dZdZe ed<e dd d Z e dd d Z e dd 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. NrreqrKrirrDcCsd|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().  )_requirement_namerErrrrs zHashError.bodycCs|jd|S)Nr$)rrrErrrraszHashError.__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)rrOrErrrrszHashError._requirement_name)r.r/r0r1rr rPrrrrOrrarrrrrrs   rc@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.r/r0r1rrrrrrrsrc@seZdZdZdZdZdS)DirectoryUrlHashUnsupportedrzUCan't verify hashes for these file:// requirements because they point to directories:Nrrrrrrsrc@s6eZdZdZdZdZeddddZedd 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.)N) gotten_hashrcCs ||_dS)zq :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded N)r)rBrrrrr@szHashMissing.__init__rDcCsHddlm}d}|jr4|jjr&|jjn t|jdd}d|p>d||jS)Nr) FAVORITE_HASHrz {} --hash={}:{}r)pip._internal.utils.hashesrr is_direct original_linkgetattrformatr)rBrrUrrrrs   zHashMissing.body) r.r/r0r1rrrOr@rrrrrr s  rc@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:Nrrrrrr3src@sZeZdZdZdZdZeeeefeedfddddZ ed d d Z ed d d Z 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.rN)allowedgotsrcCs||_||_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)rr)rBrrrrrr@PszHashMismatch.__init__rDcCsd|d|S)Nr: )r_hash_comparisonrErrrrZszHashMismatch.bodycsntdddd}g}|jD]D\}}|||fdd|D|d|j|dqd|S) aE Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef z chain[str]) hash_namercSst|gtdS)Nz or)rr)rrrr hash_then_orisz3HashMismatch._hash_comparison..hash_then_orc3s"|]}dtd|VqdS)z Expected  N)nextrr rrrhqsz0HashMismatch._hash_comparison..z Got r$)rOritemsrrr hexdigestr()rBrrr expectedsrrrr]s zHashMismatch._hash_comparison) r.r/r0r1rrrrOrr@rrrrrrr>s & rc@seZdZdZdS)UnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.Nr-rrrrrxsrcsFeZdZdZd eeeeejddfdd Zeddd Z Z S) !ConfigurationFileCouldNotBeLoadedz8When there are errors while loading a configuration filecould not be loadedN)r]fnamer4rcs"t|||_||_||_dSre)r?r@r]rr4)rBr]rr4rCrrr@s z*ConfigurationFileCouldNotBeLoaded.__init__rDcCsF|jdk rd|jd}n|jdk s(td|jd}d|j|S)Nz in .z. r$zConfiguration file )rr4r>r])rB message_partrrrras  z)ConfigurationFileCouldNotBeLoaded.__str__)rNN) r.r/r0r1rOr configparserErrorr@rarQrrrCrr}s rzThe Python environment under z is managed externally, and may not be manipulated by the user. Please use specific tooling from the distributor of the Python installation to interact with this environment instead. csdeZdZdZdZeeddfdd Zee eddd Z e e e jefdd d d ZZS) ExternallyManagedEnvironmentaPThe current environment is externally managed. This is raised when the current environment is externally managed, as defined by `PEP 668`_. The ``EXTERNALLY-MANAGED`` configuration is checked and displayed when the error is bubbled up to the user. :param error: The error message read from ``EXTERNALLY-MANAGED``. zexternally-managed-environmentNrcs6|dkrtt}nt|}tjd|dtdddS)Nz&This environment is externally managedzIf you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.z+See PEP 668 for the detailed specification.rY)r!_DEFAULT_EXTERNALLY_MANAGED_ERRORr?r@)rBr4r9rCrrr@s z%ExternallyManagedEnvironment.__init__rDccs|z tj}Wntk r"d}YnXt|\}}|dk rrd|VdD]&}||\}}}|sdqJd|VqJdVdS)NzError-)-_r)locale LC_MESSAGESAttributeError getlocale partition)categorylangrseprkfoundrrr#_iter_externally_managed_error_keyss   z@ExternallyManagedEnvironment._iter_externally_managed_error_keys)configrc Cstjdd}zX|j|dd|d}|D]4}tt |||W5QRWSQRXq,WnTtk rxYnBtttj fk rddl m }t |}t jd||dYnX|dS) N) interpolationzutf-8)encodingzexternally-managedr)VERBOSEzFailed to read %s)exc_info)r ConfigParserreadr contextlibsuppressKeyErrorOSErrorUnicodeDecodeError ParsingErrorpip._internal.utils._logrlogger isEnabledForwarning)rrparsersectionrrrrrr from_configs   *  z(ExternallyManagedEnvironment.from_config)r.r/r0r1r3r rOr@ staticmethodrr classmethodr pathlibPathrrQrrrCrrs  rcs(eZdZdZdddfdd ZZS)UninstallMissingRecordzuninstall-no-record-filerN distributionrcsv|j}|r|dkr<|jd|j}tdd|df}ntd|d}tjtd|d |jd |d dS) Npipz==z,You might be able to recover from this via: z(pip install --force-reinstall --no-deps greenzThe package was installed by z3. You should check if it can uninstall the package.Cannot uninstall zAThe package's contents are unknown: no RECORD file was found for rr8r9r:) installerraw_nameversionrassembler?r@)rBrrdephintrCrrr@s     zUninstallMissingRecord.__init__r.r/r0r3r@rQrrrCrrsrcs(eZdZdZdddfdd ZZS)LegacyDistutilsInstallz%uninstall-distutils-installed-packagerNrcs tjtd|ddddS)NrzIt is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.r)r?r@r)rBrrCrrr@s  zLegacyDistutilsInstall.__init__rrrrCrrsrcs2eZdZdZdeeefddfdd ZZS)InvalidInstalledPackagezinvalid-installed-packagerN)r_ invalid_excrcsn|j}t|trd}nd}tjtd|d|rs$          v  ).  * :I