o gl@s~ddlZddlZddlZddlZddlZddlmZmZddlm Z m Z m Z ddl m Z ddlmZddlmZddlmZddlmZmZmZdd lmZmZdd lmZmZdd lmZdd l m!Z!dd l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;ddlZ>ddl?m@Z@mAZAmBZBe4eCZDde#de@fddZEGdddeZF   d:d!eGd"e eHd#e eHd$eGd%e eHde eHf d&d'ZId#e eHd$eGdeGfd(d)ZJ    d;d*e eGd+e eHd,e eHd-e eHd.eGdeGf d/d0ZKd1e e*d2e e eHddfd3d4ZLd5eMd6eGd7eGdeHfd8d9ZNdS)<N) SUPPRESS_HELPValues)IterableListOptional)canonicalize_name) WheelCache) cmdoptions)make_target_python)RequirementCommandwarn_if_run_as_root with_cleanup)ERRORSUCCESS) CommandErrorInstallationError) get_scheme)get_environment) FormatControl)ConflictDetailscheck_install_conflicts)install_given_reqs)InstallRequirement)get_requirement_tracker)WINDOWS)parse_distutils_argstest_writable_dir) getLogger) ensure_dirget_pip_version(protect_pip_from_modification_on_windows write_output) TempDirectory)running_under_virtualenvvirtualenv_no_global)BinaryAllowedPredicatebuild should_build_for_install_commandformat_controlreturncsdtdtffdd }|S)Nreqr*cs t|jpd}|}d|vS)Nbinary)rnameget_allowed_formats)r+canonical_nameallowed_formatsr)@/usr/lib/python3/dist-packages/pip/_internal/commands/install.pycheck_binary_allowed5s z6get_check_binary_allowed..check_binary_allowed)rbool)r)r5r3r2r4get_check_binary_allowed4sr7c@seZdZdZdZdddZededee de fd d Z d e d e d e ddfddZdeedeefddZdede ddfddZdS)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] ...r*NcCsj|jt|jt|jt|jt|jt|jjdddddddt|j|jjddd d d |jjd dd t d |jjdddddd|jjdddddd|jt |jjdddd dd |jjdddddgdd|jjddd d d |jjd!d"d#d d$d |jt |jt |jt |jt|jt|jt|jjd%d d&d'd(d)|jjd*d d&d+d,|jjd-d d.d'd/d)|jjd0d d1d'd2d)|jt|jt|jt|jt|jtttj|j}|jd3||jd3|jdS)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.)destmetavardefaulthelpz--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-user 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-neededeageraGDetermines 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)cmd_opts add_optionr requirements constraintsno_depspreeditableadd_target_python_optionsrsrcignore_requires_pythonno_build_isolation use_pep517 no_use_pep517install_optionsglobal_options no_binary only_binary prefer_binaryrequire_hashes progress_barmake_option_group index_groupparserinsert_option_group)self index_optsr3r3r4 add_optionsQs     zInstallCommand.add_optionsoptionsargsc) s.|jr |jdur tdt|d}|jr|j}tj|dd|jp$g}t dt t |j|j |j|j|jd|_d}d}|jrld|_tj|j|_tj|jr_tj|js_tdtdd }|j}|||jppg}||}t|} |j||| |jd } t|j|j} |t } t|j! d dd } z<|"||| |}|D]}d|_#qt$||j|j%| || || |j|j&d }|j'|| || |j|j|j|j(||j)d }|*| |j+||j d}z|,d}Wn t-yd}Ynw|j.du}t/|dt0| jfdd|j12D}t3|| dggd\}}dd|D}|r/t4d5d6||D] }|j)s:d|_7q1|8|}d}|j9 oJ|j:}|rS|;|}|j<}|js^|j r`d}t=||||j||j ||j|j>d }t?|j||j|j |jd}t@|} |jAtBCddg}!|D]*}"|"jD}#z| E|#}$|$dur|#d|$jF}#Wn tGyYnw|!H|#q|dur|jI||J|dd 6|!}%|%rtKd!|%Wn(tLy}&z|j&d"k}'tM|&|'|j}(t jN|(|'d#tOWYd}&~&Sd}&~&ww|jr|s J|P|j||jtQtRS)$Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT) check_targetzUsing %s)rDr9rC isolated_modez=Target path exists but is not a directory, will not continue.target)kind)risession target_pythonrWinstall)deleternglobally_managed)temp_build_dirri req_trackerrofinderr? verbosity) preparerrvri wheel_cacher?rJrWrIrFrY)check_supported_wheelspipF) modifying_pipcsg|] }t|r|qSr3)r(.0rr5r3r4 cs z&InstallCommand.run..)ryverify build_optionsr\cSsg|]}|jr|jqSr3)rYr.r}r3r3r4rss zYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, i )roothomeprefixrLr? pycompile)userrrrisolatedr.)key-)resolver_variant zSuccessfully installed %s)exc_info)Sr?r9rr check_install_build_globalrErFcheck_dist_restrictionr[loggerverboser decide_user_installrDrCrlrJospathabspathexistsisdirr# enter_contextr\get_default_sessionr _build_package_finderrWr cache_dirr)rno_cleanget_requirementspermit_editable_wheels'reject_location_related_install_optionsmake_requirement_preparerrw make_resolverrIrYtrace_basic_inforesolveget_requirementKeyError satisfied_byr!r7rPvaluesr'rformatjoinlegacy_install_reasonget_installation_orderignore_dependenciesrM_determine_conflictsrLrrKget_lib_location_guessesrsortoperator attrgetterr.get_distributionversion Exceptionappend_warn_about_conflictsdetermine_resolver_variantr"OSErrorcreate_os_error_messageerrorr_handle_target_dirr r))rfrirjrFr[target_temp_dirtarget_temp_dir_pathr\rorprvryru directoryreqsr+rxresolverrequirement_setpip_reqr| reqs_to_build_build_failurespep517_build_failure_namesr to_install conflictsshould_warn_about_conflictsrL installed lib_locationsenvitemsresultiteminstalled_distinstalled_descrshow_tracebackmessager3rr4runsh                              zInstallCommand.runr9rrEc sHt|g}td|jd}|j}|j}|j}tj|r!||tj|r0||kr0||tj|r;|||D]d} t | D]\} | |kratj || t fdd|ddDraqDtj || } tj| r|swt d| qDtj| rt d| qDtj| rt| nt| ttj | | | qDq=dS)Nr,)rc3s|]}|VqdSN) startswith)r~sddirr3r4 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.)rrrpurelibplatlibdatarrrlistdirranyrwarningislinkrshutilrmtreeremovemove) rfr9rrE lib_dir_listscheme purelib_dir platlib_dirdata_dirlib_dirrtarget_item_dirr3rr4rsL          z!InstallCommand._handle_target_dirrcCs*zt|WStytdYdSw)NzwError while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new)rrr exception)rfrr3r3r4r s  z#InstallCommand._determine_conflictsconflict_detailsrc Cs|\}\}}|s |s dSg}|dkr|dn |dksJ|d|D]}||d}||D]} dj||| dd} || q1q%|D](}||d}||D]\} } } d j||| | | |dkrdd nd d } || qRqFtd |dS)Nlegacyzpip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.z 2020-resolverzpip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.rz@{name} {version} requires {requirement}, which is not installed.r)r.r requirementzg{name} {version} requires {requirement}, but {you} have {dep_name} {dep_version} which is incompatible.youzyou'll)r.rrdep_name dep_versionr )rrrcriticalr)rfrr package_setmissing conflictingparts project_namer dependencyrrrr+r3r3r4rsL       z$InstallCommand._warn_about_conflicts)r*N)__name__ __module__ __qualname____doc__usagerhr rrstrintrr#r6rrrrrrr3r3r3r4r8=s:  g 6  r8FrrrrrcCs td|||||d}|j|jgS)Nr,)rrrrr)rrr)rrrrrrr3r3r4rPs rcCstddtt||dDS)Ncss|]}t|VqdSrr)r~dr3r3r4rcs  z)site_packages_writable..rr)allsetrrr3r3r4site_packages_writablebsr r?rDr9rCrlcCs|dur |s tddS|r#|rtdtrtdtddS|dus)J|s-|r4tddStjs>td dSt||d rKtd dStd dS) aZDetermine whether to do a user install based on the input options. If use_user_site is False, no additional checks are done. If use_user_site is True, it is checked for compatibility with other options. If use_user_site is None, the default behaviour depends on the environment, which is provided by the other arguments. Nz$Non-user install by explicit requestFzVCan 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.z User install by explicit requestTz3Non-user install due to --prefix or --target optionz4Non-user install because user site-packages disabledrz0Non-user install because site-packages writeablezMDefaulting to user installation because normal site-packages is not writeable) rdebugrr%rsiteENABLE_USER_SITEr info)r?rDr9rCrlr3r3r4ris8        rrPricCsdttdttfdd}g}|D]}|j}t|}|r)|d|||q|r>t|}|r>|d|||sBdStdd |) zIf any location-changing --install-option arguments were passed for requirements or on the command-line, then show a deprecation warning. option_namesr*cSsdd|DS)NcSsg|] }d|ddqS)z--{}rr)rreplace)r~r.r3r3r4rszSreject_location_related_install_options..format_options..r3)rr3r3r4format_optionssz?reject_location_related_install_options..format_optionsz {!r} from {}z{!r} from command lineNzLocation-changing options found in --install-option: {}. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.z; ) rrrr[rrrkeysrr)rPrir offendersrr[location_optionsr3r3r4rs0  rrrusing_user_sitecCsg}|d|s|d|t|n|d|dd7<|jtjkrGd}d}ts=|s=||d|gn|||d tr^|jtjkr^|j r^t |j d kr^|d d | dS) zrFormat an error message for an OSError It may occur anytime during the execution of the install command. z,Could not install packages due to an OSErrorz: .rrz"Consider using the `--user` optionzCheck the permissionsz or z. izHINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths r,) rrerrnoEACCESr$extendlowerrENOENTfilenamelenrstrip)rrrruser_option_partpermissions_partr3r3r4rs:        r)FNNFN)NNNF)Orrrrr optparserrtypingrrrpip._vendor.packaging.utilsrpip._internal.cacherpip._internal.clir pip._internal.cli.cmdoptionsr pip._internal.cli.req_commandr r r pip._internal.cli.status_codesrrpip._internal.exceptionsrrpip._internal.locationsrpip._internal.metadatar#pip._internal.models.format_controlrpip._internal.operations.checkrrpip._internal.reqrpip._internal.req.req_installrpip._internal.req.req_trackerrpip._internal.utils.compatr"pip._internal.utils.distutils_argsrpip._internal.utils.filesystemrpip._internal.utils.loggingrpip._internal.utils.miscrr r!r"pip._internal.utils.temp_dirr#pip._internal.utils.virtualenvr$r%pip._internal.wheel_builderr&r'r(rrr7r8r6rrr rrrrr3r3r3r4s                   =  '