U
    ÏvagÉ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mZ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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�rJd!d!d"d#d$dœe d%< d!d!d&d'd$dœe d(< e  !ej"¡ dZ#d)d*„ Z$d+d,„ Z%d-d.„ Z&d/d0„ Z'd1d2„ Z(d3d4„ Z)d5d6„ Z*d7d8„ Z+d9d:„ Z,d;d<„ Z-G d=d>„ d>e	ƒZ.dS )?zFdistutils.command.install

Implements the Distutils 'install' command.é    N)Úlogé   )ÚCommand)ÚDEBUG)Úget_config_vars)Ú
write_file)Úconvert_pathÚ
subst_varsÚchange_root)Úget_platform)ÚDistutilsOptionErrorÚDistutilsPlatformErroré   )Ú_framework_compat)Ú_collections)Ú	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}zF{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}z:{userbase}/{implementation}{py_version_nodot_plat}/Scriptsz
{userbase}Únt_userzQ{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z{userbase}/binÚ
posix_userc                
   C   s4   t  t¡�  dd„ t ¡ D ƒW  5 Q R £ S Q R X d S )Nc                 S   s   i | ]}|t j|d d�“qS )F)Úexpand)Ú	sysconfigÚ	get_paths©Ú.0Úscheme© r$   úY/var/www/html/myvenv/lib/python3.8/site-packages/setuptools/_distutils/command/install.pyÚ
<dictcomp>e   s   ÿ z+_load_sysconfig_schemes.<locals>.<dictcomp>)Ú
contextlibÚsuppressÚAttributeErrorr   Úget_scheme_namesr$   r$   r$   r%   Ú_load_sysconfig_schemesc   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 | ]}|t  |i ¡ˆ  |i ¡–“qS r$   )ÚINSTALL_SCHEMESÚgetr!   ©Zsysconfig_schemesr$   r%   r&   r   s
   ü

þz!_load_schemes.<locals>.<dictcomp>)r+   ÚsetÚ	itertoolsÚchainr,   r$   r$   r.   r%   Ú_load_schemesk   s    

ûr2   c                   C   s   t tdƒrdS dS d S )NÚpypy_version_infoÚPyPyÚPython)ÚhasattrÚsysr$   r$   r$   r%   Ú_get_implementation{   s    
r8   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_scheme‚   s    rC   c                    s   ‡ fdd„|  ¡ D ƒS )z1
    Include only attrs that are None in ob.
    c                    s$   i | ]\}}t ˆ |ƒd kr||“qS r9   )Úgetattr)r"   ÚkeyÚvalue©rA   r$   r%   r&   ‹   s       z_remove_set.<locals>.<dictcomp>)Úitems)rA   Úattrsr$   rG   r%   r?   ‡   s    r?   c                 C   sF   |   d¡\}}}zt |¡}W n" tk
r@   t t| ƒ¡}Y nX |S )NÚ_)Ú	partitionr   Zget_preferred_schemeÚ	ExceptionÚfwr#   Ú
_pypy_hack)rB   Úos_nameÚseprE   Úresolvedr$   r$   r%   r<   Ž   s    r<   c                 C   s
   t ƒ |  S r9   )r2   )rB   r$   r$   r%   r;   —   s    r;   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   )r;   rN   Ú
setdefault)rB   r#   Úfallbackr$   r$   r%   r:   ›   s    	r:   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"   rE   ©r#   r$   r%   r&   «   s      z!_scheme_attrs.<locals>.<dictcomp>)ÚSCHEME_KEYSrU   r$   rU   r%   r@   ©   s    r@   c                 C   sF   t jdk }tt dƒo|}|  d¡ }ddtjdk  }|rB|rB|S | S )N)é   é   r3   )Ú_userÚ_homer   Z_ntr   )r7   Úversion_infor6   ÚendswithÚosrB   )rB   ZPY37Zold_pypyÚprefixZ	pypy_namer$   r$   r%   rN   ®   s
    
