ó
b]c           @@  sç  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d	 l m Z d  d
 l m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z d  d l m  Z  d  d l! m" Z" m# Z# d  d l$ m% Z% d  d l& m' Z' d  d l( m) Z) m* Z* m+ Z+ d  d l, m- Z- d  d l. m/ Z/ d  d l0 m1 Z1 e j2 e3 ƒ Z4 d „  Z5 d „  Z6 d e f d „  ƒ  YZ7 d „  Z8 d „  Z9 d S(   i    (   t   absolute_importN(   t   SUPPRESS_HELP(   t   pkg_resources(   t
   WheelCache(   t
   cmdoptions(   t   RequirementCommand(   t   make_target_python(   t   ERROR(   t   CommandErrort   InstallationErrort   PreviousBuildDirError(   t   Resolver(   t   distutils_scheme(   t   check_install_conflicts(   t   RequirementPreparer(   t   RequirementSett   install_given_reqs(   t   RequirementTracker(   t   check_path_owner(   t
   ensure_dirt   get_installed_versiont(   protect_pip_from_modification_on_windows(   t   TempDirectory(   t   virtualenv_no_global(   t   WheelBuilderc          C@  s)   y d d l  }  Wn t k
 r$ t SXt S(   s8   
    Return whether the wheel package is installed.
    i    N(   t   wheelt   ImportErrort   Falset   True(   R   (    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyt   is_wheel_installed&   s
    c         C@  sJ   t  ƒ  } |  j | d | d t ƒ} | rF |  j | d | d t ƒn  | S(   sQ   
    Build wheels for requirements, depending on whether wheel is installed.
    t   sessiont   autobuilding(   R   t   buildR   (   t   buildert   pep517_requirementst   legacy_requirementsR   t   should_build_legacyt   build_failures(    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyt   build_wheels2   s    	t   InstallCommandc           B@  sD   e  Z d  Z d Z d Z d Z d „  Z d „  Z d „  Z d „  Z	 RS(   sI  
    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.
    t   installs%  
      %prog [options] <requirement specifier> [package-index-options] ...
      %prog [options] -r <requirements file> [package-index-options] ...
      %prog [options] [-e] <vcs project url> ...
      %prog [options] [-e] <local project path> ...
      %prog [options] <archive url/path> ...s   Install packages.c         O@  s¦  t  t |  ƒ j | | Ž  |  j } | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j	 ƒ  ƒ | j t j
 ƒ  ƒ | j d d d d d d d d  d d	 ƒt j | ƒ | j d
 d d d d d d ƒ| j d d d d d d t ƒ| j d d d d d d d  d d ƒ| j d d d d d d d  d d ƒ| j t j ƒ  ƒ | j t j ƒ  ƒ | j d d d d d d d d ƒ| j d d d d d d d d g d d  ƒ| j d! d d" d d d d# ƒ| j d$ d% d d& d d d d' ƒ| j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j d( d d d d) d t d d* ƒ| j d+ d d d d) d d, ƒ| j d- d d d d. d t d d/ ƒ| j d0 d d d d1 d t d d2 ƒ| j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ | j t j ƒ  ƒ t j t j |  j ƒ } |  j j  d3 | ƒ |  j j  d3 | ƒ d  S(4   Ns   -ts   --targett   destt
   target_dirt   metavart   dirt   defaultt   helps¥   Install packages into <dir>. By default this will not replace existing files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with new versions.s   --usert   use_user_sitet   actiont
   store_trues¸   Install 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.)s	   --no-usert   store_falses   --roott	   root_paths=   Install everything relative to this alternate root directory.s   --prefixt   prefix_pathsI   Installation prefix where lib, bin and other top-level folders are placeds   -Us	   --upgradet   upgrades‚   Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.s   --upgrade-strategyt   upgrade_strategys   only-if-neededt   choicest   eagersG  Determines 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).s   --force-reinstallt   force_reinstalls;   Reinstall all packages even if they are already up-to-date.s   -Is   --ignore-installedt   ignore_installeds5   Ignore the installed packages (reinstalling instead).s	   --compilet   compiles'   Compile Python source files to bytecodes   --no-compiles.   Do not compile Python source files to bytecodes   --no-warn-script-locationt   warn_script_locations0   Do not warn when installing scripts outside PATHs   --no-warn-conflictst   warn_about_conflictss%   Do not warn about broken dependenciesi    (!   t   superR'   t   __init__t   cmd_optst
   add_optionR   t   requirementst   constraintst   no_depst   pret   editablet   Nonet   add_target_python_optionsR   t	   build_dirt   srct   ignore_requires_pythont   no_build_isolationt
   use_pep517t   no_use_pep517t   install_optionst   global_optionsR   t	   no_binaryt   only_binaryt   prefer_binaryt   no_cleant   require_hashest   progress_bart   make_option_groupt   index_groupt   parsert   insert_option_group(   t   selft   argst   kwR@   t
   index_opts(    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR?   b   sÆ    					c   #   %   C@  sr  t  j | ƒ d } | j r( | j } n  | j rL t j j | j ƒ | _ n  t  j | d t	 ƒt j j | j
 ƒ | _
 | j pƒ g  } | j rÜ | j r§ t d ƒ ‚ n  t ƒ  r¿ t d ƒ ‚ n  | j d ƒ | j d ƒ n  t d d ƒ } | j rpt	 | _ t j j | j ƒ | _ t j j | j ƒ rOt j j | j ƒ rOt d	 ƒ ‚ n  | j ƒ  | j d
 | j ƒ n  | j p|g  } |  j | ƒ ¹} t | ƒ } |  j d | d | d | d | j ƒ }	 | j pÓ| j }
 t | j | j  ƒ } | j r$t! | j ƒ r$t" j# d | j ƒ d  | _ n  t% ƒ  } t | j d |
 d d ƒð} t& d | j' d | j ƒ } z©y;|  j( | | | |	 | |  j) | ƒ t* d | j d | j
 d d  d d  d | j+ d | j, d | ƒ } t- d | d |	 d | d | d | j d | d  | j. d! | j/ d | j d" | j d# | j0 d$ | j1 ƒ } | j2 | ƒ t3 d% | j4 d& ƒ ƒ g  } g  } x= | j5 j6 ƒ  D], } | j1 r•| j | ƒ qv| j | ƒ qvWt7 |	 | | d' g  d( g  ƒ} t8 d) | d* | d+ | d | ƒ } | rt d, j9 d- j: d. „  | Dƒ ƒ ƒ ƒ ‚ n  | j; | ƒ } | j/ o5| j< } | rN|  j= | ƒ n  | j> } | j rit? } n  t@ | | | d/ | jA d0 | j d1 | j d2 | jB d3 | d | j ƒ} tC d4 | j d0 | j d/ | jA d1 | j d# | j0 ƒ } tD jE | ƒ } tF | d5 tG jH d6 ƒ ƒ} g  } xh | D]` } | j) } y0 tI | j) d7 | ƒ} | rY| d8 | 7} n  Wn tJ k
 rmn X| j | ƒ qWd9 j: | ƒ } | r§t" jK d: | ƒ n  Wng tL k
 rõ}  |  jM d; k }! tN |  |! | j ƒ }" t" jO |" d< |! ƒtP StQ k
 rt	 | _ ‚  n XWd  | j s6| jR ƒ  | jS ƒ  n  XWd  QXWd  QXWd  QX| j rn|  jT | j | | j ƒ n  | S(=   Ns   to-satisfy-onlyt   check_targetsV   Can not combine '--user' and '--prefix' as they imply different installation locationssZ   Can not perform a '--user' install. User site-packages are not visible in this virtualenv.s   --users	   --prefix=t   kindt   targets=   Target path exists but is not a directory, will not continue.s   --home=t   optionsR   t   target_pythonRK   sÝ   The 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.t   deleteR(   RU   t   check_supported_wheelsRI   t   src_dirt   download_dirt   wheel_download_dirRV   t   build_isolationt   req_trackert   preparert   findert   wheel_cacheR/   R6   R9   t   ignore_dependenciesR:   t   isolatedRM   t   modifying_pipt   pipt   build_optionsRP   R!   R"   R#   sP   Could not build wheels for {} which use PEP 517 and cannot be installed directlys   , c         s@  s   |  ] } | j  Vq d  S(   N(   t   name(   t   .0t   r(    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pys	   <genexpr>z  s    t   roott   homet   prefixt	   pycompileR<   t   usert   keyRs   t   working_sett   -t    s   Successfully installed %si   t   exc_info(U   R   t   check_install_build_globalR5   R6   RI   t   ost   patht   abspatht   check_dist_restrictionR   Rf   RO   R/   R4   R   R   R	   t   appendR   R*   R:   t   existst   isdirt   createRP   t   _build_sessionR   t   _build_package_finderRK   RT   R   t	   cache_dirt   format_controlR   t   loggert   warningRG   R   R   RU   t   populate_requirement_setRs   R   RV   Ri   R   R9   Rn   t   isolated_modeRM   t   resolveR   t   has_requirementRB   t   valuesR   R&   t   formatt   joint   get_installation_orderR=   t   _warn_about_conflictsR<   R   R   R3   R;   t   get_lib_location_guessesR   t
   WorkingSett   sortedt   operatort
   attrgetterR   t	   Exceptiont   infot   EnvironmentErrort	   verbosityt   create_env_error_messaget   errorR   R
   t   cleanup_filest   cleanupt   _handle_target_dir(#   R[   Rb   R\   R6   RO   t   target_temp_dirRP   R   Rc   Rl   t   build_deleteRm   Rj   t	   directoryt   requirement_setRk   t   resolverR#   R"   t   reqt   wheel_builderR%   t
   to_installt   should_warn_about_conflictsR<   t	   installedt   lib_locationsR|   t   reqst   itemst   itemt   installed_versionR¢   t   show_tracebackt   message(    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyt   runò   s4   							
	
 	 													"	
															
 	c      
   @  s÷  t  | ƒ g  } | Ût d d | j ƒ} | d } | d } | d } t j j | ƒ rl | j | ƒ n  t j j | ƒ rš | | k rš | j | ƒ n  t j j | ƒ r¼ | j | ƒ n  x.| D]&}	 xt j |	 ƒ D]}
 |	 | k r)t j j | |
 ƒ ‰  t ‡  f d †  | d  Dƒ ƒ r)qÙ q)n  t j j | |
 ƒ } t j j | ƒ rÆ| slt	 j
 d | ƒ qÙ n  t j j | ƒ r”t	 j
 d	 | ƒ qÙ n  t j j | ƒ r¶t j | ƒ qÆt j | ƒ n  t j t j j |	 |
 ƒ | ƒ qÙ WqÃ WWd  QXd  S(
   Nt    Rw   t   purelibt   platlibt   datac         3@  s   |  ] } | j  ˆ  ƒ Vq d  S(   N(   t
   startswith(   Rt   t   s(   t   ddir(    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pys	   <genexpr>å  s    iÿÿÿÿsK   Target directory %s already exists. Specify --upgrade to force replacement.s„   Target directory %s already exists and is a link. Pip will not automatically replace links, please remove if replacement is desired.(   R   R   R‚   R   R†   R…   t   listdirR•   t   anyR   RŽ   t   islinkR‡   t   shutilt   rmtreet   removet   move(   R[   R*   R¦   R5   t   lib_dir_listt   schemet   purelib_dirt   platlib_dirt   data_dirt   lib_dirR³   t   target_item_dir(    (   R¾   s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR¥   Ë  sJ    



 	c      	   C@  sõ   y t  | ƒ \ } } Wn% t k
 r= t j d d t ƒd  SX| \ } } xK | D]C } | | d } x, | | D]  } t j d | | | d ƒ qp WqQ WxV | D]N } | | d } x7 | | D]+ \ }	 }
 } t j d | | | |	 |
 ƒ q¾ WqŸ Wd  S(   Ns   Error checking for conflicts.R   i    s*   %s %s requires %s, which is not installed.i   sF   %s %s has requirement %s, but you'll have %s %s which is incompatible.(   R   R   R   R¢   R   t   critical(   R[   R­   t   package_sett	   _dep_infot   missingt   conflictingt   project_namet   versiont
   dependencyt   dep_namet   dep_versionR«   (    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR—     s$    (
   t   __name__t
   __module__t   __doc__Rs   t   usaget   summaryR?   R·   R¥   R—   (    (    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR'   K   s   		Ù	8c          O@  s$   t  d |  | Ž } | d | d g S(   NR¸   R¹   Rº   (   R   (   R\   t   kwargsRÇ   (    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR˜     s    c         C@  sÐ   g  } | j  d ƒ | s< | j  d ƒ | j  t |  ƒ ƒ n | j  d ƒ | d c d 7<|  j t j k r¹ d } d } | sœ | j | d | j ƒ  g ƒ n | j  | ƒ | j  d	 ƒ n  d
 j | ƒ j ƒ  d S(   s{   Format an error message for an EnvironmentError

    It may occur anytime during the execution of the install command.
    s5   Could not install packages due to an EnvironmentErrors   : t   .iÿÿÿÿs   
s"   Consider using the `--user` options   Check the permissionss    or s   .
R¸   (   R…   t   strt   errnot   EACCESt   extendt   lowerR•   t   strip(   R¢   Rµ   t   using_user_sitet   partst   user_option_partt   permissions_part(    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyR¡   #  s"    (:   t
   __future__R    Rß   t   loggingR›   R   RÂ   t   optparseR   t   pip._vendorR   t   pip._internal.cacheR   t   pip._internal.cliR   t   pip._internal.cli.base_commandR   t   pip._internal.cli.cmdoptionsR   t   pip._internal.cli.status_codesR   t   pip._internal.exceptionsR   R	   R
   t   pip._internal.legacy_resolveR   t   pip._internal.locationsR   t   pip._internal.operations.checkR   t    pip._internal.operations.prepareR   t   pip._internal.reqR   R   t   pip._internal.req.req_trackerR   t   pip._internal.utils.filesystemR   t   pip._internal.utils.miscR   R   R   t   pip._internal.utils.temp_dirR   t   pip._internal.utils.virtualenvR   t   pip._internal.wheelR   t	   getLoggerR×   R   R   R&   R'   R˜   R¡   (    (    (    s=   lib/python2.7/site-packages/pip/_internal/commands/install.pyt   <module>   s>   		ÿ Ô	