o
    g}”eºu  ã                
   @   s   d 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mZ dd
lmZ ddlmZ ddlmZ ddlmZ dZddddddœZddddddœddddddœeddddddœddddddœdœZerœdddd d!dœed"< ddd#d$d!dœed%< dZd&d'„ Zd(d)„ Z d*d+„ Z!d,d-„ Z"d.d/„ Z#d0d1„ Z$d2d3„ Z%d4d5„ Z&d6d7„ Z'd8d9„ Z(G d:d;„ d;e	ƒZ)dS )<zFdistutils.command.install

Implements the Distutils 'install' command.é    N)Úlog)ÚCommand)ÚDEBUG)Úget_config_vars)ÚDistutilsPlatformError)Ú
write_file)Úconvert_pathÚ
subst_varsÚchange_root)Úget_platform)ÚDistutilsOptionError)Ú	USER_BASE)Ú	USER_SITETz{base}/Lib/site-packagesz{base}/Include/{dist_name}z{base}/Scriptsz{base})ÚpurelibÚplatlibÚheadersÚscriptsÚdatazA{base}/lib/{implementation_lower}{py_version_short}/site-packageszN{platbase}/{platlibdir}/{implementation_lower}{py_version_short}/site-packageszM{base}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z
{base}/binz!{base}/lib/{implementation_lower}z*{base}/{platlibdir}/{implementation_lower}z1{base}/include/{implementation_lower}/{dist_name}z{base}/site-packagesz{base}/include/{dist_name})Úposix_prefixÚ
posix_homeÚntÚpypyZpypy_ntz
{usersite}zA{userbase}/{implementation}{py_version_nodot}/Include/{dist_name}z5{userbase}/{implementation}{py_version_nodot}/Scriptsz
{userbase}Únt_userzQ{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z{userbase}/binÚ
posix_userc                   C   s@   t  t¡� dd„ t ¡ D ƒW  d   ƒ S 1 sw   Y  d S )Nc                 S   s   i | ]
}|t j|d d�“qS )F)Úexpand)Ú	sysconfigÚ	get_paths©Ú.0Úscheme© r    ún/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/setuptools/_distutils/command/install.pyÚ
<dictcomp>\   ó    ÿÿz+_load_sysconfig_schemes.<locals>.<dictcomp>)Ú
contextlibÚsuppressÚAttributeErrorr   Úget_scheme_namesr    r    r    r!   Ú_load_sysconfig_schemesZ   s
   þ$ÿr(   c                      s(   t ƒ pi ‰ ‡ fdd„tt tˆ ¡ƒD ƒS )z=
    Extend default schemes with schemes from sysconfig.
    c                    s*   i | ]}|i t  |i ¡¥ˆ  |i ¡¥“qS r    )ÚINSTALL_SCHEMESÚgetr   ©Zsysconfig_schemesr    r!   r"   i   s    ü
ÿ
þÿz!_load_schemes.<locals>.<dictcomp>)r(   ÚsetÚ	itertoolsÚchainr)   r    r    r+   r!   Ú_load_schemesb   s   

ûr/   c                   C   s   t tdƒrdS dS )NÚpypy_version_infoÚPyPyÚPython)ÚhasattrÚsysr    r    r    r!   Ú_get_implementationr   s   
r5   c                 C   s.   t |tt|ƒƒƒ}t| ƒ t| t|ƒƒ¡ d S ©N)Ú_inject_headersÚ_load_schemeÚ_resolve_schemeÚvarsÚupdateÚ_remove_setÚ_scheme_attrs)ÚobÚnamer   r    r    r!   Ú_select_schemey   s   r@   c                    s   ‡ fdd„|  ¡ D ƒS )z1
    Include only attrs that are None in ob.
    c                    s$   i | ]\}}t ˆ |ƒd u r||“qS r6   )Úgetattr)r   ÚkeyÚvalue©r>   r    r!   r"   ‚   s    ýÿz_remove_set.<locals>.<dictcomp>)Úitems)r>   Úattrsr    rD   r!   r<   ~   s   
