
вEbc           @@  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 m Z d  d
 l m Z 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& d  d l' m( Z( d  d l) m* Z* m+ Z+ m, Z, m- Z- m. Z. d  d l/ m0 Z0 d  d l1 m2 Z2 d  d l3 m4 Z4 d  d l5 m6 Z6 m7 Z7 e2 r=d  d l m8 Z8 d  d l9 m: Z: m; Z; m< Z< d  d l= m> Z> d  d l m? Z? d  d l@ mA ZA d  d l5 mB ZB n  e jC eD  ZE d   ZF d e f d     YZG eH eI eI eH eI d   ZJ d!   ZK eI eI eI eH d"  ZL d#   ZM d$   ZN d S(%   i    (   t   absolute_importN(   t   SUPPRESS_HELP(   t   pkg_resources(   t   canonicalize_name(   t
   WheelCache(   t
   cmdoptions(   t   make_target_python(   t   RequirementCommandt   with_cleanup(   t   ERRORt   SUCCESS(   t   CommandErrort   InstallationError(   t   distutils_scheme(   t   check_install_conflicts(   t   install_given_reqs(   t   get_requirement_tracker(   t   parse_distutils_args(   t   test_writable_dir(   t
   ensure_dirt   get_installed_versiont   get_pip_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   Iterablet   Listt   Optional(   t   FormatControl(   t   ConflictDetails(   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-UPPWic/pip/pip/_internal/commands/install.pyt   check_binary_allowed5   s
    	(    (   R-   R.   (    (   R-   s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyt   get_check_binary_allowed3   s    t   InstallCommandc           B@  sG   e  Z d  Z d Z d   Z e 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         C@  s  |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j d d d d d d d d  d d	 t j	 |  j   |  j  j d
 d d d d d d |  j  j d d d d d d t
 |  j  j d d d d d d d  d d |  j  j d d d d d d d  d d |  j  j t j    |  j  j t j    |  j  j d d d d d d d d |  j  j d d d d d d d d g d d  |  j  j d! d d" d d d d# |  j  j d$ d% d d& d d d d' |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j d( d d d d) d t d d* |  j  j d+ d d d d) d d, |  j  j d- d d d d. d t d d/ |  j  j d0 d d d d1 d t d d2 |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    |  j  j t j    t j t j |  j  } |  j j d3 |  |  j j d3 |  j   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   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   require_hashest   progress_bart   make_option_groupt   index_groupt   parsert   insert_option_group(   t   selft
   index_opts(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyt   add_optionsT   s    																	c   )      C@  s&  | j  r' | j d  k	 r' t d   n  t j |  d } | j rO | j } n  t j | d t	 | j
 pn g  } t j d t    t | j  d | j d | j d | j d | j | _  d  } d  } | j rRt	 | _ t j j | j  | _ t j j | j  r*t j j | j  r*t d	   n  t d
 d  } | j } |  j |  n  | j p^g  } |  j |  } t |  }	 |  j d | d | d |	 d | j  }
 t | j  | j!  } |  j t"    } t d | j# d
 d d t	  } y|  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+ | d | j } y | j, d  } Wn t- k
 rt. } n X| j/ d  k } t0 d |  t1 |
 j!  } g  | j2 j3   D] } t4 | |  r,| ^ q,} t5 | d | d  t	 d! g  d" g  \ } } g  | D] } | j) r~| j6 ^ q~} | rt7 d# j8 d$ j9 |     n  x# | D] } | j) sd% | _: qqW| j; |  } d  } | j< o| j= } | r)|  j> |  } n  | j? } | j rDt. } n  t@ | | | d& | j d' | d( | j d) | d | j  d* | jA } tB d+ | j  d' | d& | j d( | j d, | j  } tC jD |  }  | jE d- tF jG d.   g  }! xh | D]` }" |" j6 }# y0 tH |" j6 d/ |  }$ |$ r,|# d0 |$ 7}# n  Wn tI k
 r@n X|! jJ |#  qW| d  k	 r}|  jK | d1 |  jL |  n  d2 j9 |!  }% |% rtM d3 |%  n  WnK tN k
 r}& |  jO d4 k }' tP |& |' | j   }( t jQ |( d5 |' tR SX| j r"| stS  |  jT | j | | j  n  tU S(6   Ns'   Can not combine '--user' and '--target's   to-satisfy-onlyt   check_targets   Using %sR<   R2   R;   t   isolated_modes=   Target path exists but is not a directory, will not continue.t   kindt   targett   optionst   sessiont   target_pythonRQ   t   deletet   installt   globally_managedt   temp_build_dirt   req_trackert   finderR7   t   preparert   wheel_cacheRB   RA   R>   R&   t   check_supported_wheelst   pipt   modifying_pipt   verifyt   build_optionsRU   sP   Could not build wheels for {} which use PEP 517 and cannot be installed directlys   , i   t   roott   homet   prefixRD   t	   pycompilet   usert   isolatedt   keyR(   t   working_sett   -t   resolver_variantt    s   Successfully installed %si   t   exc_info(V   R7   R2   RM   R   R   t   check_install_build_globalR=   R>   t   check_dist_restrictionR'   RT   t   loggert   debugR   t   decide_user_installR<   R;   Rc   RB   t   ost   patht   abspatht   existst   isdirR   t   enter_contextRU   t   get_default_sessionR   t   _build_package_finderRQ   R   t	   cache_dirR-   R   t   no_cleant   get_requirementst'   reject_location_related_install_optionst   make_requirement_preparert   make_resolverRA   R&   t   trace_basic_infot   resolvet   get_requirementt   KeyErrort   Falset   satisfied_byR   R/   RH   t   valuesR   R   R(   R   t   formatt   joint   legacy_install_reasont   get_installation_ordert   ignore_dependenciesRE   t   _determine_conflictsRD   R   RC   t   get_lib_location_guessesR   t
   WorkingSett   sortt   operatort
   attrgetterR   t	   Exceptiont   appendt   _warn_about_conflictst   determine_resolver_variantR   t   EnvironmentErrort	   verbosityt   create_env_error_messaget   errorR	   t   AssertionErrort   _handle_target_dirR
   ()   R_   Rf   t   argsR>   RT   t   target_temp_dirt   target_temp_dir_pathRU   Rg   Rh   Rn   Rp   Rm   t	   directoryt   reqsRo   t   resolvert   requirement_sett   pip_reqRs   R.   t   rt   reqs_to_buildt   _t   build_failurest   pep517_build_failure_namest
   to_installt	   conflictst   should_warn_about_conflictsRD   t	   installedt   lib_locationsR}   t   itemst   resultt   itemt   installed_versiont   installed_descR   t   show_tracebackt   message(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyt   run   s.   									
							
"		
												c         @  s  t  |  g  } t d d | j } | d } | d } | d } t j j |  re | 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| se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 Wd  S(
   Nt    Rw   t   purelibt   platlibt   datac         3@  s   |  ] } | j     Vq d  S(   N(   t
   startswith(   t   .0t   s(   t   ddir(    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pys	   <genexpr>  s    isK   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(   R_   R2   R   R=   t   lib_dir_listt   schemet   purelib_dirt   platlib_dirt   data_dirt   lib_dirR   t   target_item_dir(    (   R   s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR     sH    



 	c         C@  s4   y t  |  SWn t k
 r/ t j d  d  SXd  S(   Nsw   Error while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new(   R   R   R   t	   exceptionRM   (   R_   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR     s    c         C@  sn  | \ } \ } } | r$ | r$ d  Sg  } | d k rF | j  d  n | d k sX t  | j  d  x` | D]X } | | d } xA | | D]5 }	 d j d | d | d	 |	 d
  }
 | j  |
  q Wql Wx | D] } | | d } xj | | D]^ \ } } } d j d | d | d	 | d | d | d | d k r6d n d  }
 | j  |
  q Wq Wt j d j |   d  S(   Nt   legacys   pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.s   2020-resolvers   pip'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.i    s@   {name} {version} requires {requirement}, which is not installed.R(   t   versiont   requirementi   sg   {name} {version} requires {requirement}, but {you} have {dep_name} {dep_version} which is incompatible.t   dep_namet   dep_versiont   yous   you'lls   
(   R   R   R   R   t   criticalR   (   R_   t   conflict_detailsR   t   package_sett   missingt   conflictingt   partst   project_nameR   t
   dependencyR   R   R   R*   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR     s<    
		(
   t   __name__t
   __module__t   __doc__t   usageRa   R   R   R   R   R   (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR0   @   s   		8	c         C@  s<   t  d d |  d | d | d | d | } | d | d g S(	   NR   Rz   Rw   Rv   R{   Rx   R   R   (   R   (   Rz   Rw   Rv   R{   Rx   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR   D  s    c         C@  s)   t  d   t t d |  d |   D  S(   Nc         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   R   t   d(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pys	   <genexpr>T  s    Rv   R{   (   t   allt   setR   (   Rv   R{   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyt   site_packages_writableQ  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 disabledRv   R{   s0   Non-user install because site-packages writeablesM   Defaulting to user installation because normal site-packages is not writeableN(   RM   R   R   R   R   R   R   R'   R   t   sitet   ENABLE_USER_SITER   t   info(   R7   R<   R2   R;   Rc   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR   Y  s0    		c         C@  s   d   } g  } xQ |  D]I } | j  } t |  } | r | j d j | | j    |   q q W| r t |  } | r | j d j | | j      q n  | s d St d j d j |     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-UPPWic/pip/pip/_internal/commands/install.pyt   format_options  s    s   {!r} from {}s   {!r} from command lineNs   Location-changing options found in --install-option: {}. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.s   ; (   RT   R   R   R   t   keysR   R   (   RH   Rf   R   t	   offendersR   RT   t   location_options(    (    s;   /tmp/pip-build-UPPWic/pip/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   .is   
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_siteR   t   user_option_partt   permissions_part(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyR     s"    (O   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   R   t   pip._internal.cli.status_codesR	   R
   t   pip._internal.exceptionsR   R   t   pip._internal.locationsR   t   pip._internal.operations.checkR   t   pip._internal.reqR   t   pip._internal.req.req_trackerR   t"   pip._internal.utils.distutils_argsR   t   pip._internal.utils.filesystemR   t   pip._internal.utils.miscR   R   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    t#   pip._internal.models.format_controlR!   R"   t   pip._internal.req.req_installR#   R$   t	   getLoggerR   R   R/   R0   R   RM   R   R   R   R   R   (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/install.pyt   <module>   sd   (	  	
7	*