ó
0±E^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 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 d  d l m Z m Z 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) d  d l* m+ Z+ d  d l, m- Z- m. Z. m/ Z/ m0 Z0 d  d l1 m2 Z2 d  d l3 m4 Z4 d  d l5 m6 Z6 d  d l7 m8 Z8 m9 Z9 e4 rCd  d l m: Z: d  d l; m< Z< m= Z= m> Z> m? Z? d  d l@ mA ZA d  d lB mC ZC d  d l7 mD ZD n  e jE eF ƒ ZG d „  ZH d e f d „  ƒ  YZI d  „  ZJ d! „  ZK eL eL eL eM d" „ ZN d# „  ZO d$ „  ZP d S(%   i    (   t   absolute_importN(   t   SUPPRESS_HELP(   t   pkg_resources(   t   canonicalize_name(   t
   WheelCache(   t
   cmdoptions(   t   make_target_python(   t   RequirementCommand(   t   ERRORt   SUCCESS(   t   CommandErrort   InstallationErrort   PreviousBuildDirError(   t   distutils_scheme(   t   check_install_conflicts(   t   RequirementSett   install_given_reqs(   t   get_requirement_tracker(   t
   deprecated(   t   parse_distutils_args(   t   test_writable_dir(   t
   ensure_dirt   get_installed_versiont(   protect_pip_from_modification_on_windowst   write_output(   t   TempDirectory(   t   MYPY_CHECK_RUNNING(   t   virtualenv_no_global(   t   buildt    should_build_for_install_command(   t   Values(   t   Anyt   Iterablet   Listt   Optional(   t   FormatControl(   t   InstallRequirement(   t   BinaryAllowedPredicatec         @  s   ‡  f d †  } | S(   Nc         @  s5   |  j  r t St |  j ƒ } ˆ  j | ƒ } d | k S(   Nt   binary(   t
   use_pep517t   TrueR   t   namet   get_allowed_formats(   t   reqt   canonical_namet   allowed_formats(   t   format_control(    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   check_binary_allowed?   s
    	(    (   R.   R/   (    (   R.   s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   get_check_binary_allowed=   s    t   InstallCommandc           B@  s8   e  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.
    s%  
      %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> ...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_installeds°   Ignore 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!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   superR1   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_isolationR'   t   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   kwRI   t
   index_opts(    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyRH   ^   sÆ    					c   (      C@  sâ  t  j | ƒ d } | j r( | j } n  t  j | d t ƒ| j pG g  } t | j d | j	 d | j
 d | j d | j ƒ| _ d  } d  } | j
 rt | _ t j j | j
 ƒ | _
 t j j | j
 ƒ rð t j j | j
 ƒ rð t d ƒ ‚ n  t d d	 ƒ } | j } n  | j pg  } |  j | ƒ } t | ƒ }	 |  j d
 | d | d |	 d | j ƒ }
 | j pk| j } t | j | j ƒ } t  ƒ  �*} t | j d | d d ƒ�} t! d | j
 ƒ } zÈyZ|  j" | | | |
 | | ƒ t# | | j ƒ |  j$ d | d
 | d | d | d |
 d | j ƒ } |  j% d | d |
 d
 | d | d | j d | j d | j d | j& d | d | j' ƒ 
} |  j( |
 ƒ | j) | ƒ y | j* d ƒ } Wn t+ k
 rÃd  } n X| j, d  k } t- d | ƒ t. |
 j ƒ } g  | j/ j0 ƒ  D] } t1 | | ƒ rÿ| ^ qÿ} t2 | d | d g  d g  ƒ\ } } g  | D] } | j' rK| ^ qK} | r—t3 d j4 d  j5 d! „  | Dƒ ƒ ƒ ƒ ‚ n  | j6 | ƒ } | j7 o¶| j8 } | rÏ|  j9 | ƒ n  | j: } | j
 rêt; } n  t< | | | d" | j d# | d$ | j	 d% | j= d& | d | j ƒ} t> d' | j d# | d" | j d$ | j	 d( | j ƒ } t? j@ | ƒ } | jA d) tB jC d* ƒ ƒ g  }  xh | D]` }! |! jD }" y0 tE |! jD d+ | ƒ}# |# rÒ|" d, |# 7}" n  Wn tF k
 ræn X|  jG |" ƒ q”Wd- j5 |  ƒ }$ |$ rtH d. |$ ƒ n  Wng tI k
 rk}% |  jJ d/ k }& tK |% |& | j ƒ }' tL jM |' d0 |& ƒtN StO k
 r‡t | _ ‚  n XWd  | j s¬| jP ƒ  | jQ ƒ  n  XWd  QXWd  QX| j
 rÞ|  jR | j
 | | j ƒ n  tS S(1   Ns   to-satisfy-onlyt   check_targetR=   R3   R<   t   isolated_modes=   Target path exists but is not a directory, will not continue.t   kindt   targett   optionst   sessiont   target_pythonRT   t   deletet   installt   check_supported_wheelst   temp_build_dirt   req_trackert   finderR8   t   preparert   wheel_cacheRC   RB   R?   R'   t   pipt   modifying_pipt   build_optionsRX   sP   Could not build wheels for {} which use PEP 517 and cannot be installed directlys   , c         s@  s   |  ] } | j  Vq d  S(   N(   R)   (   t   .0t   r(    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pys	   <genexpr>w  s    t   roott   homet   prefixt	   pycompileRE   t   usert   isolatedt   keyR)   t   working_sett   -t    s   Successfully installed %si   t   exc_info(T   R   t   check_install_build_globalR>   R?   t   check_dist_restrictionR(   RW   t   decide_user_installR8   R=   R3   R<   Rh   RP   RC   t   ost   patht   abspatht   existst   isdirR
   R   RX   t   get_default_sessionR   t   _build_package_finderRT   R\   RR   R   t	   cache_dirR.   R   R   t   populate_requirement_sett   warn_deprecated_install_optionst   make_requirement_preparert   make_resolverRB   R'   t   trace_basic_infot   resolvet   get_requirementt   KeyErrort   satisfied_byR   R0   RK   t   valuesR   R   R   t   formatt   joint   get_installation_ordert   ignore_dependenciesRF   t   _warn_about_conflictsRE   t   FalseR   RD   t   get_lib_location_guessesR   t
   WorkingSett   sortt   operatort
   attrgetterR)   R   t	   Exceptiont   appendR   t   EnvironmentErrort	   verbosityt   create_env_error_messaget   loggert   errorR   R   t   cleanup_filest   cleanupt   _handle_target_dirR	   ((   Rc   Rk   Rd   R?   RW   t   target_temp_dirt   target_temp_dir_pathRX   Rl   Rm   Rs   t   build_deleteRu   Rr   t	   directoryt   requirement_setRt   t   resolvert   pip_reqRw   R/   Rz   t   reqs_to_buildt   _t   build_failurest   pep517_build_failurest
   to_installt   should_warn_about_conflictsRE   t	   installedt   lib_locationsR‚   t   itemst   resultt   itemt   installed_versiont   installed_descR¬   t   show_tracebackt   message(    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   runò   s$   								  						
	""	
													
	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    R|   t   purelibt   platlibt   datac         3@  s   |  ] } | j  ˆ  ƒ Vq d  S(   N(   t
   startswith(   Ry   t   s(   t   ddir(    s;   /tmp/pip-build-iCT__d/pip/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«   t   warningt   islinkR�   t   shutilt   rmtreet   removet   move(   Rc   R3   R°   R>   t   lib_dir_listt   schemet   purelib_dirt   platlib_dirt   data_dirt   lib_dirRÁ   t   target_item_dir(    (   RÍ   s;   /tmp/pip-build-iCT__d/pip/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(   Rc   R»   t   package_sett	   _dep_infot   missingt   conflictingt   project_namet   versiont
   dependencyt   dep_namet   dep_versionR+   (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyRŸ     s$    (   t   __name__t
   __module__t   __doc__t   usageRH   RÆ   R¯   RŸ   (    (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyR1   J   s   	”	Ù	8c          O@  s$   t  d |  | Ž } | d | d g S(   NRÇ   RÈ   RÉ   (   R   (   Rd   t   kwargsR×   (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyR¡     s    c          K@  s    t  d „  t t |  �  ƒ Dƒ ƒ S(   Nc         s@  s   |  ] } t  | ƒ Vq d  S(   N(   R   (   Ry   t   d(    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pys	   <genexpr>%  s    (   t   allt   setR¡   (   Rë   (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   site_packages_writable#  s    c         C@  sè   |  d k	 r$ |  r$ t j d ƒ t S|  rh | r? t d ƒ ‚ n  t ƒ  rW t d ƒ ‚ n  t j d ƒ t S|  d k sz t ‚ | s† | r— t j d ƒ t St	 j
 s± t j d ƒ t St d | d | ƒ r× t j d	 ƒ t St j d
 ƒ t S(   sZ  Determine 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.
    s$   Non-user install by explicit requestsV   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    User install by explicit requests3   Non-user install due to --prefix or --target options4   Non-user install because user site-packages disabledR{   R€   s0   Non-user install because site-packages writeablesM   Defaulting to user installation because normal site-packages is not writeableN(   RP   R«   t   debugR    R
   R   R   R(   t   AssertionErrort   sitet   ENABLE_USER_SITERï   t   info(   R8   R=   R3   R<   Rh   (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyRˆ   )  s0    		c      	   C@  s
  d „  } |  j  t |  j j ƒ  ƒ } g  } x] | D]U } | j j d g  ƒ } t | ƒ } | r2 | j d j | | j	 ƒ  ƒ | ƒ ƒ q2 q2 W| rË t | ƒ } | rË | j d j | | j	 ƒ  ƒ ƒ ƒ qË n  | sÕ d St
 d d j d j | ƒ ƒ d	 d
 d d d d ƒ d S(   s’   If any location-changing --install-option arguments were passed for
    requirements or on the command-line, then show a deprecation warning.
    c         S@  s,   g  |  D]! } d j  | j d d ƒ ƒ ^ q S(   Ns   --{}R¸   Rƒ   (   R›   t   replace(   t   option_namesR)   (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   format_optionsj  s    RW   s   {!r} from {}s   {!r} from command lineNt   reasons}   Location-changing options found in --install-option: {}. This configuration may cause unexpected behavior and is unsupported.s   ; t   replacementsC   using pip-level options like --user, --prefix, --root, and --targett   gone_ins   20.2t   issuei�  (   t   unnamed_requirementst   listRK   Rš   Rk   t   getR   R§   R›   t   keysR   Rœ   (   R´   Rk   R÷   RK   t	   offenderst   requirementRW   t   location_options(    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyR’   e  s2    	 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;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyRª   œ  s"    (Q   t
   __future__R    R  t   loggingR¤   R‰   RÒ   Rò   t   optparseR   t   pip._vendorR   t   pip._vendor.packaging.utilsR   t   pip._internal.cacheR   t   pip._internal.cliR   t   pip._internal.cli.cmdoptionsR   t   pip._internal.cli.req_commandR   t   pip._internal.cli.status_codesR   R	   t   pip._internal.exceptionsR
   R   R   t   pip._internal.locationsR   t   pip._internal.operations.checkR   t   pip._internal.reqR   R   t   pip._internal.req.req_trackerR   t   pip._internal.utils.deprecationR   t"   pip._internal.utils.distutils_argsR   t   pip._internal.utils.filesystemR   t   pip._internal.utils.miscR   R   R   R   t   pip._internal.utils.temp_dirR   t   pip._internal.utils.typingR   t   pip._internal.utils.virtualenvR   t   pip._internal.wheel_builderR   R   R   t   typingR   R    R!   R"   t#   pip._internal.models.format_controlR#   t   pip._internal.req.req_installR$   R%   t	   getLoggerRç   R«   R0   R1   R¡   Rï   RP   R    Rˆ   R’   Rª   (    (    (    s;   /tmp/pip-build-iCT__d/pip/pip/_internal/commands/install.pyt   <module>   sZ   ""	ÿ Õ		7	7