þr<   c                 C   s>   |   d¡\}}}zt |¡}W |S  ty   t| ƒ}Y |S w )NÚ_)Ú	partitionr   Úget_preferred_schemeÚ	ExceptionÚ
_pypy_hack)r?   Úos_nameÚseprB   Zresolvedr    r    r!   r9   ‰   s   þ
þr9   c                 C   s
   t ƒ |  S r6   )r/   )r?   r    r    r!   r8   ’   s   
r8   c                 C   s    t t| ƒƒ}| d|d ¡ |S )z¾
    Given a scheme name and the resolved scheme,
    if the scheme does not include headers, resolve
    the fallback scheme for the name and use headers
    from it. pypa/distutils#88
    r   )r8   rK   Ú
setdefault)r?   r   Úfallbackr    r    r!   r7   –   s   	r7   c                    s   ‡ fdd„t D ƒS )z<Resolve install directories by applying the install schemes.c                    s   i | ]
}d |› �ˆ | “qS )Úinstall_r    )r   rB   ©r   r    r!   r"   ¦   r#   z!_scheme_attrs.<locals>.<dictcomp>)ÚSCHEME_KEYSrQ   r    rQ   r!   r=   ¤   s   
þr=   c                 C   sF   t jdk }tt dƒo|}|  d¡ }ddtjdk  }|r!|r!|S | S )N)é   é   r0   )Ú_userÚ_homer   Z_ntr   )r4   Úversion_infor3   ÚendswithÚosr?   )r?   ZPY37Zold_pypyÚprefixZ	pypy_namer    r    r!   rK   ¬   s
   
