3 PfqG @s(ddlmZddlZddlZddlZddlZddlZddlZddlZddlm Z y ddl Z Wne k rtdZ YnXddl m Z ddlmZddlmZmZddlmZmZmZddlmZdd lmZmZdd lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$ej%e&Z'GdddeZ(ddZ)dS))absolute_importN)path)RequirementSet)RequirementCommand)virtualenv_no_globaldistutils_scheme)InstallationError CommandErrorPreviousBuildDirError) cmdoptions) ensure_dirget_installed_version)BuildDirectory)RemovedInPip10Warning)check_path_owner) WheelCache WheelBuildercs4eZdZdZdZdZdZfddZddZZ 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.c s0tt|j|||j}|jtj|jtj|jtj|jtj |jddddddd|jddd d d ddd d|jtj |jd ddddd|jdddddgdd|jddddd|jdddddd|jtj |jtj |jtj |jtj|jd d!dd"d|jd#d$dd%d|jd&d'ddd(d|jd)d*d+dd,d|jd-d.ddd/d|jd0dd1d2d3d4|jd5d6d1d7d8|jtj|jtj|jtj|jtj|jtj|jtj|jtjtjtj|j}|jjd9||jjd9|dS):Nz-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-dz --downloadz--download-dirz--download-directory download_dirz`Download packages into instead of installing them, regardless of what's already installed.z-Uz --upgradeupgrade store_truezUpgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.)ractionrz--upgrade-strategyupgrade_strategyZeagerzonly-if-neededa3Determines how dependency upgrading should be handled. "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).)rrchoicesrz--force-reinstallforce_reinstallzKWhen upgrading, reinstall all packages even if they are already up-to-date.z-Iz--ignore-installedignore_installedz5Ignore the installed packages (reinstalling instead).z--user use_user_sitezInstall 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.)z--eggas_eggzInstall packages as eggs, not 'flat', like pip normally does. This option is not about installing *from* eggs. (WARNING: Because this option overrides pip's normal install logic, requirements files may not behave as expected.)z--root root_pathz=Install everything relative to this alternate root directory.z--strip-file-prefixstrip_file_prefixprefixz5Strip given prefix from script paths in wheel RECORD.z--prefix prefix_pathzIInstallation prefix where lib, bin and other top-level folders are placedz --compilecompileTzCompile py files to pyc)rrrrz --no-compileZ store_falsezDo not compile py files to pyc)rrrr)superr__init__cmd_optsZ add_optionr Z constraintsZeditableZ requirements build_dirsrcignore_requires_pythonZno_depsinstall_optionsglobal_optionsZ use_wheelZ no_use_wheelZ no_binaryZ only_binaryZpreno_cleanrequire_hashesZmake_option_groupZ index_groupparserZinsert_option_group)selfargskwr,Z index_opts) __class__/usr/lib/python3.6/install.pyr+8szInstallCommand.__init__c&Cstj|tj|dd}tjdkrJ| rJtjdtjt j d|j r\t j dt|jrnt j dt|jrt j dt|jrt j dt|jrt j d td |_|jrtjj|j|_tjj|j|_|jpg}|jr|jrtd trtd |jd |jdd}|jrtd |_tj }tjj|j|_tjj!|jrftjj"|j rftd|jd||j#p~g}|j$|T}|j%||}|j&p|j } t'|j(|j)} |j(rt*|j( rtjd|j(d|_(t+|j| d} t,| |j|j|j-|j.|j |j|j/|j0|j1|j|||j2|j3| |j4d} |j5| |||||j6| | j7s\dSz`y:|js~t8 s~|j( r| j9|nt:| |ggd} | j;d d|jsr| j<|||j=|j|j>dt?|j||j=|j|j3d}t@| jAtBjCdd}g}xX|D]P}|j6}y"tD|j6|}|r*|d|7}WntEk rBYnX|j|qWdjF|}|rtjGd|n(djFdd| jHD}|rtjGd|WntIk rd |_&YnXWd|j&s| jJXWdQRXWdQRX|jrtK|jg}tLd |d!d"}tLd |d!d#}tjj!|r4|j|tjj!|rV||krV|j|x|D]}xtjM|D]}tjjF|j|}tjj!|r|j-stjd$|qltjjN|rtjd%|qltjj"|rtOjP|n tjQ|tOjRtjjF|||qlWq\WtOjP|| S)&NcSs ttdpttdotjtjkS)NZ real_prefix base_prefix)hasattrsysr;r'r9r9r9r:is_venvs z#InstallCommand.run..is_venvrzpWARNING: Running pip install with root privileges is generally not a good idea. Try `%s install --user` instead.z--egg has been deprecated and will be removed in the future. This flag is mutually exclusive with large parts of pip, and actually using it invalidates pip's ability to manage the installation process.z--allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.zpip install --download has been deprecated and will be removed in the future. Pip now has a download command that should be used instead.TzVCan 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=z=Target path exists but is not a directory, will not continue.z--home=zThe 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.)delete)r-src_dirrrrr$r"ignore_dependenciesr/r!r#rsessionZ pycompileisolated wheel_cacher3)Z build_optionsr1)Z autobuilding)rootr'r&)userhomerEr'rCname)key- zSuccessfully installed %scSsg|] }|jqSr9)rH).0reqr9r9r: sz&InstallCommand.run..zSuccessfully downloaded %s)rGpurelibplatlibzKTarget 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.)Sr Zresolve_wheel_no_use_binaryZcheck_install_build_globalosgetuidloggerZwarningrbasenamer=argvr$warningswarnrZallow_externalZallow_all_externalZallow_unverifiedrr"r-abspathr@r0r#r(r rrappendrtempfileZmkdtempexistsisdirr1Z_build_sessionZ_build_package_finderr2r cache_dirZformat_controlrrrrrrAr/r!r)Z isolated_moder3Zpopulate_requirement_setrHZhas_requirementswheelZ prepare_filesrZbuildrr%r&get_lib_location_guessessortedZsuccessfully_installedoperator attrgetterr ExceptionjoininfoZsuccessfully_downloadedr Z cleanup_filesr rlistdirislinkshutilZrmtreeremoveZmove)r5Zoptionsr6r>r0Ztemp_target_dirr1rBfinderZ build_deleterDr-Zrequirement_setwbZpossible_lib_locationsZreqsitemsrMitemZinstalled_versionZ installedZ downloadedZ lib_dir_listZ purelib_dirZ platlib_dirZlib_dirZtarget_item_dirr9r9r:runsP                            zInstallCommand.run) __name__ __module__ __qualname____doc__rHZusageZsummaryr+ro __classcell__r9r9)r8r:r!s  rcOstd||}|d|dgS)NrOrPrQ)rO)r)r6kwargsschemer9r9r:r`sr`)*Z __future__rZloggingrbrRr[rirWr=rr_ ImportErrorZpip.reqrZpip.basecommandrZ pip.locationsrrZpip.exceptionsrr r Zpipr Z pip.utilsr r Zpip.utils.buildrZpip.utils.deprecationrZpip.utils.filesystemrZ pip.wheelrrZ getLoggerrprTrr`r9r9r9r:s8           ,