3 (\9Y@sVddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZmZmZdd lmZmZdd lmZdd lmZdd lmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ej/e0Z1ddZ2ddZ3GdddeZ4ddZ5ddZ6dS))absolute_importN) SUPPRESS_HELP) pkg_resources) WheelCache) cmdoptions)RequirementCommand)ERROR) CommandErrorInstallationErrorPreviousBuildDirError)distutils_schemevirtualenv_no_global)check_install_conflicts)RequirementPreparer)RequirementSetinstall_given_reqs)RequirementTracker)Resolver)check_path_owner) ensure_dirget_installed_version(protect_pip_from_modification_on_windows) TempDirectory) WheelBuilderc Cs&y ddl}Wntk r dSXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)rrq/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/pip/_internal/commands/install.pyis_wheel_installed$s  rcCs.t}|j||dd}|r*|j||dd|S)zQ Build wheels for requirements, depending on whether wheel is installed. T)session autobuilding)rbuild)builderpep517_requirementslegacy_requirementsrZshould_build_legacybuild_failuresrrr build_wheels0s  r&csDeZdZdZdZdZdZfddZddZd d Z d d Z Z 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. installa% %prog [options] [package-index-options] ... %prog [options] -r [package-index-options] ... %prog [options] [-e] ... %prog [options] [-e] ... %prog [options] ...zInstall packages.cstt|j|||j}|jtj|jtj|jtj|jtj |jtj |jddddddd|jtj |jtj |jtj |jtj|jddd d d |jd dd td |jdddddd|jdddddd|jtj|jtj|jdddd dd |jdddddgdd|jddd d d |jd!d"d#d d$d |jtj|jtj|jtj|jtj|jtj|jtj|jd%d d&d'd(d)|jd*d d&d+d,|jd-d d.d'd/d)|jd0d d1d'd2d)|jtj|jtj|jtj|jtj|jtj|jtjtjtj|j }|j j!d3||j j!d3|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.)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_installedz5Ignore the installed packages (reinstalling instead).z --compilecompileTz'Compile Python source files to bytecode)r1r+r-r.z --no-compilez.Do not compile Python source files to bytecode)r1r+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)"superr'__init__cmd_opts add_optionr requirements constraintsno_depspreeditableplatformpython_versionimplementationabir build_dirsrcignore_requires_pythonZno_build_isolation use_pep517Z no_use_pep517install_optionsglobal_options no_binary only_binaryZ prefer_binaryno_cleanrequire_hashes progress_barmake_option_group index_groupparserinsert_option_group)selfargskwr@ index_opts) __class__rrr?`s zInstallCommand.__init__c#/Cstj|d}|jr|j}|jr0tjj|j|_tj|dd|j rN|j g}nd}tjj|j |_ |j pjg}|j r|j rtdtrtd|jd|jdtdd }|jrd|_tjj|j|_tjj|jrtjj|j rtd |j|jd |j|jpg}|j|P}|j|||j||j|jd } |jpJ|j } t|j |j!} |j rt"|j  rt#j$d |j d|_ t%} t|j| dd} t&|j'|j d}zy|j(|||| ||j)| t*| j|j dd|j+|j,| d}t-|| || |j ||j.|j/|j0|j|j1|j2d }|j3|t4|j5ddg}g}x2|j6j7D]$}|j2rh|j|n |j|qPWt8| || ggd}t9||||d}|rtdj:dj;dd|D|j<|}|j/ o|j=}|r|j>||j?}|jrd}t@||||jA|j|j |jB||j d }tC|j |j|jA|j |j1d}tDjE|}tF|tGjHdd}g}xZ|D]R}|j)}y$tI|j)|d }|r|d!|7}WntJk rYnX|j|q`Wd"j;|}|rt#jKd#|WndtLk r} z*|jMd$k}!tN| |!|j }"t#jO|"|!d%tPSd} ~ XntQk r8d|_YnXWd|jsV|jR| jSXWdQRXWdQRXWdQRX|jr|jT|j||j|S)&Nzto-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.z--userz --prefix=target)kindz=Target path exists but is not a directory, will not continue.z--home=)optionsrrGpython_versionsrJrIzThe 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.r()deleter`)rTZcheck_supported_wheels)rKsrc_dir download_dirwheel_download_dirrUbuild_isolation req_tracker) preparerfinderr wheel_cacher/r6r9ignore_dependenciesrMr:isolatedrNpip)Z modifying_pip) build_optionsrP)r"r#r$rzPCould not build wheels for {} which use PEP 517 and cannot be installed directlyz, css|] }|jVqdS)N)name).0rrrr sz%InstallCommand.run..F)roothomeprefix pycompiler<r/)userrurtrvrmrp)key) working_set- zSuccessfully installed %s)exc_info)Urcheck_install_build_globalr5r6rKospathabspathZcheck_dist_restrictionrHrdrOr/r4r r r appendrr)r:existsisdircreaterP_build_session_build_package_finderrGrJrIrSr cache_dirformat_controlrloggerwarningrrrTpopulate_requirement_setrprrUrgrr9rlrM isolated_moderNresolverhas_requirementrBvaluesrr&formatjoinZget_installation_orderr=_warn_about_conflictsr<rr3r;get_lib_location_guessesr WorkingSetsortedoperator attrgetterr ExceptioninfoEnvironmentError verbositycreate_env_error_messageerrorrr cleanup_filescleanup_handle_target_dir)#rZrar[r6rbrOtarget_temp_dirrPrrj build_deleterkrh directoryrequirement_setriresolverr$r#reqZ wheel_builderr% to_installZshould_warn_about_conflictsr< installedZ lib_locationsrzreqsitemsiteminstalled_versionrshow_tracebackmessagerrrruns8                           (zInstallCommand.runc spt|g}|Ttd|jd}|d}|d}|d}tjj|rP|j|tjj|rn||krn|j|tjj|r|j|x|D]} xtj| D]} | |krtjj|| tfdd|dd Drqtjj|| } tjj| rD|st j d | qtjj | r t j d | qtjj | r:t j| n tj| t jtjj| | | qWqWWdQRXdS) N)rupurelibplatlibdatac3s|]}|jVqdS)N) startswith)rqs)ddirrrrssz4InstallCommand._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.)rr rrrrlistdirranyrrislinkrshutilrmtreeremovemove) rZr)rr5 lib_dir_listscheme purelib_dir platlib_dirZdata_dirlib_dirrtarget_item_dirr)rrrsJ         z!InstallCommand._handle_target_dirc Csyt|\}}Wn"tk r2tjddddSX|\}}x>|D]6}||d}x$||D]}tjd|||dq\WqBWxD|D]<}||d}x*||D]\} } } tjd||| | | qWqWdS)NzError checking for conflicts.T)r~rz*%s %s requires %s, which is not installed.r}zF%s %s has requirement %s, but you'll have %s %s which is incompatible.)rrrrcritical) rZrZ package_setZ _dep_infomissingZ conflicting project_nameversion dependencyZdep_nameZ dep_versionrrrrr s$    z$InstallCommand._warn_about_conflicts) __name__ __module__ __qualname____doc__rpusagesummaryr?rrr __classcell__rr)r^rr'Is  `8r'cOstd||}|d|dgS)Nrrr)r)r )r[kwargsrrrrr%srcCsg}|jd|s,|jd|jt|n |jd|d d7<|jtjkrd}d}|st|j|d|jgn |j||jd d j|jdS) 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. rr)rstrerrnoZEACCESextendlowerrstrip)rrZusing_user_sitepartsZuser_option_partZpermissions_partrrrr*s"      r)7 __future__rrloggingrrroptparser pip._vendorrZpip._internal.cacherZpip._internal.clirZpip._internal.cli.base_commandrZpip._internal.cli.status_codesrZpip._internal.exceptionsr r r Zpip._internal.locationsr r Zpip._internal.operations.checkrZ pip._internal.operations.preparerZpip._internal.reqrrZpip._internal.req.req_trackerrZpip._internal.resolverZpip._internal.utils.filesystemrZpip._internal.utils.miscrrrZpip._internal.utils.temp_dirrZpip._internal.wheelr getLoggerrrrr&r'rrrrrrs>                _