a
    {"k™i  ã                   @   s"  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œZe�r
ddddddœed< ddd d!ddœed"< dZG d#d$„ d$eƒZdS )%é    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_namez$base/Scriptsz$base)ÚpurelibÚplatlibÚheadersÚscriptsÚdataz/$base/lib/python$py_version_short/site-packagesz;$platbase/$platlibdir/python$py_version_short/site-packagesz9$base/include/python$py_version_short$abiflags/$dist_namez	$base/binz$base/lib/pythonz$base/$platlibdir/pythonz$base/include/python/$dist_name)Úunix_prefixÚ	unix_homeÚntz	$usersitez4$userbase/Python$py_version_nodot/Include/$dist_namez)$userbase/Python$py_version_nodot/Scriptsz	$userbaseZnt_userz=$userbase/include/python$py_version_short$abiflags/$dist_namez$userbase/binÚ	unix_userc                   @   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	e
e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 d3d4„ Z!d5efd6efd7e fd8e!fd9d:d;„ 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   r   ÚuserNz!install in user site-package '%s'r   r   Ú_prefix_additionÚ 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 )Nr   é   )ÚprefixÚexec_prefixÚhomer    Ú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©Úself© r<   ú1/usr/lib64/python3.9/distutils/command/install.pyÚinitialize_options•   s2    zinstall.initialize_optionsc                 C   sz  | j s| js| jr&| js| jr&tdƒ‚| jr@| j s8| jr@tdƒ‚| jrl| j sd| jsd| jsd| jsd| jrltdƒ‚tjdkrŒ| jrŒ|  	d¡ d | _|  
d¡ tjdkrª|  ¡  n|  ¡  |  
d¡ tj ¡ d }td	d
ƒ\}}z
tj}W n tyø   d}Y n0 | j ¡ | j ¡ | j ¡ |dtjd d…  dtjd d…  |||||tjdœ| _t�rh| j| jd< | j| jd< |  ¡  |  
d¡ | j| jd< | j| jd< t�r¶ddlm} t dƒ || jƒ |  !¡  |  
d¡ | j�rØ|  "¡  | j#d u �r | jj$�rø| j%| _#n| j&| _#|  'dddddddd¡ |  (¡  | j#| _)tj* +| j#| j,¡| _#| j-d u�r^|  .ddddddd¡ |  
d¡ |  /d d!d"¡ d S )#NzWmust 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 platformzpre-finalize_{unix,other}zpost-finalize_{unix,other}()r   r$   r%   r"   z%d.%dé   z%d%d)Z	dist_nameZdist_versionZdist_fullnameÚ
py_versionZpy_version_shortZpy_version_nodotZ
sys_prefixr$   Zsys_exec_prefixr%   ÚabiflagsÚ
platlibdirÚuserbaseZusersitezpost-expand_basedirs()ÚbaseZplatbase)Úpprintzconfig vars:zpost-expand_dirs()Úlibr   r   r   r   r   Zlibbasezafter prepending rootÚbuild)r7   r7   )r8   r8   )0r$   r%   r&   r'   r(   r   r    ÚosÚnameÚwarnÚ	dump_dirsÚfinalize_unixÚfinalize_otherÚsysÚversionÚsplitr   rB   ÚAttributeErrorÚdistributionÚget_nameZget_versionZget_fullnameÚversion_inforC   Úconfig_varsÚHAS_USER_SITEr0   r1   Úexpand_basedirsr   rF   ÚprintÚexpand_dirsÚcreate_home_pathr-   Zext_modulesr+   r*   Úconvert_pathsÚhandle_extra_pathÚinstall_libbaseÚpathÚjoinÚ
extra_dirsr)   Úchange_rootsZset_undefined_options)r;   rA   r$   r%   rB   rF   r<   r<   r=   Úfinalize_optionsã   s¢    ÿÿÿÿÿÿ








õ