rN   c                   @   s:  e Zd ZdZdddddddd	d
dddddddddgZdddg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/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Zd=d>„ Zd?d@„ ZdAdB„ ZdCdD„ ZdEefdFefdGefdHefdIdJdK„ fgZdS )LÚ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 filesr`   rd   rf   ÚuserNz!install in user site-package '%s'rb   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   r   )r^   Úexec_prefixÚhomerg   Ú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_filerd   Ú
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 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k
rú   d}Y nX | j ¡ | j ¡ | j ¡ |dtjdd…  dtjdd…  |||||ttddƒtƒ  ¡ tƒ dœ}tttddƒ dd¡d�}t�r�| j|d< | j|d< t  !t" #¡ |t$ ¡ |g¡| _%|  &¡  |  
d¡ | j|d< | j|d< t'�rúd	dl(m(} t)dƒ |t| j%ƒƒ |  *¡  |  
d¡ | j�r|  +¡  | j,dk�rF| j -¡ �r>| j.| _,n| j/| _,|  0dddd d!d"dd¡ |  1¡  | j,| _2tj3 4| j,| j5¡| _,| j6dk	�r¤|  7d#dddd d!d"¡ |  
d$¡ |  8d%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   r^   rh   Ú z%d.%dr   z%d%dÚ
platlibdirÚlib)Z	dist_nameZdist_versionZdist_fullnameÚ
py_versionÚpy_version_shortÚpy_version_nodotZ
sys_prefixr^   Zsys_exec_prefixrh   Úabiflagsr‚   Zimplementation_lowerÚimplementationÚwinverÚ.)Zpy_version_nodot_platÚuserbaseZusersitezpost-expand_basedirs()ÚbaseÚplatbase)Úpprintzconfig vars:zpost-expand_dirs()r   r   r   r   r   Zlibbasezafter prepending rootÚbuild)rz   rz   )r{   r{   )9r^   rh   ri   rj   rk   r   rg   r]   rB   ÚwarnÚ	dump_dirsÚfinalize_unixÚfinalize_otherr7   ÚversionÚsplitr   r‡   r)   ÚdistributionÚget_nameÚget_versionÚget_fullnamer[   rD   r8   ÚlowerÚdictÚreplaceÚHAS_USER_SITErs   rt   r   Z	DictStackrM   r=   r   Úconfig_varsÚexpand_basedirsr   rŽ   ÚprintÚexpand_dirsÚcreate_home_pathrp   Úhas_ext_modulesrn   rm   Úconvert_pathsÚhandle_extra_pathÚinstall_libbaseÚpathÚjoinÚ
extra_dirsrl   Úchange_rootsÚset_undefined_options)r~   r„   r^   rh   r‡   Ú
local_varsZcompat_varsrŽ   r$   r$   r%   Úfinalize_optionsL  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krx| j| }| |¡}t| |ƒ }n| |¡}t| |ƒ}t d||¡ q(dS )	zDumps the list of user options.Nr   )Úlongopt_xlateú:r   éÿÿÿÿú=z  %s: %s)	r   Úfancy_getoptr®   r   ÚdebugÚuser_optionsÚnegative_optÚ	translaterD   )r~   Úmsgr®   ÚoptZopt_nameÚvalr$   r$   r%   r‘     s    





zinstall.dump_dirsc                 C   s<  | j dk	s| jdk	r`| jdkr2| jdkr2| jdkpN| jdkpN| jdkpN| jdk}|r\tdƒ‚dS | j	r’| j
dkrxtdƒ‚| j
 | _ | _|  d¡ n¦| jdk	r¶| j | _ | _|  d¡ n‚| jdk�r
| jdk	rÔtdƒ‚ttddƒ}tj tj¡| | _tj tj¡| | _n| jdk�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   )rj   rk   rp   rm   rn   ro   rq   rr   r   rg   rs   r   Úselect_schemeri   r^   rh   rD   r   r]   r§   Únormpathr7   )r~   Zincomplete_schemer»   r$   r$   r%   r’     sL    
ÿýûúø
ÿ


ÿzinstall.finalize_unixc                 C   s¼   | j r8| jdkrtdƒ‚| j | _| _|  tjd ¡ n€| jdk	r\| j | _| _|  d¡ n\| j	dkrvtj
 tj	¡| _	| j	 | _| _z|  tj¡ W n" tk
r¶   tdtj ƒ‚Y nX dS )z)Finalizes options for non-posix platformsNrº   rY   r   z)I don't know how to install stuff on '%s')rg   rs   r   rj   rk   r¼   r]   rB   ri   r^   r§   r½   r7   ÚKeyErrorr}   r$   r$   r%   r“   F  s"    


ÿzinstall.finalize_otherc                 C   s   t | |ƒ d S r9   )rC   )r~   rB   r$   r$   r%   r¼   \  s    zinstall.select_schemec                 C   sN   |D ]D}t | |ƒ}|d k	rtjdkr0tj |¡}t|| jƒ}t| ||ƒ qd S )N)r€   r   )rD   r]   rB   r§   Ú
expanduserr	   rž   Úsetattr)r~   rI   Úattrr¹   r$   r$   r%   Ú_expand_attrs_  s    

