
0c@_L  ã               @   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 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 e rd d l m Z m Z m Z m Z d d l m  Z! e j" d ƒ Z# d d „  Z$ d d „  Z% e j& d ƒ Z' e j( ƒ  j) ƒ  d k rve
 j* ƒ  Z' y e j+ ƒ  Z, Wn e- k
 r£e j. Z, Yn Xe re j/ j0 e j1 d ƒ Z2 e j/ j0 e, d ƒ Z3 e j/ j4 e2 ƒ s~e j/ j0 e j1 d ƒ Z2 e j/ j0 e, d ƒ Z3 ne e j/ j0 e j1 d ƒ Z2 e j/ j0 e, d ƒ Z3 e j d d … d k r~e j1 d d … d k r~d Z2 d d d d d d d „ Z5 d d d d d d d  „ Z6 d S)!z7Locations where we look for configs, install stuff, etcé    )Úabsolute_importN)Ú	sysconfig)ÚSCHEME_KEYS)Úinstall)ÚScheme)Úappdirs)ÚWINDOWS)ÚMYPY_CHECK_RUNNINGÚcast)Úrunning_under_virtualenv)ÚDictÚListÚOptionalÚUnion)ÚCommandÚpipc               C   s   d j  t j Œ  S)ze
    Return the major-minor version of the current Python as a string, e.g.
    "3.7" or "3.10".
    z{}.{})ÚformatÚsysÚversion_info© r   r   ú6/tmp/pip-build-jynh7p1z/pip/pip/_internal/locations.pyÚget_major_minor_version"   s    r   c              C   su   t  ƒ  r$ t j j t j d ƒ }  nA y t j j t j ƒ  d ƒ }  Wn t k
 rd t j d ƒ Yn Xt j j	 |  ƒ S)NÚsrcz=The folder you are executing pip from can no longer be found.)
r   ÚosÚpathÚjoinr   ÚprefixÚgetcwdÚOSErrorÚexitÚabspath)Ú
src_prefixr   r   r   Úget_src_prefix+   s    	r"   ÚpurelibZpypyÚScriptsÚbiné   Údarwiné   z/System/Library/z/usr/local/binFc             C   s*  d d l  m } d |  i } | r/ d g | d <| | ƒ } | j ƒ  d }	 | j d d d	 ƒ}	 |	 d k	 sr t ‚ t t |	 ƒ }
 | oŠ | s¦ t d
 j | | ƒ ƒ ‚ | o¯ | sË t d j | | ƒ ƒ ‚ | p× |
 j |
 _ | sé | rò d |
 _	 | pþ |
 j	 |
 _	 | p|
 j
 |
 _
 | p"|
 j |
 _ |
 j ƒ  i  } x% t D] } t |
 d | ƒ | | <q?Wd | j d ƒ k r—| j t d |
 j d |
 j ƒ ƒ t ƒ  r&t j j |
 j	 d d d j t ƒ  ƒ |  ƒ | d <| d k	 r&t j j t j j | d ƒ ƒ d } t j j | | d d … ƒ | d <| S)z+
    Return a distutils install scheme
    r   )ÚDistributionÚnamez--no-user-cfgÚscript_argsNr   ÚcreateTzuser={} prefix={}zhome={} prefix={}Ú Úinstall_Úinstall_libr#   ÚplatlibÚincludeÚsitezpython{}Úheadersé   )Údistutils.distr)   Úparse_config_filesÚget_command_objÚAssertionErrorr
   Údistutils_install_commandr   Úuserr   ÚhomeÚrootÚfinalize_optionsr   ÚgetattrÚget_option_dictÚupdateÚdictr/   r   r   r   r   r   Ú
splitdriver    )Ú	dist_namer:   r;   r<   Úisolatedr   r)   Ú	dist_argsÚdÚobjÚiÚschemeÚkeyÚpath_no_driver   r   r   Údistutils_scheme_   sL    
%%	
"				rL   c             C   sT   t  |  | | | | | ƒ } t d | d d | d d | d d | d d | d ƒ S)a;  
    Get the "scheme" corresponding to the input parameters. The distutils
    documentation provides the context for the available schemes:
    https://docs.python.org/3/install/index.html#alternate-installation

    :param dist_name: the name of the package to retrieve the scheme for, used
        in the headers scheme path
    :param user: indicates to use the "user" scheme
    :param home: indicates to use the "home" scheme and provides the base
        directory for the same
    :param root: root under which other directories are re-based
    :param isolated: equivalent to --no-user-cfg, i.e. do not consider
        ~/.pydistutils.cfg (posix) or ~/pydistutils.cfg (non-posix) for
        scheme paths
    :param prefix: indicates to use the "prefix" scheme and provides the
        base directory for the same
    r0   r#   r3   ÚscriptsÚdata)rL   r   )rC   r:   r;   r<   rD   r   rI   r   r   r   Ú
get_schemeŸ   s    



rO   )7Ú__doc__Ú
__future__r   r   Úos.pathÚplatformr2   r   r   Ú	distutilsZdistutils_sysconfigÚdistutils.command.installr   r   r9   Zpip._internal.models.schemer   Zpip._internal.utilsr   Zpip._internal.utils.compatr   Zpip._internal.utils.typingr	   r
   Zpip._internal.utils.virtualenvr   Ztypingr   r   r   r   Údistutils.cmdr   ZDistutilsCommandÚuser_cache_dirÚUSER_CACHE_DIRr   r"   Úget_pathÚsite_packagesÚpython_implementationÚlowerÚget_python_libÚgetusersitepackagesÚ	user_siteÚAttributeErrorÚ	USER_SITEr   r   r   Úbin_pyÚbin_userÚexistsrL   rO   r   r   r   r   Ú<module>   sX   "	2A