þ	ÿ
þzinstall.finalize_optionsc                 C   s    t sd S ddlm} t |d ¡ | jD ]r}|d }|d dkrL|dd… }|| jv rx| j| }| |¡}t| |ƒ }n| |¡}t| |ƒ}t d||¡ q(d S )Nr   )Úlongopt_xlateú:éÿÿÿÿú=z  %s: %s)	r   Zdistutils.fancy_getoptrd   r   ÚdebugÚuser_optionsÚnegative_optÚ	translateÚgetattr)r;   Úmsgrd   ÚoptZopt_nameÚvalr<   r<   r=   rL   y  s    





zinstall.dump_dirsc                 C   s.  | j d us| jd ur\| jd u r2| jd u r2| jd u sP| jd u sP| jd u sP| jd u rXtdƒ‚d S | j	rŽ| j
d u rttdƒ‚| j
 | _ | _|  d¡ nœ| jd ur²| j | _ | _|  d¡ nx| jd u rü| jd urÎtdƒ‚tj tj¡| j | _tj tj¡| j | _n| jd u �r| j| _| j| _ | j| _|  d¡ d S )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 prefixr   )r'   r(   r-   r*   r+   r,   r.   r/   r   r    r0   r   Úselect_schemer&   r$   r%   rI   r_   ÚnormpathrO   r!   r:   r<   r<   r=   rM   Œ  sP    
ÿþýüûÿ
ÿ


ÿÿÿzinstall.finalize_unixc                 C   sº   | j r8| jd u rtdƒ‚| j | _| _|  tjd ¡ n~| jd ur\| j | _| _|  d¡ nZ| j	d u rvtj
 tj	¡| _	| j	 | _| _z|  tj¡ W n  ty´   tdtj ƒ‚Y n0 d S )Nrp   Ú_userr   z)I don't know how to install stuff on '%s')r    r0   r   r'   r(   rq   rI   rJ   r&   r$   r_   rr   rO   ÚKeyErrorr:   r<   r<   r=   rN   ¶  s&    
ÿ

ÿzinstall.finalize_otherc                 C   s<   t | }tD ]*}d| }t| |ƒd u rt| ||| ƒ qd S ©NZinstall_)ÚINSTALL_SCHEMESÚSCHEME_KEYSrl   Úsetattr)r;   rJ   ÚschemeÚkeyÚattrnamer<   r<   r=   rq   Ì  s
    zinstall.select_schemec                 C   sX   |D ]N}t | |ƒ}|d urtjdks.tjdkr:tj |¡}t|| jƒ}t| ||ƒ qd S )Nr?   r   )rl   rI   rJ   r_   Ú
expanduserr	   rV   rx   )r;   ÚattrsÚattrro   r<   r<   r=   Ú_expand_attrsÕ  s    
zinstall._expand_attrsc                 C   s   |   g d¢¡ d S )N)r'   r(   r)   ©r   r:   r<   r<   r=   rX   Þ  s    zinstall.expand_basedirsc                 C   s   |   g d¢¡ d S )N)r*   r+   r-   r,   r.   r/   r€   r:   r<   r<   r=   rZ   ã  s    zinstall.expand_dirsc                 G   s,   |D ]"}d| }t | |tt| |ƒƒƒ qd S ru   )rx   r   rl   ©r;   ÚnamesrJ   r~   r<   r<   r=   r\   é  s    zinstall.convert_pathsc                 C   s¤   | j d u r| jj | _ | j d urŒt d¡ t| j tƒrB| j  d¡| _ t| j ƒdkr`| j d  }}n"t| j ƒdkrz| j \}}ntdƒ‚t	|ƒ}nd }d}|| _
|| _d S )NzIDistribution option extra_path is deprecated. See issue27919 for details.ú,r#   r   r@   zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr"   )r3   rS   r   rK   Ú
isinstanceÚstrrQ   Úlenr   r   Ú	path_filera   )r;   r‡   ra   r<   r<   r=   r]   ï  s(    


ÿÿ
zinstall.handle_extra_pathc              	   G   s0   |D ]&}d| }t | |t| jt| |ƒƒƒ qd S ru   )rx   r
   r)   rl   r�   r<   r<   r=   rb     s    zinstall.change_rootsc                 C   sb   | j s