zinstall._expand_attrsc                 C   s   |   dddg¡ dS )zNCalls `os.path.expanduser` on install_base, install_platbase and
        root.rj   rk   rl   N©rÂ   r}   r$   r$   r%   rŸ   h  s    zinstall.expand_basedirsc                 C   s   |   ddddddg¡ dS )z+Calls `os.path.expanduser` on install dirs.rm   rn   rp   ro   rq   rr   NrÃ   r}   r$   r$   r%   r¡   m  s    úÿzinstall.expand_dirsc                 G   s,   |D ]"}d| }t | |tt| |ƒƒƒ qdS )z!Call `convert_path` over `names`.rT   N)rÀ   r   rD   ©r~   ÚnamesrB   rÁ   r$   r$   r%   r¤   z  s    zinstall.convert_pathsc                 C   s¤   | j dkr| jj | _ | j dk	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 )	z4Set `path_file` and `extra_dirs` using `extra_path`.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�   )rv   r–   r   ÚwarningÚ
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.rT   N)rÀ   r
   rl   rD   rÄ   r$   r$   r%   rª   £  s    zinstall.change_rootsc                 C   sf   | j s
dS ttj d¡ƒ}| j ¡ D ]<\}}t|ƒ |¡r$tj 	|¡s$|  
d| ¡ t |d¡ q$dS )zCreate directories under ~.NÚ~zos.makedirs('%s', 0o700)iÀ  )rg   r   r]   r§   r¿   rž   rH   rÉ   Ú
startswithÚisdirÚdebug_printÚmakedirs)r~   ri   rB   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||k�rt d| j¡ 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)rx   Úrun_commandr–   Úget_command_objÚ	plat_namery   r   r   Úget_sub_commandsrË   Úcreate_path_filer|   Úget_outputsrl   rÊ   ÚrangeÚexecuter   Úmapr]   r§   r½   r7   Únormcaserp   rw   r   r³   )r~   Z
build_platÚcmd_nameÚoutputsZroot_lenÚcounterZsys_pathrp   r$   r$   r%   Úrunµ  sF    

ýÿþþýúzinstall.runc                 C   sJ   t j | j| jd ¡}| jr8|  t|| jgfd| ¡ n|  	d| ¡ dS )zCreates the .pth fileú.pthzcreating %szpath file '%s' not createdN)
r]   r§   r¨   r¦   rË   rw   rØ   r   r©   r�   )r~   Úfilenamer$   r$   r%   rÕ   ç  s     
 ÿzinstall.create_path_filec                 C   sh   g }|   ¡ D ].}|  |¡}| ¡ D ]}||kr"| |¡ q"q| jrd| jrd| tj | j	| jd ¡¡ |S )z.Assembles the outputs of all the sub-commands.rß   )
rÔ   Úget_finalized_commandrÖ   ÚappendrË   rw   r]   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~   Ú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£   r}   r$   r$   r%   Úhas_lib  s    ÿzinstall.has_libc                 C   s
   | j  ¡ S )zLReturns true if the current distribution has any headers to
        install.)r–   Úhas_headersr}   r$   r$   r%   ré     s    zinstall.has_headersc                 C   s
   | j  ¡ S )zMReturns true if the current distribution has any scripts to.
        install.)r–   Úhas_scriptsr}   r$   r$   r%   rê     s    zinstall.has_scriptsc                 C   s
   | j  ¡ S )zJReturns true if the current distribution has any data to.
        install.)r–   Úhas_data_filesr}   r$   r$   r%   Úhas_data   s    zinstall.has_datarp   ro   rq   rr   Úinstall_egg_infoc                 C   s   dS )NTr$   r}   r$   r$   r%   Ú<lambda>,  ó    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_   ¶   sn   Ç<
ÿ
M 61	#2
ûr_   )/Ú__doc__r7   r]   r'   r   r0   Zdistutils._logr   Úcorer   r³   r   r   Ú	file_utilr   Úutilr   r	   r
   r   Úerrorsr   r   r�   r   rM   r   Zsiter   r   r�   ZWINDOWS_SCHEMEr,   r>   ZschemesrV   r+   r2   r8   rC   r?   r<   r;   r:   r@   rN   r_   r$   r$   r$   r%   Ú<module>   s˜   û
ù
ûûûç#ú

ú

	