
j^c           @@  s	  d  Z  d d l m 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 m Z 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 d d l m Z d d l m  Z  e  rod d l! m" Z" m# Z# m$ Z$ m% Z% m& Z& d d l m' Z' m( Z( d d l) m* Z* n  e j+ e,  Z- d   Z. d   Z/ d d  Z1 e2 d  Z3 d   Z4 d e f d     YZ5 e
 e d d d d d d d d Z6 e
 e d  d d! d d" d# e2 d d$ Z7 e
 e d% d& d d' d d" d# e2 d e Z8 e
 e d( d) d d* d d+ d# d d d, Z9 e
 e d- d d. d d" d# e2 d d/ Z: e
 e d0 d1 d d2 d d" d d3 Z; e
 e d4 d5 d d6 d d+ d# d d d7 Z< e
 e d8 d d9 d: d; d< e= e j>    d# d= d d> d? j? e j>    d@ Z@ e
 e5 dA dB dC d dD dE dF d: dF d dG ZA e
 e dH d dI d d" d# e2 d e ZB e
 e dJ d dK d: dL d# dM d dN ZC e
 e dO d dP d: dQ d# dR d dS ZD e
 e dT dU dE dV d dW d: dX d# dY d dZ ZE d[   ZF e
 e5 d\ d d] d: dF dE dF d d^ ZG e
 e5 d_ d d` d: dF d# d dE dF d da ZH e
 e db dc dd d de dE df d# e jI d dg ZJ dh   ZK e
 e di d dj d d" d# e2 d dk ZL dl   ZM dm   ZN dn   ZO do   ZP dp   ZQ dq   ZR e
 e5 dr ds dt du d dv d: dF dE dw d# e   d dx dx eR d dy ZS dz   ZT d{   ZU d|   ZV d}   ZW d~   ZX e
 e d d d dE d d# d d d ZY d   ZZ d   Z[ e
 e d d d dE d d dx dx e[ d: dL d# d d e d  Z\ e
 e d d d dE d d# d d d Z] e
 e d d d dE d d# d d d Z^ d   Z_ d   Z` d   Za e
 e5 d d d d# e dE dw d: dF d d Zb d   Zc e
 e d d d d dx dx ec d d Zd e
 e d d d d d d" d# e2 d d Ze d   Zf e
 e5 d d d d d d d: dF dE dw d dx dx ef d d Zg e
 e d d d d d" d d Zh e
 e d d d d d d# ei d d Zj d   Zk e
 e d d d d d" d# d d d Zl e
 e d d d d dx dx ek d# d d e Zm e
 e d d d d d dE d d d Zn e
 e d d d d d dE d d d Zo e
 e d d d" d# e2 d d Zp e
 e d d d" d# e2 d d Zq e
 e d d d d d" d# e2 d d Zr e
 e d d d d d d" d e Zs d   Zt e
 e d d d d dx dx et d: d d d Zu e
 e d d d d d" d# e2 d d Zv e
 e5 d d dF d: dF d d d d Zw d   Zx e
 e d d d d d" d# e2 d d Zy e
 e d d d dE d d d d# g  d< d g d e Zz i d d 6e6 e7 e8 e9 e; e< eA eB eC eD eE eF eN eG eH eb ed er e: ey ez g d 6Z{ i d d 6eJ eK eL eM g d 6Z| d S(   sC  
shared options and groups