rK   c                   @   s  e Zd ZdZg d¢Zg d¢Zere ddde f¡ e d¡ ddiZ	d	d
„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3efd4efd5efd6efd7d8d9„ fgZdS ):Úinstallz'install everything from build directory))zprefix=Nzinstallation prefix)zexec-prefix=Nz.(Unix only) prefix for platform-specific files)zhome=Nz+(Unix only) home directory to install under)zinstall-base=Nz;base installation directory (instead of --prefix or --home))zinstall-platbase=Nz\base installation directory for platform-specific files (instead of --exec-prefix or --home))zroot=Nz<install everything relative to this alternate root directory)zinstall-purelib=Nz;installation directory for pure Python module distributions)zinstall-platlib=Nz8installation directory for non-pure module distributions)zinstall-lib=Nzginstallation directory for all module distributions (overrides --install-purelib and --install-platlib))zinstall-headers=Nz(installation directory for C/C++ headers)zinstall-scripts=Nz)installation directory for Python scripts)zinstall-data=Nz%installation directory for data files)ÚcompileÚczcompile .py to .pyc [default])ú
no-compileNzdon't compile .py files)z	optimize=ÚOzlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])ÚforceÚfz1force installation (overwrite any existing files))ú
skip-buildNz2skip rebuilding everything (for testing/debugging))zrecord=Nz3filename in which to record list of installed files)r\   r`   rb   ÚuserNz!install in user site-package '%s'r^   r\   c                 C   sš   d| _ d| _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _t| _t| _d| _d| _d| _d| _d| _d| _d| _d| _d| _d| _dS )zInitializes options.Nr   é   )rZ   Úexec_prefixÚhomerc   Úinstall_baseÚinstall_platbaseÚrootÚinstall_purelibÚinstall_platlibÚinstall_headersÚinstall_libÚinstall_scriptsÚinstall_datar   Úinstall_userbaser   Úinstall_usersiter\   ÚoptimizeÚ
extra_pathÚinstall_path_filer`   Ú
skip_buildÚwarn_dirÚ
build_baseÚ	build_libÚrecord©Úselfr    r    r!   Úinitialize_optionsý   s2   
zinstall.initialize_optionsc                 C   s¢  | j s	| js	| jr| js| jrtdƒ‚| jr | j s| jr tdƒ‚| jr6| j s2| js2| js2| js2| jr6tdƒ‚tjdkrF| jrF|  	d¡ d| _|  
d¡ tjdkrU|  ¡  n|  ¡  |  
d¡ tj ¡ d	 }td
dƒ\}}ztj}W n ty|   d}Y nw | j ¡ | j ¡ | j ¡ |dtjdd…  dtjdd…  |||||ttddƒtƒ  ¡ tƒ t d¡dœ| _trÀ| j| jd< | j | jd< |  !¡  |  
d¡ | j| jd< | j| jd< t ¡ d | jd< t"rïd	dl#m#} t$dƒ || jƒ |  %¡  |  
d¡ | jrÿ|  &¡  | j'du �r| j (¡ �r| j)| _'n| j*| _'|  +ddddd d!dd¡ |  ,¡  | j'| _-tj. /| j'| j0¡| _'| j1du�rC|  2d"ddddd d!¡ |  
d#¡ |  3d$d%d&¡ dS )'zFinalizes options.zWmust supply either prefix/exec-prefix/home or install-base/install-platbase -- not bothz9must supply either home or prefix/exec-prefix -- not bothzGcan't combine user with prefix, exec_prefix/home, or install_(plat)baseÚposixz+exec-prefix option ignored on this platformNzpre-finalize_{unix,other}zpost-finalize_{unix,other}()r   rZ   re   Ú z%d.%dé   z%d%dÚ
platlibdirÚlibÚ
platsubdir)Z	dist_nameZdist_versionZdist_fullnameÚ
py_versionÚpy_version_shortÚpy_version_nodotZ
sys_prefixrZ   Zsys_exec_prefixre   Úabiflagsr€   Zimplementation_lowerÚimplementationr‚   ÚuserbaseZusersitezpost-expand_basedirs()ÚbaseÚplatbaseÚinstalled_base)Úpprintzconfig vars:zpost-expand_dirs()r   r   r   r   r   Zlibbasezafter prepending rootÚbuild)rw   rw   )rx   rx   )4rZ   re   rf   rg   rh   r   rc   rY   r?   ÚwarnÚ	dump_dirsÚfinalize_unixÚfinalize_otherr4   ÚversionÚsplitr   r†   r&   ÚdistributionÚget_nameÚget_versionÚget_fullnamerW   rA   r5   Úlowerr   Úget_config_varÚconfig_varsÚHAS_USER_SITErp   rq   Úexpand_basedirsr   rŒ   ÚprintÚexpand_dirsÚcreate_home_pathrm   Úhas_ext_modulesrk   rj   Úconvert_pathsÚhandle_extra_pathÚinstall_libbaseÚpathÚjoinÚ
extra_dirsri   Úchange_rootsÚset_undefined_options)r{   rƒ   rZ   re   r†   rŒ   r    r    r!   Úfinalize_optionsK  s®   ÿÿÿÿÿÿ







þ
ò

ÿ



þ	ÿ
þzinstall.finalize_optionsc                 C   s    t sdS ddlm} t |d ¡ | jD ]9}|d }|d dkr&|dd… }|| jv r<| j| }| |¡}t| |ƒ }n
| |¡}t| |ƒ}t d||¡ qdS )zDumps the list of user options.Nr   )Úlongopt_xlateú:éÿÿÿÿú=z  %s: %s)	r   Údistutils.fancy_getoptrª   r   ÚdebugÚuser_optionsÚnegative_optÚ	translaterA   )r{   Úmsgrª   ÚoptZopt_nameÚvalr    r    r!   r�   æ  s    





õzinstall.dump_dirsc                 C   s<  | j dus
| jdur0| jdu o| jdu o| jdu p'| jdu p'| jdu p'| jdu }|r.tdƒ‚dS | j	rJ| j
du r<tdƒ‚| j
 | _ | _|  d¡ dS | jdur]| j | _ | _|  d¡ dS | jdu r†| jdurktdƒ‚ttddƒ}tj tj¡| | _tj tj¡| | _n	| jdu r�| j| _| j| _ | j| _|  d	¡ dS )
