U .e_@sddlmZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZmZdd lmZddl m!Z!ddl"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5e1rddl m6Z6ddl7m8Z8m9Z9m:Z:ddl;mZ>ddl4m?Z?e@eAZBddZCddZDd d!ZEGd"d#d#eZFd$d%ZGd&d'ZHdS)()absolute_importN)path) SUPPRESS_HELP) pkg_resources)canonicalize_name) WheelCache) cmdoptions)make_target_python)RequirementCommand)ERRORSUCCESS) CommandErrorInstallationErrorPreviousBuildDirErrordistutils_scheme)check_install_conflicts)RequirementSetinstall_given_reqs)RequirementTracker)check_path_owner) ensure_dirget_installed_version(protect_pip_from_modification_on_windows write_output) TempDirectory)MYPY_CHECK_RUNNING)virtualenv_no_global) WheelBuilder)Values)AnyListOptional) FormatControl)InstallRequirement)BinaryAllowedPredicatecCs(z ddl}Wntk r"YdSXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)r&r(B/usr/lib/python3.8/site-packages/pip/_internal/commands/install.pyis_wheel_installed<s  r*cCs*t}|j|dd}|r&|j|dd|S)zQ Build wheels for requirements, depending on whether wheel is installed. T)Z should_unpack)r*Zbuild)builderpep517_requirementslegacy_requirementsZshould_build_legacybuild_failuresr(r(r) build_wheelsHs r/csfdd}|S)Ncs&|jr dSt|j}|}d|kS)NTZbinary) use_pep517rnameZget_allowed_formats)reqZcanonical_nameZallowed_formatsformat_controlr(r)check_binary_allowedhs   z6get_check_binary_allowed..check_binary_allowedr()r4r5r(r3r)get_check_binary_allowedfs r6cs<eZdZdZdZfddZddZddZd d ZZ S) InstallCommandaI Install packages from: - PyPI (and other indexes) using requirement specifiers. - VCS project urls. - Local project directories. - Local or remote source archives. pip also supports installing from "requirements files", which provide an easy way to specify a whole environment to be installed. a% %prog [options] [package-index-options] ... %prog [options] -r [package-index-options] ... %prog [options] [-e] ... %prog [options] [-e] ... %prog [options] ...cs^tt|j|||j}|t|t|t|t |t |jdddddddt ||jddd d d |jd dd t d |jdddddd|jdddddd|t |t|jdddd dd |jdddddgdd|jddd d d |jd!d"d#d d$d |t|t|t|t|t|t|jd%d d&d'd(d)|jd*d d&d+d,|jd-d d.d'd/d)|jd0d d1d'd2d)|t|t|t|t|t|tttj|j}|jd3||jd3|dS)4Nz-tz--target target_dirdirzInstall packages into . By default this will not replace existing files/folders in . Use --upgrade to replace existing packages in with new versions.)destmetavardefaulthelp--user use_user_site store_truezInstall to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.))r:actionr=z --no-userZ store_falsez--root root_pathz=Install everything relative to this alternate root directory.z--prefix prefix_pathzIInstallation prefix where lib, bin and other top-level folders are placedz-Uz --upgradeupgradezUpgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.z--upgrade-strategyupgrade_strategyzonly-if-neededZeageraGDetermines how dependency upgrading should be handled [default: %default]. "eager" - dependencies are upgraded regardless of whether the currently installed version satisfies the requirements of the upgraded package(s). "only-if-needed" - are upgraded only when they do not satisfy the requirements of the upgraded package(s).)r:r<choicesr=z--force-reinstallforce_reinstallz;Reinstall all packages even if they are already up-to-date.z-Iz--ignore-installedignore_installedzIgnore the installed packages, overwriting them. This can break your system if the existing package is of a different version or was installed with a different package manager!z --compilecompileTz'Compile Python source files to bytecode)rAr:r<r=z --no-compilez.Do not compile Python source files to bytecode)rAr:r=z--no-warn-script-locationwarn_script_locationz0Do not warn when installing scripts outside PATHz--no-warn-conflictswarn_about_conflictsz%Do not warn about broken dependenciesr)superr7__init__cmd_optsZ add_optionr requirementsZ constraintsZno_depsZpreZeditableZadd_target_python_optionsr build_dirsrcignore_requires_pythonZno_build_isolationr0Z no_use_pep517install_optionsglobal_optionsZ no_binaryZ only_binaryZ prefer_binaryno_cleanrequire_hashesZ progress_barZmake_option_groupZ index_groupparserZinsert_option_group)selfargskwrNZ index_opts __class__r(r)rMs   zInstallCommand.__init__c*Cst|dd}tdkrZ|sZttjd}|dkrLttjd}t d|d}|j rj|j }|j rtj|j |_ tj|dd tj|j|_|jpg}|jr|jrtd trtd |d |d d}d}|jrJd|_tj|j|_tj|jr,tj|js,tdtdd}|j}|d||jpTg} ||} t|} |j || | |j!d} |j"p|j } t#|j$|j%}|j$rt&|j$st d|j$d|_$t'}t|j | dd}t(|j)|j d}zz*|,|||| | ||j-|||d}|j.|| | |||j|j|j!|j/||j0d }|1|z|2d}Wnt3k rzd}Yn X|j4dk}t5|dt6| j%}g}g}|j78D]$}|j0r||n ||qt9||gg|d}t:|||d}|rtd;d o.|j?}|r@|@||jA}|jrRd!}tB||| |jC||j|jD||jd" }tE|j||jC|j|jFd#} tGH| }!tI|tJKd$d%}"g}#|"D]R}|jL}$z$tM|jL|!d&}%|%r|$d'|%7}$WntNk rYnX|#|$qd(<|#}&|&r tOd)|&WntPk r}'zN|jQd*k}(tR|'|(|j})t jS|)|(d+tTWYWHW5QRW5QRSd}'~'XYntUk rd|_"YnXW5|j"s|*|+XW5QRXW5QRX|jr|V|j||j tWS),NcSs ttdpttdotjtjkS)NZ real_prefix base_prefix)hasattrsysr]prefixr(r(r(r)is_venvs   z#InstallCommand.run..is_venvrz __main__.pyz -m pipzgRunning pip install with root privileges is generally not a good idea. Try `%s install --user` instead.zto-satisfy-onlyT)Z check_targetzVCan not combine '--user' and '--prefix' as they imply different installation locationszZCan not perform a '--user' install. User site-packages are not visible in this virtualenv.r>z --prefix=z=Target path exists but is not a directory, will not continue.target)kindz--home=)optionssession target_pythonrRzThe directory '%s' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Zinstall)deleterc)rVZcheck_supported_wheels)Ztemp_build_dirrd req_tracker) preparerfinderrerd wheel_cacher?rHrRrGrEr0Zpip) modifying_pip)Z build_optionsrTr5)r+r,r-zPCould not build wheels for {} which use PEP 517 and cannot be installed directlyz, css|] }|jVqdSN)r1).0rr(r(r) sz%InstallCommand.run..F)roothomer`Z pycompilerJr?)userrrrqr`isolatedr1)key) working_set- zSuccessfully installed %sexc_info)XrZcheck_install_build_globalosgetuidrbasenamer_argv executableloggerwarningrDrErPabspathZcheck_dist_restrictionZsrc_dirrSr?rCr rrappendr8rHexistsisdirrrTZget_default_sessionr Z_build_package_finderrRrUr cache_dirr4rrrrVZ cleanup_filesZcleanupZpopulate_requirement_setZmake_requirement_preparerZ make_resolverrGr0ZresolveZget_requirementKeyErrorZ satisfied_byrr6rOvaluesrr/formatjoinZget_installation_orderZignore_dependenciesrK_warn_about_conflictsrJrrBrIget_lib_location_guessesZ isolated_moderZ WorkingSetsortedoperator attrgetterr1r ExceptionrEnvironmentError verbositycreate_env_error_messageerrorr r_handle_target_dirr )*rXrdrYraZcommandrErStarget_temp_dirZtarget_temp_dir_pathrTrerfrjZ build_deleterkrhZ directoryZrequirement_setriZresolverZpip_reqrlr5r-r,r2Z wheel_builderr. to_installZshould_warn_about_conflictsrJZ installedZ lib_locationsrvZreqsitemsitemZinstalled_versionZinstalled_descrshow_tracebackmessager(r(r)runs                   4 zInstallCommand.runc sft|g}|Jtd|jd}|d}|d}|d}tj|rP||tj|rn||krn||tj|r|||D]} t| D]} | |krtj|| tfdd|ddDrqtj|| } tj| r>|st d | qtj | rt d | qtj | r4t | n t| t tj| | | qqW5QRXdS) N)rrpurelibplatlibdatac3s|]}|VqdSrm) startswith)rnsddirr(r)rp+sz4InstallCommand._handle_target_dir..zKTarget directory %s already exists. Specify --upgrade to force replacement.zTarget directory %s already exists and is a link. Pip will not automatically replace links, please remove if replacement is desired.)rrrr|rrlistdirranyrrislinkrshutilZrmtreeremoveZmove) rXr8rrDZ lib_dir_listschemeZ purelib_dirZ platlib_dirZdata_dirZlib_dirrZtarget_item_dirr(rr)rsP        z!InstallCommand._handle_target_dirc Cszt|\}}Wn$tk r4tjdddYdSX|\}}|D]2}||d}||D]}td|||dqZqB|D]8}||d}||D]\} } } td||| | | qqzdS)NzError checking for conflicts.Trzrz*%s %s requires %s, which is not installed.ryzF%s %s has requirement %s, but you'll have %s %s which is incompatible.)rrrrZcritical) rXrZ package_setZ _dep_infoZmissingZ conflictingZ project_nameversionZ dependencyZdep_nameZ dep_versionr2r(r(r)rIs4   z$InstallCommand._warn_about_conflicts) __name__ __module__ __qualname____doc__ZusagerMrrr __classcell__r(r(r[r)r7ss  w8r7cOstd||}|d|dgS)Nrrr)rr)rYkwargsrr(r(r)rdsrcCsg}|d|s,|d|t|n |d|dd7<|jtjkrd}d}|st||d|gn |||d d |dS) z{Format an error message for an EnvironmentError It may occur anytime during the execution of the install command. z5Could not install packages due to an EnvironmentErrorz: .r z"Consider using the `--user` optionzCheck the permissionsz or z. r)rstrerrnoZEACCESextendlowerrstrip)rrZusing_user_sitepartsZuser_option_partZpermissions_partr(r(r)ris&      r)IZ __future__rrZloggingrr|rr_rZoptparserZ pip._vendorrZpip._vendor.packaging.utilsrZpip._internal.cacherZpip._internal.clirZpip._internal.cli.cmdoptionsr Zpip._internal.cli.req_commandr Zpip._internal.cli.status_codesr r Zpip._internal.exceptionsr rrZpip._internal.locationsrZpip._internal.operations.checkrZpip._internal.reqrrZpip._internal.req.req_trackerrZpip._internal.utils.filesystemrZpip._internal.utils.miscrrrrZpip._internal.utils.temp_dirrZpip._internal.utils.typingrZpip._internal.utils.virtualenvrZpip._internal.wheelrrtypingr r!r"Z#pip._internal.models.format_controlr#Zpip._internal.req.req_installr$r%Z getLoggerrrr*r/r6r7rrr(r(r(r)sT                        t