The principle here is to define options once, but *not* instantiate them
globally. One reason being that options with action='append' can carry state
between parses. pip parses general options twice internally, and shouldn't
pass on state. To be consistent, all options will follow this design.
i    (   t   absolute_importN(   t	   strtobool(   t   partial(   t   SUPPRESS_HELPt   Optiont   OptionGroup(   t   dedent(   t	   BAR_TYPES(   t   CommandError(   t   USER_CACHE_DIRt   get_src_prefix(   t   FormatControl(   t   PyPI(   t   TargetPython(   t   STRONG_HASHES(   t   MYPY_CHECK_RUNNING(   t   Anyt   Callablet   Dictt   Optionalt   Tuple(   t   OptionParsert   Values(   t   ConfigOptionParserc         C@  sA   d j  | |  } t j d j | j     } |  j |  d S(   s   
    Raise an option parsing error using parser.error().

    Args:
      parser: an OptionParser instance.
      option: an Option instance.
      msg: the error text.
    s   {} error: {}t    N(   t   formatt   textwrapt   fillt   joint   splitt   error(   t   parsert   optiont   msg(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   raise_option_error)   s    
c         C@  s<   t  | |  d  } x" |  d D] } | j |    q W| S(   s   
    Return an OptionGroup object
    group  -- assumed to be dict with 'name' and 'options' keys
    parser -- an optparse Parser
    t   namet   options(   R   t
   add_option(   t   groupR   t   option_groupR    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   make_option_group8   s    c         @  su     d k r |    n    f d   } d d d g } t t | |   rq |  j } | j   t j d d d n  d S(	   s   Disable wheels if per-setup.py call options are set.

    :param options: The OptionParser options to update.
    :param check_options: The options to check, if not supplied defaults to
        options.
    c         @  s   t    |  d   S(   N(   t   getattrt   None(   t   n(   t   check_options(    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   getnameP   s    t   build_optionst   global_optionst   install_optionssb   Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.t
   stackleveli   N(   R*   t   anyt   mapt   format_controlt   disallow_binariest   warningst   warn(   R$   R,   R-   t   namest   control(    (   R,   s-   site-packages/pip/_internal/cli/cmdoptions.pyt   check_install_build_globalE   s    		
c         C@  s   t  |  j |  j |  j |  j g  } t t   d h  } |  j | k oO |  j } | rm | rm t	 d   n  | r | r |  j
 r t	 d   q n  d S(   s   Function for determining if custom platform options are allowed.

    :param options: The OptionParser options.
    :param check_target: Whether or not to check if --target is being used.
    s   :all:s   When restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).sQ   Can not use any platform or abi specific options unless installing via '--target'N(   R2   t   python_versiont   platformt   abit   implementationR   t   setR4   t   ignore_dependenciesR   t
   target_dir(   R$   t   check_targett   dist_restriction_sett   binary_onlyt   sdist_dependencies_allowed(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   check_dist_restriction]   s    
c         C@  s   t  j j |  S(   N(   t   ost   patht
   expanduser(   R    t   optt   value(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _path_option_check   s    t	   PipOptionc           B@  s.   e  Z e j d Z e j j   Z e e d  <RS(   RH   (   RH   (   t   __name__t
   __module__R   t   TYPESt   TYPE_CHECKERt   copyRL   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyRM      s   s   -hs   --helpt   destt   helpt   actions
   Show help.s
   --isolatedt   isolated_modet
   store_truet   defaultsS   Run pip in an isolated mode, ignoring environment variables and user configuration.s   --require-virtualenvs   --require-venvt   require_venvs   -vs	   --verboset   verboset   countsD   Give more output. Option is additive, and can be used up to 3 times.s
   --no-colort   no_colors   Suppress colored outputs   -Vs	   --versiont   versions   Show version and exit.s   -qs   --quiett   quiets   Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).s   --progress-bart   progress_bart   typet   choicet   choicest   ons*   Specify type of progress to be displayed [t   |s   ] (default: %default)s   --logs
   --log-files   --local-logt   logt   metavarRH   s    Path to a verbose appending log.s
   --no-inputt   no_inputs   --proxyt   proxyt   strt    s<   Specify a proxy in the form [user:passwd@]proxy.server:port.s	   --retriest   retriest   inti   sR   Maximum number of retries each connection should attempt (default %default times).s	   --timeouts   --default-timeoutt   sect   timeoutt   floati   s2   Set the socket timeout (default %default seconds).c           C@  sC   t  d d d d d d d d d	 d
 d g d g  d d d d d d S(   Ns   --exists-actionRS   t   exists_actionR`   Ra   Rb   t   st   it   wt   bt   aRX   RU   t   appendRf   RT   sY   Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyRp     s    s   --certt   certs   Path to alternate CA bundle.s   --client-certt   client_certsk   Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.s   -is   --index-urls
   --pypi-urlt	   index_urlt   URLs   Base URL of the Python Package Index (default %default). This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format.c           C@  s(   t  d d d d d d d d g  d	 d
 S(   Ns   --extra-index-urlRS   t   extra_index_urlsRf   Rz   RU   Rv   RX   RT   sm   Extra URLs of package indexes to use in addition to --index-url. Should follow the same rules as --index-url.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   extra_index_urlH  s    s
   --no-indext   no_indexsA   Ignore package index (only looking at --find-links URLs instead).c           C@  s+   t  d d d d d d d g  d d	 d
 d S(   Ns   -fs   --find-linksRS   t
   find_linksRU   Rv   RX   Rf   t   urlRT   s  If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files. If a local path or file:// URL that's a directory,  then look for archives in the directory listing. Links to VCS project URLs are not supported.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR~   `  s    	c           C@  s(   t  d d d d d d d d g  d	 d
 S(   Ns   --trusted-hostRS   t   trusted_hostsRU   Rv   Rf   t   HOSTNAMERX   RT   s]   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   trusted_hostp  s    c           C@  s+   t  d d d d d d d g  d d	 d
 d S(   Ns   -cs   --constraintRS   t   constraintsRU   Rv   RX   Rf   t   fileRT   s\   Constrain versions using the given constraints file. This option can be used multiple times.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR   }  s    	c           C@  s+   t  d d d d d d d g  d d	 d
 d S(   Ns   -rs   --requirementRS   t   requirementsRU   Rv   RX   Rf   R   RT   sQ   Install from the given requirements file. This option can be used multiple times.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR     s    	c           C@  s+   t  d d d d d d d g  d d	 d
 d S(   Ns   -es
   --editableRS   t	   editablesRU   Rv   RX   Rf   s   path/urlRT   sk   Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.(   R   (    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   editable  s    	c         C@  s,   t  j j |  } t | j |  j |  d  S(   N(   RG   RH   t   abspatht   setattrt   valuesRS   (   R    t   opt_strRK   R   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_src  s    s   --srcs   --sources   --source-dirs   --source-directoryt   src_dirt   dirt   callbacks   Directory to check out editable projects into. The default in a virtualenv is "<venv path>/src". The default for global installs is "<current dir>/src".c         C@  s   t  |  | j  S(   s   Get a format_control object.(   R)   RS   (   R   R    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _get_format_control  s    c         C@  s/   t  | j |   } t j | | j | j  d  S(   N(   R   R   R   t   handle_mutual_excludest	   no_binaryt   only_binary(   R    R   RK   R   t   existing(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_no_binary  s    c         C@  s/   t  | j |   } t j | | j | j  d  S(   N(   R   R   R   R   R   R   (   R    R   RK   R   R   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_only_binary  s    c          C@  sC   t  t   t    }  t d d d d d d t d d d |  d	 d
 S(   Ns   --no-binaryRS   R4   RU   R   R`   Ri   RX   RT   sv  Do not use binary packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either ":all:" to disable all binary packages, ":none:" to empty the set (notice the colons), or one or more package names with commas between them (no colons). Note that some packages are tricky to compile and may fail to install when this option is used on them.(   R   R?   R   R   (   R4   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR     s    c          C@  sC   t  t   t    }  t d d d d d d t d d d |  d	 d
 S(   Ns   --only-binaryRS   R4   RU   R   R`   Ri   RX   RT   sK  Do not use source packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either ":all:" to disable all source packages, ":none:" to empty the set, or one or more package names with commas between them. Packages without binary distributions will fail to install when this option is used on them.(   R   R?   R   R   (   R4   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR     s    s
   --platformR<   s[   Only use wheels compatible with <platform>. Defaults to the platform of the running system.c         C@  s   |  s
 d	 S|  j d  } t |  d k r/ d St |  d k rw | d }  t |   d k rw |  d |  d g } qw n  y t d   | D  } Wn t k
 r d SX| d f S(   s   
    Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.

    :return: A 2-tuple (version_info, error_msg), where `error_msg` is
        non-None if and only if there was a parsing error.
    t   .i   s'   at most three version parts are allowedi   i    c         s@  s   |  ] } t  |  Vq d  S(   N(   Rl   (   t   .0t   part(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pys	   <genexpr>  s    s$   each version part must be an integerN(   NN(    (   (    s'   at most three version parts are allowed(    (   (    s$   each version part must be an integer(   R*   R   t   lent   tuplet
   ValueError(   RK   t   partst   version_info(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _convert_python_version  s    
c         C@  sY   t  |  \ } } | d k	 rI d j | |  } t | d |  d | n  | | j _ d S(   s3   
    Handle a provided --python-version value.
    s(   invalid --python-version value: {!r}: {}R    R!   N(   R   R*   R   R"   R   R;   (   R    R   RK   R   R   t	   error_msgR!   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_python_version  s    s   --python-versionR;   s      The Python interpreter version to use for wheel and "Requires-Python"
    compatibility checks. Defaults to a version derived from the running
    interpreter. The version can be specified using up to three dot-separated
    integers (e.g. "3" for 3.0.0, "3.7" for 3.7.0, or "3.7.3"). A major-minor
    version can also be given as a string without dots (e.g. "37" for 3.7.0).
    s   --implementationR>   s   Only use wheels compatible with Python implementation <implementation>, e.g. 'pp', 'jy', 'cp',  or 'ip'. If not specified, then the current interpreter implementation is used.  Use 'py' to force implementation-agnostic wheels.s   --abiR=   s   Only use wheels compatible with Python abi <abi>, e.g. 'pypy_41'.  If not specified, then the current interpreter abi tag is used.  Generally you will need to specify --implementation, --platform, and --python-version when using this option.c         C@  sD   |  j  t    |  j  t    |  j  t    |  j  t    d  S(   N(   R%   R<   R;   R>   R=   (   t   cmd_opts(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   add_target_python_optionsY  s    c      	   C@  s1   t  d |  j d |  j d |  j d |  j  } | S(   NR<   t   py_version_infoR=   R>   (   R   R<   R;   R=   R>   (   R$   t   target_python(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   make_target_pythona  s    			c        
   C@  s"   t  d d d d d d t d d S(	   Ns   --prefer-binaryRS   t   prefer_binaryRU   RW   RX   RT   s8   Prefer older binary packages over newer source packages.(   R   t   False(    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyR   m  s    s   --cache-dirt	   cache_dirs   Store the cache data in <dir>.c         C@  s_   | d k	 rO y t |  WqO t k
 rK } t | d |  d t |  qO Xn  t | j _ d S(   s   
    Process a value provided for the --no-cache-dir option.

    This is an optparse.Option callback for the --no-cache-dir option.
    R    R!   N(   R*   R   R   R"   Ri   R   R   R   (   R    RJ   RK   R   t   exc(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_no_cache_dir  s    #	s   --no-cache-dirs   Disable the cache.s	   --no-depss   --no-dependenciesR@   s#   Don't install package dependencies.c         C@  s5   | r t  j j |  } n  t | j |  j |  d  S(   N(   RG   RH   R   R   R   RS   (   R    RJ   RK   R   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_build_dir  s    s   -bs   --builds   --build-dirs   --build-directoryt	   build_dirs>  Directory to unpack packages into and build in. Note that an initial build still takes place in a temporary directory. The location of temporary directories can be controlled by setting the TMPDIR environment variable (TEMP on Windows) appropriately. When passed, build directories are not cleaned in case of failures.s   --ignore-requires-pythont   ignore_requires_pythons'   Ignore the Requires-Python information.s   --no-build-isolationt   build_isolationt   store_falses   Disable isolation when building a modern source distribution. Build dependencies specified by PEP 518 must be already installed if this option is used.c         C@  s;   | d k	 r+ d } t | d |  d | n  t | j _ d S(   s   
    Process a value provided for the --no-use-pep517 option.

    This is an optparse.Option callback for the no_use_pep517 option.
    s0  A value was passed for --no-use-pep517,
        probably using either the PIP_NO_USE_PEP517 environment variable
        or the "no-use-pep517" config file option. Use an appropriate value
        of the PIP_USE_PEP517 environment variable or the "use-pep517"
        config file option instead.
        R    R!   N(   R*   R"   R   R   t
   use_pep517(   R    RJ   RK   R   R!   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_no_use_pep517  s    s   --use-pep517R   s^   Use PEP 517 for building source distributions (use --no-use-pep517 to force legacy behaviour).s   --no-use-pep517s   --install-optionR0   Rv   R$   s"  Extra arguments to be supplied to the setup.py install command (use like --install-option="--install-scripts=/usr/local/bin"). Use multiple --install-option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.s   --global-optionR/   sT   Extra global options to be supplied to the setup.py call before the install command.s
   --no-cleans!   Don't clean up build directories.s   --presY   Include pre-release and development versions. By default, pip only finds stable versions.s   --disable-pip-version-checkt   disable_pip_version_checks{   Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.s   -Zs   --always-unzipt   always_unzipc         C@  s   | j  j s i  | j  _ n  y | j d d  \ } } Wn' t k
 r` | j d j |   n X| t k r | j d j | d j t    n  | j  j j | g   j	 |  d S(   sk   Given a value spelled "algo:digest", append the digest to a list
    pointed to in a dict by the algo name.t   :i   sT   Arguments to {} must be a hash name followed by a value, like --hash=sha256:abcde...s&   Allowed hash algorithms for {} are {}.s   , N(
   R   t   hashesR   R   R   R   R   R   t
   setdefaultRv   (   R    R   RK   R   t   algot   digest(    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   _handle_merge_hashE  s    s   --hashR   t   stringsg   Verify that the package's archive matches this hash before installing. Example: --hash=sha256:abcdef...s   --require-hashest   require_hashess   Require a hash to check each requirement against, for repeatable installs. This option is implied when any package in a requirements file has a --hash option.s   --paths^   Restrict to the specified installation path for listing packages (can be used multiple times).c         C@  s.   |  j  r* |  j s |  j r* t d   n  d  S(   Ns2   Cannot combine '--path' with '--user' or '--local'(   RH   t   usert   localR   (   R$   (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   check_list_path_option|  s    s   --no-python-version-warningt   no_python_version_warnings>   Silence deprecation warnings for upcoming unsupported Pythons.s   --unstable-featuret   unstable_featurest   featuret   resolvers   General OptionsR#   s   Package Index Options(}   t   __doc__t
   __future__R    t   loggingRG   R   R6   t   distutils.utilR   t	   functoolsR   t   optparseR   R   R   R   t   pip._internal.cli.progress_barsR   t   pip._internal.exceptionsR   t   pip._internal.locationsR	   R
   t#   pip._internal.models.format_controlR   t   pip._internal.models.indexR   t"   pip._internal.models.target_pythonR   t   pip._internal.utils.hashesR   t   pip._internal.utils.typingR   t   typingR   R   R   R   R   R   R   t   pip._internal.cli.parserR   t	   getLoggerRN   t   loggerR"   R(   R*   R:   R   RF   RL   RM   t   help_RV   t   require_virtualenvRZ   R\   R]   R^   t   listt   keysR   R_   Re   Rg   Rh   Rk   Rn   Rp   Rw   Rx   t
   simple_urlRy   R|   R}   R~   R   R   R   R   R   t   srcR   R   R   R   R   R<   R   R   R;   R>   R=   R   R   R   R   R   t   no_cachet   no_depsR   R   R   t   Truet   no_build_isolationR   R   t   no_use_pep517R0   R/   t   no_cleant   preR   R   R   t   hashR   t	   list_pathR   R   t   unstable_featuret   general_groupt   index_group(    (    (    s-   site-packages/pip/_internal/cli/cmdoptions.pyt   <module>   s  (		(	
												 																																																															