z&Finalizes options for posix platforms.NzPinstall-base or install-platbase supplied, but installation scheme is incompleteú$User base directory is not specifiedr   r   z*must not supply exec-prefix without prefixÚ_prefix_additionr~   r   )rg   rh   rm   rj   rk   rl   rn   ro   r   rc   rp   r   Úselect_schemerf   rZ   re   rA   r   rY   r¤   Únormpathr4   )r{   Zincomplete_schemer·   r    r    r!   r�   ù  sT   
ÿýûúø
ÿ
ÿ


ÿÿÿ
zinstall.finalize_unixc                 C   s¸   | j r| jdu rtdƒ‚| j | _| _|  tjd ¡ dS | jdur0| j | _| _|  d¡ dS | j	du r=tj
 tj	¡| _	| j	 | _| _z	|  tj¡ W dS  ty[   tdtj ƒ‚w )z)Finalizes options for non-posix platformsNr¶   rU   r   z)I don't know how to install stuff on '%s')rc   rp   r   rg   rh   r¸   rY   r?   rf   rZ   r¤   r¹   r4   ÚKeyErrorrz   r    r    r!   r‘   +  s(   
ÿ

ÿÿzinstall.finalize_otherc                 C   s   t | |ƒ d S r6   )r@   )r{   r?   r    r    r!   r¸   A  s   zinstall.select_schemec                 C   sX   |D ]'}t | |ƒ}|d ur)tjdkstjdkrtj |¡}t|| jƒ}t| ||ƒ qd S )Nr}   r   )rA   rY   r?   r¤   Ú
expanduserr	   rš   Úsetattr)r{   rF   Úattrrµ   r    r    r!   Ú_expand_attrsD  s   
€úzinstall._expand_attrsc                 C   ó   |   g d¢¡ dS )zNCalls `os.path.expanduser` on install_base, install_platbase and
        root.)rg   rh   ri   N©r¾   rz   r    r    r!   rœ   M  s   zinstall.expand_basedirsc                 C   r¿   )z+Calls `os.path.expanduser` on install dirs.)rj   rk   rm   rl   rn   ro   NrÀ   rz   r    r    r!   rž   R  s   zinstall.expand_dirsc                 G   s,   |D ]}d| }t | |tt| |ƒƒƒ qdS )z!Call `convert_path` over `names`.rP   N)r¼   r   rA   ©r{   Únamesr?   r½   r    r    r!   r¡   X  s   þzinstall.convert_pathsc                 C   s¤   | j du r
| jj | _ | j durFt d¡ t| j tƒr!| j  d¡| _ t| j ƒdkr0| j d  }}nt| j ƒdkr=| j \}}ntdƒ‚t	|ƒ}nd}d}|| _
|| _dS )	z4Set `path_file` and `extra_dirs` using `extra_path`.NzIDistribution option extra_path is deprecated. See issue27919 for details.ú,rd   r   r   zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr~   )rs   r”   r   rŽ   Ú
isinstanceÚstrr“   Úlenr   r   Ú	path_filer¦   )r{   rÇ   r¦   r    r    r!   r¢   ^  s(   


ÿÿ

zinstall.handle_extra_pathc              	   G   s0   |D ]}d| }t | |t| jt| |ƒƒƒ qdS )z:Change the install directories pointed by name using root.rP   N)r¼   r
   ri   rA   rÁ   r    r    r!   r§   €  s   þzinstall.change_rootsc                 C   sf   | j sdS ttj d¡ƒ}| j ¡ D ]\}}t|ƒ |¡r0tj 	|¡s0|  