d S ttj d¡ƒ}| j ¡ D ]8\}}| |¡r$tj |¡s$|  	d| ¡ t 
|d¡ q$d S )Nú~zos.makedirs('%s', 0o700)iÀ  )r    r   rI   r_   r|   rV   ÚitemsÚ
startswithÚisdirZdebug_printÚmakedirs)r;   r&   rJ   r_   r<   r<   r=   r[     s    zinstall.create_home_pathc                 C   s"  | j s6|  d¡ | j d¡j}| jr6|tƒ kr6tdƒ‚|  ¡ D ]}|  |¡ q>| j	r\|  
¡  | jrº|  ¡ }| jr t| jƒ}tt|ƒƒD ]}|| |d … ||< q†|  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 )NrH   z"Can't install when cross-compilingz'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)r5   Zrun_commandrS   Zget_command_objZ	plat_namer6   r   r   Úget_sub_commandsr‡   Úcreate_path_filer9   Úget_outputsr)   r†   ÚrangeÚexecuter   ÚmaprI   r_   rr   rO   Únormcaser-   r4   r   rh   )r;   Z
build_platÚcmd_nameÚoutputsZroot_lenZcounterZsys_pathr-   r<   r<   r=   Úrun#  sD    

ÿþÿÿþýzinstall.runc                 C   sJ   t j | j| jd ¡}| jr8|  t|| jgfd| ¡ n|  	d| ¡ d S )Nú.pthzcreating %szpath file '%s' not created)
rI   r_   r`   r^   r‡   r4   r‘   r   ra   rK   )r;   Úfilenamer<   r<   r=   rŽ   O  s    
ÿ
þzinstall.create_path_filec                 C   sh   g }|   ¡ D ].}|  |¡}| ¡ D ]}||vr"| |¡ q"q| jrd| jrd| tj | j	| jd ¡¡ |S )Nr—   )
r�   Úget_finalized_commandr�   Úappendr‡   r4   rI   r_   r`   r^   )r;   r•   r”   Úcmdr˜   r<   r<   r=   r�   ]  s    
ÿzinstall.get_outputsc                 C   s.   g }|   ¡ D ]}|  |¡}| | ¡ ¡ q|S ©N)r�   r™   ÚextendÚ
get_inputs)r;   Zinputsr”   r›   r<   r<   r=   rž   n  s
    
zinstall.get_inputsc                 C   s   | j  ¡ p| j  ¡ S rœ   )rS   Zhas_pure_modulesZhas_ext_modulesr:   r<   r<   r=   Úhas_libz  s    
ÿzinstall.has_libc                 C   s
   | j  ¡ S rœ   )rS   Úhas_headersr:   r<   r<   r=   r    €  s    zinstall.has_headersc                 C   s
   | j  ¡ S rœ   )rS   Úhas_scriptsr:   r<   r<   r=   r¡   …  s    zinstall.has_scriptsc                 C   s
   | j  ¡ S rœ   )rS   Zhas_data_filesr:   r<   r<   r=   Úhas_dataŠ  s    zinstall.has_datar-   r,   r.   r/   Zinstall_egg_infoc                 C   s   dS )NTr<   r:   r<   r<   r=   Ú<lambda>•  ó    zinstall.<lambda>)#Ú__name__Ú
__module__Ú__qualname__Údescriptionri   Zboolean_optionsrW   rš   r   rj   rl   Ú	sysconfigr!   r>   rc   rL   rM   rN   rq   r   rX   rZ   r\   r]   rb   r[   r–   rŽ   r�   rž   rŸ   r    r¡   r¢   Zsub_commandsr<   r<   r<   r=   r   J   sL   ;ÿ
N *		",
ür   )rO   r©   rI   Z	distutilsr   Zdistutils.corer   Zdistutils.debugr   Zdistutils.sysconfigr   Zdistutils.errorsr   Zdistutils.file_utilr   Zdistutils.utilr   r	   r
   r   r   Zsiter   r   rW   ZWINDOWS_SCHEMErv   rw   r   r<   r<   r<   r=   Ú<module>   sb   û
ûûñû
	ú
