3 igl@sHddlZddlZddlZddlZddlZddlmZmZddlm 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@mAZAmBZBe4eCZDe#e@dddZEGdddeZFd/eGe eHe eHeGe eHe eHd d!d"ZIe eHeGeGd#d$d%ZJd0e eGe eHe eHe eHeGeGd&d'd(ZKe e*e e eHdd)d*d+ZLeMeGeGeHd,d-d.ZNdS)1N) 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_args)test_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_command)format_controlreturncsttdfdd }|S)N)reqr)cs t|jp d}j|}d|kS)Nbinary)rnameZget_allowed_formats)r*canonical_nameZallowed_formats)r(=/tmp/pip-build-88gy_88q/pip/pip/_internal/commands/install.pycheck_binary_allowed5s z6get_check_binary_allowed..check_binary_allowed)rbool)r(r1r/)r(r0get_check_binary_allowed4sr3c@szeZdZdZdZddddZeeee e ddd Z e e e dd d d Zeeeed ddZee ddddZdS)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] ...N)r)cCsj|jjtj|jjtj|jjtj|jjtj|jjtj|jjdddddddtj|j|jjddd d d |jjd dd t d |jjdddddd|jjdddddd|jjtj |jjdddd dd |jjdddddgdd|jjddd d d |jjd!d"d#d d$d |jjtj |jjtj |jjtj |jjtj|jjtj|jjtj|jjd%d d&d'd(d)|jjd*d d&d+d,|jjd-d d.d'd/d)|jjd0d d1d'd2d)|jjtj|jjtj|jjtj|jjtj|jjtjtjtj|j}|jjd3||jjd3|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.))r7actionr: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).)r7r9choicesr: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)r=r7r9r:z --no-compilez.Do not compile Python source files to bytecode)r=r7r: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_depspreeditableZadd_target_python_optionsrsrcignore_requires_pythonZno_build_isolation use_pep517Z no_use_pep517install_optionsglobal_options no_binary only_binaryZ prefer_binaryrequire_hashesZ progress_barmake_option_group index_groupparserinsert_option_group)self index_optsr/r/r0 add_optionsQs  zInstallCommand.add_options)optionsargsr)c)s8|jr|jdk rtdtj|d}|jr2|j}tj|dd|jpHg}t j dt t |j|j |j|j|jd|_d}d}|jrd|_tjj|j|_tjj|jrtjj|j rtdtdd }|j}|j||jpg}|j|}t|} |j||| |jd } t|j|j} |jt } t|j! d dd } y|j"||| |}x|D] }d|_#qPWt$||j|j%| || || |jd }|j&|| || |j|j|j|j'||j(d }|j)| |j*||j d}y|j+d}Wnt,k rd}Yn X|j-dk}t.|dt/| jfdd|j0j1D}t2|| dggd\}}dd|D}|rft3dj4dj5|x|D]}|j(sld|_6qlW|j7|}d}|j8 o|j9}|r|j:|}|j;}|js|j rd}t<||||j||j ||j|j=d }t>|j||j|j |jd}t?|} |j@tAjBddg}!x^|D]V}"|"jC}#y(| jD|#}$|$dk r\|#d|$jE}#WntFk rtYnX|!jG|#q,W|dk r|jH||jI|dd j5|!}%|%rtJd!|%WnHtKk r}&z*|jLd"k}'tM|&|'|j}(t jN|(|'d#tOSd}&~&XnX|jr.|stP|jQ|j||jtRtSS)$Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)Z check_targetzUsing %s)r@r5r? isolated_modez=Target path exists but is not a directory, will not continue.target)kind)r`session target_pythonrRinstall)deleterdZglobally_managed)Ztemp_build_dirr` req_trackerrefinderr;) preparerrjr` wheel_cacher;rFrRrErBrS)Zcheck_supported_wheelspipF) modifying_pipcsg|]}t|r|qSr/)r').0r)r1r/r0 csz&InstallCommand.run..)rlverify build_optionsrUcSsg|]}|jr|jqSr/)rSr-)rorpr/r/r0rqsszYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, i )roothomeprefixrHr; pycompile)userrurtrvisolatedr-)key-)resolver_variant zSuccessfully installed %s)exc_info)Tr;r5rr check_install_build_globalrArBZcheck_dist_restrictionrTloggerverboserdecide_user_installr@r?rbrFospathabspathexistsisdirr" enter_contextrUZget_default_sessionr _build_package_finderrRr cache_dirr(rno_cleanZget_requirementsZpermit_editable_wheels'reject_location_related_install_optionsZmake_requirement_preparerZ make_resolverrErSZtrace_basic_inforesolveget_requirementKeyError satisfied_byr r3rLvaluesr&rformatjoinZlegacy_install_reasonZget_installation_orderignore_dependenciesrI_determine_conflictsrHrrGget_lib_location_guessesrsortoperator attrgetterr-get_distributionversion Exceptionappend_warn_about_conflictsZdetermine_resolver_variantr!OSError verbositycreate_os_error_messageerrorrAssertionError_handle_target_dirr r))r]r`rarBrTtarget_temp_dirZtarget_temp_dir_pathrUrerfrjrlri directoryreqsr*rkresolverrequirement_setZpip_reqrnZ reqs_to_build_Zbuild_failuresZpep517_build_failure_namesrp to_installZ conflictsZshould_warn_about_conflictsrH installedZ lib_locationsenvitemsresultiteminstalled_distZinstalled_descrshow_tracebackmessager/)r1r0runs*                                   zInstallCommand.run)r5rrAr)c sVt|g}td|jd}|j}|j}|j}tjj|rB|j|tjj|r`||kr`|j|tjj|rv|j|x|D]} xtj | D]} | |krtjj || t fdd|ddDrqtjj || } tjj| r4|st j d| qtjj| rt j d| qtjj| r*tj| n tj| tjtjj | | | qWq|WdS) Nr+)ruc3s|]}|jVqdS)N) startswith)ros)ddirr/r0 sz4InstallCommand._handle_target_dir..r~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) r]r5rrA lib_dir_listscheme purelib_dir platlib_dirZdata_dirlib_dirrtarget_item_dirr/)rr0rsD        z!InstallCommand._handle_target_dir)rr)c Cs,yt|Stk r&tjddSXdS)NzwError while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new)rrr exception)r]rr/r/r0r s z#InstallCommand._determine_conflicts)conflict_detailsr|r)c Cs|\}\}}| r| rdSg}|dkr4|jdn|dks@t|jdxH|D]@}||d}x.||D]"} dj||| dd} |j| qjWqPWx\|D]T}||d}xB||D]6\} } } d j||| | | |dkrd nd d } |j| qWqWtjd j|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 )rrrrcriticalr)r]rr|Z package_setmissingZ conflictingparts project_namer dependencyrrrr*r/r/r0rs<        z$InstallCommand._warn_about_conflicts)__name__ __module__ __qualname____doc__usager_r rrstrintrr"r2rrrrrrr/r/r/r0r4=s  g5 r4F)rxrurtryrvr)cCs td|||||d}|j|jgS)Nr+)rxrurtryrv)rrr)rxrurtryrvrr/r/r0rOsr)rtryr)cCstddtt||dDS)Ncss|]}t|VqdS)N)r)rodr/r/r0rcsz)site_packages_writable..)rtry)allsetr)rtryr/r/r0site_packages_writableasr)r;r@r5r?rbr)cCs|dk r| rtjddS|rH|r,tdtr:tdtjddS|dksTt|s\|rjtjddStjs~tjd dSt||d rtjd dStj d 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 disabled)rtryz0Non-user install because site-packages writeablezMDefaulting to user installation because normal site-packages is not writeable) rdebugrr$rrsiteENABLE_USER_SITErinfo)r;r@r5r?rbr/r/r0rhs2       r)rLr`r)cCsttttddd}g}x8|D]0}|j}t|}|r"|jdj||j|q"W|r~t|}|r~|jdj||j|sdStdjdj |dS) 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|]}dj|jddqS)z--{}rr{)rreplace)ror-r/r/r0rqszSreject_location_related_install_options..format_options..r/)rr/r/r0format_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; ) rrrrTrrrkeysrr)rLr`rZ offendersrrTZlocation_optionsr/r/r0rs& r)rrusing_user_siter)cCsg}|jd|s,|jd|jt|n |jd|d d7<|jtjkrd}d}t r~| r~|j|d|jgn |j||jd tr|jtjkr|j rt |j d kr|jd d j |j 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: .r~rz"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+r) rrerrnoZEACCESr#extendlowerrENOENTfilenamelenrstrip)rrrrZuser_option_partZpermissions_partr/r/r0rs0       r)FNNFN)NNNF)OrrrrroptparserrZtypingrrrpip._vendor.packaging.utilsrZpip._internal.cacherZpip._internal.clir Zpip._internal.cli.cmdoptionsr Zpip._internal.cli.req_commandr r r Zpip._internal.cli.status_codesrrZpip._internal.exceptionsrrZpip._internal.locationsrZpip._internal.metadatarZ#pip._internal.models.format_controlrZpip._internal.operations.checkrrZpip._internal.reqrZpip._internal.req.req_installrZpip._internal.req.req_trackerrZpip._internal.utils.compatrZ"pip._internal.utils.distutils_argsrZpip._internal.utils.filesystemrZpip._internal.utils.loggingrZpip._internal.utils.miscrrr r!Zpip._internal.utils.temp_dirr"Zpip._internal.utils.virtualenvr#r$Zpip._internal.wheel_builderr%r&r'rrr3r4r2rrrrrrrr/r/r/r0sf                  8&