d| ¡ t |d¡ qdS )zCreate directories under ~.Nú~zos.makedirs('%s', 0o700)iÀ  )rc   r   rY   r¤   r»   rš   rE   rÅ   Ú
startswithÚisdirÚdebug_printÚmakedirs)r{   rf   r?   r¤   r    r    r!   rŸ   †  s   €ýzinstall.create_home_pathc                 C   s&  | j s|  d¡ | j d¡j}| jr|tƒ krtdƒ‚|  ¡ D ]}|  |¡ q| j	r.|  
¡  | jr]|  ¡ }| jrPt| jƒ}tt|ƒƒD ]}|| |d… ||< qC|  t| j|fd| j ¡ ttjjtjƒ}ttjj|ƒ}tj tj | j¡¡}| jr�| j	r€| js‘||vr�t d| j¡ dS dS dS dS )zRuns the command.r�   z"Can't install when cross-compilingNz'writing list of installed files to '%s'zƒmodules installed to '%s', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself)ru   Úrun_commandr”   Úget_command_objÚ	plat_namerv   r   r   Úget_sub_commandsrÇ   Úcreate_path_filery   Úget_outputsri   rÆ   ÚrangeÚexecuter   ÚmaprY   r¤   r¹   r4   Únormcaserm   rt   r   r¯   )r{   Z
build_platÚcmd_nameÚoutputsZroot_lenÚcounterÚsys_pathrm   r    r    r!   Úrun’  sF   

ÿþÿÿþýýzinstall.runc                 C   sL   t j | j| jd ¡}| jr|  t|| jgfd| ¡ dS |  	d| ¡ dS )zCreates the .pth fileú.pthzcreating %szpath file '%s' not createdN)
rY   r¤   r¥   r£   rÇ   rt   rÔ   r   r¦   rŽ   )r{   Úfilenamer    r    r!   rÑ   ¾  s   
ÿ
þzinstall.create_path_filec                 C   sh   g }|   ¡ D ]}|  |¡}| ¡ D ]}||vr| |¡ qq| jr2| jr2| tj | j	| jd ¡¡ |S )z.Assembles the outputs of all the sub-commands.rÜ   )
rÐ   Úget_finalized_commandrÒ   ÚappendrÇ   rt   rY   r¤   r¥   r£   )r{   rØ   r×   ÚcmdrÝ   r    r    r!   rÒ   Ì  s   

€þÿzinstall.get_outputsc                 C   s.   g }|   ¡ D ]}|  |¡}| | ¡ ¡ q|S )z*Returns the inputs of all the sub-commands)rÐ   rÞ   ÚextendÚ
get_inputs)r{   Zinputsr×   rà   r    r    r!   râ   Ý  s
   
zinstall.get_inputsc                 C   s   | j  ¡ p	| j  ¡ S )zSReturns true if the current distribution has any Python
        modules to install.)r”   Úhas_pure_modulesr    rz   r    r    r!   Úhas_libé  s   
ÿzinstall.has_libc                 C   ó
   | j  ¡ S )zLReturns true if the current distribution has any headers to
        install.)r”   Úhas_headersrz   r    r    r!   ræ   ï  ó   
zinstall.has_headersc                 C   rå   )zMReturns true if the current distribution has any scripts to.
        install.)r”   Úhas_scriptsrz   r    r    r!   rè   ô  rç   zinstall.has_scriptsc                 C   rå   )zJReturns true if the current distribution has any data to.
        install.)r”   Úhas_data_filesrz   r    r    r!   Úhas_dataù  rç   zinstall.has_datarm   rl   rn   ro   Úinstall_egg_infoc                 C   s   dS )NTr    rz   r    r    r!   Ú<lambda>  s    zinstall.<lambda>) Ú__name__Ú
__module__Ú__qualname__Údescriptionr°   Úboolean_optionsr›   rß   r   r±   r|   r©   r�   r�   r‘   r¸   r¾   rœ   rž   r¡   r¢   r§   rŸ   rÛ   rÑ   rÒ   râ   rä   ræ   rè   rê   Úsub_commandsr    r    r    r!   r[   ´   sL    ;ÿ
N 2	",
ür[   )*Ú__doc__r4   rY   r$   r   r-   Ú	distutilsr   Údistutils.corer   Údistutils.debugr   Údistutils.sysconfigr   Údistutils.errorsr   Údistutils.file_utilr   Údistutils.utilr   r	   r
   r   r   Úsiter   r   r›   ZWINDOWS_SCHEMEr)   rR   r(   r/   r5   r@   r<   r9   r8   r7   r=   rK   r[   r    r    r    r!   Ú<module>   s–    û
ûûûûé!
û	
ú	