o
    6‘ðiáT  ã                   @  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	Z	ddl
Z
ddlZddlmZ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mZmZmZ dd
lmZm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+ er�ddl,Z,ze-dƒ W n e.y©   ddl%m/Z/ e/ 0¡  Y nw e 1d¡Z2dCdd„Z3dDdd„Z4e5ej& 6d¡d ƒZ7dZ8dEd d!„Z9dFd"d#„Z:dGd&d'„Z;	(dHdId-d.„Z<dJd/d0„Z=dCd1d2„Z>dDd3d4„Z?dKd;d<„Z@dLd?d@„ZAG dAdB„ dBe$ƒZBdS )MzI
Create a wheel (.whl) distribution.

A wheel is a built archive format.
é    )ÚannotationsN)ÚIterableÚSequence)ÚBytesGeneratorÚ	Generator)ÚEmailPolicy)Úiglob)Úrmtree)ÚTYPE_CHECKINGÚCallableÚLiteralÚcast)ÚZIP_DEFLATEDÚ
ZIP_STORED)Útags©Úversion)ÚCommandé   )Ú__version__)Úpkginfo_to_metadata)Ú	WheelFilezsetuptools.logging)Ú_setuptools_loggingÚwheelÚnameÚstrÚreturnc                 C  s   t  dd| ¡S )zŽConvert an arbitrary string to a standard distribution name
    Any runs of non-alphanumeric/. characters are replaced with a single '-'.
    ú[^A-Za-z0-9.]+ú-)ÚreÚsub©r   © r"   úQ/root/parts/websockify/install/lib/python3.10/site-packages/wheel/_bdist_wheel.pyÚ	safe_name2   s   r$   r   c                 C  s@   zt t | ¡ƒW S  tjy   |  dd¡} t dd| ¡ Y S w )zB
    Convert an arbitrary string to a standard version string
    ú Ú.r   r   )r   Ú_packaging_versionÚVersionÚInvalidVersionÚreplacer   r    r   r"   r"   r#   Úsafe_version9   s   þr+   r&   zcp3\dÚboolc                   C  s   t  d¡dkS )NÚPé   )ÚstructÚcalcsizer"   r"   r"   r#   Ú_is_32bit_interpreterJ   s   r1   c                   C  s   dt jd › �S )NÚpyr   )ÚsysÚversion_infor"   r"   r"   r#   Ú
python_tagN   ó   r5   Úarchive_rootú
str | Nonec                 C  s^   t  ¡ }| d¡r| durddlm} || |ƒ}ntƒ r)|dkr#d}n|dkr)d}| d	d
¡S )z0Return our platform name 'win32', 'linux_x86_64'ÚmacosxNr   )Úcalculate_macosx_platform_tagúlinux-x86_64z
linux-i686úlinux-aarch64zlinux-armv7lr   Ú_)Ú	sysconfigÚget_platformÚ
startswithÚmacosx_libfiler:   r1   r*   )r7   Úresultr:   r"   r"   r#   r?   R   s   r?   TÚvarÚfallbackÚexpectedÚwarnc                 C  s:   t  | ¡}|du r|rtjd| › d�tdd� |S ||kS )zfUse a fallback value for determining SOABI flags if the needed config
    var is unset or unavailable.NzConfig variable 'z+' is unset, Python ABI tag may be incorrecté   ©Ú
stacklevel)r>   Úget_config_varÚwarningsrF   ÚRuntimeWarning)rC   rD   rE   rF   Úvalr"   r"   r#   Úget_flagf   s   

ýrN   c                  C  sŽ  t  d¡} t ¡ }| sO|dv rOttdƒrOd}d}d}tdttdƒ|dkd�r(d	}td
|dk|dko5tjdk d�r?tjdk r?d}|› t ¡ › |› |› |› �}|S | re|dkre|  	d¡red|  
d¡d  }|S | ry|dkry|  	d¡ry|  
d¡d }|S | r—|dkr—d |  
d¡dd… ¡}| dd¡ dd¡}|S | rµ|dkrµd |  
d¡dd… ¡}| dd¡ dd¡}|S | rÃ|  dd¡ dd¡}|S d}|S )zJReturn the ABI tag based on SOABI (if available) or emulate SOABI (PyPy2).ÚSOABI)ÚcpÚppÚ
maxunicodeÚ ÚPy_DEBUGÚgettotalrefcountrP   )rF   ÚdÚWITH_PYMALLOC)é   é   ÚmÚcpythonr   r   r   rQ   NrG   r&   r=   ÚgraalpyrX   )r>   rJ   r   Úinterpreter_nameÚhasattrr3   rN   r4   Úinterpreter_versionr@   ÚsplitÚjoinr*   )ÚsoabiÚimplrV   rZ   ÚuÚabir"   r"   r#   Úget_abi_tagw   sH   
ý
îñô	øûþrf   c                 C  ó   t | ƒ dd¡S ©Nr   r=   )r$   r*   r!   r"   r"   r#   Ú
safer_nameŸ   r6   ri   c                 C  rg   rh   )r+   r*   r   r"   r"   r#   Úsafer_version£   r6   rj   ÚfuncúCallable[..., object]ÚpathÚexcinfoú6tuple[type[Exception], Exception, types.TracebackType]ÚNonec                 C  s   t | ||d ƒ d S )Nr   )Úremove_readonly_exc)rk   rm   rn   r"   r"   r#   Úremove_readonly§   s   rr   ÚexcÚ	Exceptionc                 C  s   t  |tj¡ | |ƒ d S )N)ÚosÚchmodÚstatÚS_IWRITE)rk   rm   rs   r"   r"   r#   rq   ¯   s   rq   c                   @  sÚ   e Zd ZdZeedœZddddedƒ› d�fd	d
dddddddd d 	e¡¡fddde
ƒ › d�fddgZg d¢Zdd„ Zdd„ Zedd„ ƒZd5d!d"„Zd#d$„ Zd%e› d�fd6d)d*„Zd7d,d-„Zed8d/d0„ƒZd9d3d4„ZdS ):Úbdist_wheelzcreate a wheel distribution)ÚstoredÚdeflated)z
bdist-dir=Úbz1temporary directory for creating the distributionz
plat-name=Úpz8platform name to embed in generated filenames (default: Nú))ú	keep-tempÚkzPkeep the pseudo-installation tree around after creating the distribution archive)z	dist-dir=rV   z-directory to put final built distributions in)ú
skip-buildNz2skip rebuilding everything (for testing/debugging))ÚrelativeNz7build the archive using relative paths (default: false))zowner=rd   z@Owner name used when creating a tar file [default: current user])zgroup=ÚgzAGroup name used when creating a tar file [default: current group])Ú	universalNz'make a universal wheel (default: false)zcompression=z6zipfile compression (one of: {}) (default: 'deflated')z, zpython-tag=z3Python implementation compatibility tag (default: 'z'))zbuild-number=NzqBuild number for this particular version. As specified in PEP-0427, this must start with a digit. [default: None])zpy-limited-api=Nz?Python tag (cp32|cp33|cpNN) for abi3 wheel tag (default: false))r   r�   r‚   r„   c                 C  sx   d | _ d | _d | _d | _d| _d| _d | _d | _d | _d | _	d| _
d | _d | _d| _d| _tƒ | _d | _d| _d| _d S )NÚzipFr{   )Ú	bdist_dirÚdata_dirÚ	plat_nameÚplat_tagÚformatÚ	keep_tempÚdist_dirÚegginfo_dirÚroot_is_pureÚ
skip_buildr‚   ÚownerÚgroupr„   Úcompressionr5   Úbuild_numberÚpy_limited_apiÚplat_name_supplied)Úselfr"   r"   r#   Úinitialize_optionsø   s&   
zbdist_wheel.initialize_optionsc                 C  sJ  | j d u r|  d¡j}tj |d¡| _ | j d¡}| ¡  | j	d | _
| jd u| _z	| j| j | _W n tyB   td| j› �ƒd ‚w d}| jdgt||ƒ¢R Ž  | j ¡ pZ| j ¡  | _| jrot t| j¡sotdt› d�ƒ‚| j d¡}d	|v r�t d
¡ |d	 d  ¡ }| ¡ dv r�d| _| j d ur¡| j d d…  !¡ s£tdƒ‚d S d S )NÚbdistr   Úegg_infoz.datazUnsupported compression: )rŒ   rˆ   r�   zpy-limited-api must match 'ú'r„   z=The [wheel] section is deprecated. Use [bdist_wheel] instead.r   )Ú1ÚtrueÚyesTz1Build tag (build-number) must start with a digit.)"r†   Úget_finalized_commandÚ
bdist_baseru   rm   ra   ÚdistributionÚget_command_objÚensure_finalizedÚwheel_dist_namer‡   rˆ   r•   Úsupported_compressionsr’   ÚKeyErrorÚ
ValueErrorÚset_undefined_optionsr…   Úhas_ext_modulesÚhas_c_librariesrŽ   r”   r   ÚmatchÚPY_LIMITED_API_PATTERNÚget_option_dictÚlogÚwarningÚstripÚlowerr„   r“   Úisdigit)r–   rŸ   r™   Úneed_optionsr   rM   r"   r"   r#   Úfinalize_options  s>   
ÿÿ
ÿÿÿzbdist_wheel.finalize_optionsc                 C  s8   t | j ¡ ƒt| j ¡ ƒf}| jr|| jf7 }d |¡S )z4Return distribution full name with - replaced with _r   )ri   r    Úget_namerj   Úget_versionr“   ra   )r–   Ú
componentsr"   r"   r#   r£   8  s   þ
zbdist_wheel.wheel_dist_namer   útuple[str, str, str]c                   s(  | j r
tt| jƒ‰ n'| jrd‰ n!| jr| j d¡s| j‰ nt| jƒ‰ tƒ r1ˆ dv r+d‰ ˆ dv r1d‰ ˆ  	¡  
dd¡ 
d	d¡ 
d
d¡‰ | jrT| jrJd}n| j}|dˆ f}|S t ¡ }t ¡ }|| }| jrp||  d¡rp| j}d}nttƒ ƒ 	¡ }||ˆ f}‡ fdd„t ¡ D ƒ}||v s’J d|› �ƒ‚|S )NÚanyr9   )r;   Úlinux_x86_64Ú
linux_i686)r<   Úlinux_aarch64Úlinux_armv7lr   r=   r&   r%   zpy2.py3ÚnoneÚcp3Úabi3c                   s   g | ]	}|j |jˆ f‘qS r"   )Úinterpreterre   )Ú.0Út©rˆ   r"   r#   Ú
<listcomp>u  s    ÿz'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )r•   r   r   rˆ   rŽ   r@   r?   r†   r1   r°   r*   r„   r5   r   r]   r_   r”   rf   Úsys_tags)r–   rc   ÚtagÚ	impl_nameÚimpl_verÚabi_tagÚsupported_tagsr"   rÃ   r#   Úget_tagC  sF   
ÿ
ï

ÿ
ÿzbdist_wheel.get_tagc                 C  sŒ  |   d¡}d|_d|_|   d¡}d|_| js|  d¡ | j ddd�}| j|_d|_| j|_d|_	|   d	¡}d|_
d
D ]}t|d| tj | j|¡ƒ q:d}tjdkrdtj tj | jd¡¡}| | _| _t|| jrkdnd|ƒ t d| j› �¡ |  d¡ |  ¡ \}}}	| j› d|› d|› d|	› �}
| js™| j}ntj | j|  |j¡¡}|  dd¡ t| j ¡ ƒ› dt | j !¡ ƒ› d�}tj | j|¡}|  "| j#|¡ |  $|¡ tj %| j&¡sÞt '| j&¡ tj | j&|
d ¡}t(|d| j)ƒ�}| *|¡ W d   ƒ n1 sÿw   Y  t+| jdg ƒ ,ddj-t.j/d d… Ž |f¡ | j0�sBt d| j› �¡ | j1�sDt.j/dk �r9t2| jt3d� d S t2| jt4d� d S d S d S ) NÚbuild_scriptsÚpythonTÚ	build_extFÚbuildÚinstall)Úreinit_subcommandsÚinstall_scripts)ÚheadersÚscriptsÚdataÚpurelibÚplatlibÚinstall_rS   Úntz..Úinstall_purelibÚinstall_platlibzinstalling to r   Úinstall_egg_info)Útargetr�   z
.dist-infoz.whlÚwÚ
dist_filesry   z{}.{}rG   z	removing )rX   é   )Úonerror)Úonexc)5Úreinitialize_commandÚ
executableÚforceÚinplacer�   Úrun_commandr†   ÚrootÚcompileÚwarn_dirÚno_epÚsetattrru   rm   ra   r‡   r   ÚnormpathÚinstall_libbaseÚinstall_librŽ   r­   ÚinforË   r£   r‚   Ú_ensure_relativeÚinstall_baser§   ri   r    r´   rj   rµ   Úegg2distr�   Úwrite_wheelfileÚexistsrŒ   Úmakedirsr   r’   Úwrite_filesÚgetattrÚappendrŠ   r3   r4   r‹   Údry_runr	   rr   rq   )r–   rÌ   rÎ   rÐ   rÒ   ÚkeyÚbasedir_observedÚimpl_tagrÉ   r‰   Úarchive_basenamer7   Údistinfo_dirnameÚdistinfo_dirÚ
wheel_pathÚwfr"   r"   r#   Úrun}  s|   




ý
ÿÿÿ
ÿýÿúzbdist_wheel.runzbdist_wheel (Úwheelfile_baser   Ú	generatorc                 C  sú   ddl m} |ƒ }d|d< ||d< t| jƒ ¡ |d< | jd ur$| j|d< |  ¡ \}}}| d¡D ]}| d¡D ]}	| d¡D ]}
d	 ||	|
f¡|d
< q>q7q0t	j
 |d¡}t d|› �¡ t|dƒ�}t|dd� |¡ W d   ƒ d S 1 svw   Y  d S )Nr   )ÚMessagez1.0zWheel-Versionr   zRoot-Is-PurelibÚBuildr&   r   ÚTagÚWHEELz	creating Úwb)Úmaxheaderlen)Úemail.messager  r   rŽ   r°   r“   rË   r`   ra   ru   rm   r­   rð   Úopenr   Úflatten)r–   r  r  r  Úmsgrý   rÉ   r‰   rc   re   ÚplatÚwheelfile_pathÚfr"   r"   r#   rô   ×  s&   

ÿÿ"ÿzbdist_wheel.write_wheelfilerm   c                 C  s6   t j |¡\}}|dd… t jkr||dd …  }|S )Nr   r   )ru   rm   Ú
splitdriveÚsep)r–   rm   Údriver"   r"   r#   rñ   ï  s   zbdist_wheel._ensure_relativeúIterable[str]c              	   C  s  t dkr| jjjp
dS tƒ }| j d¡}t dkr#ttt | jjjƒ}nd|v r0|d d  	¡ }nd}d|v rGt
jdtd	d
� | |d d ¡ |sR|sRt|tƒsRd}|D ]3}t|ƒD ],}| d¡rkt d|› d�¡ qZ||vr†tj |¡r†t d|› d|› d�¡ | |¡ qZqT|S )Né9   r"   Úmetadataé*   Úlicense_filesr   Úlicense_filezEThe "license_file" option is deprecated. Use "license_files" instead.rG   rH   )zLICEN[CS]E*zCOPYING*zNOTICE*zAUTHORS*ú~zignoring license file "z" as it looks like a backupzadding license file "z" (matched pattern "z"))Úsetuptools_major_versionr    r  r  Úsetr¬   r   r   r   r`   rK   rF   ÚDeprecationWarningÚaddÚ
isinstanceÚlistr   Úendswithr­   Údebugru   rm   Úisfilerð   )r–   Úfilesr  ÚpatternsÚpatternrm   r"   r"   r#   Úlicense_pathsö  sB   ý

ÿÿ
€õzbdist_wheel.license_pathsÚegginfo_pathÚdistinfo_pathc                 C  s´  ddd„}||ƒ t j |¡s?ddl}t j t j |¡d	¡}| |¡}d
|› d�}|r;t j |d ¡}|d|› d�7 }t|ƒ‚t j |¡rPt	||ƒ}	t  
|¡ n?t j |d¡}
t	||
ƒ}	tj||dd„ d� t j |d¡}t|dd��}| ¡  ¡ }W d  ƒ n1 s„w   Y  |s�||ƒ t j |d¡}tdddd�}t|ddd��}t||d� |	¡ W d  ƒ n1 s¸w   Y  | jD ]}t j |¡}t |t j ||¡¡ qÀ||ƒ dS )z:Convert an .egg-info directory into a .dist-info directoryr}   r   r   rp   c                 S  sP   t j | ¡rt j | ¡st j | ¡rt | ¡ dS t j | ¡r&t  | ¡ dS dS )z-Appropriately delete directory, file or link.N)ru   rm   rõ   ÚislinkÚisdirÚshutilr	   Úunlink)r}   r"   r"   r#   Úadios&  s
   $ÿz#bdist_wheel.egg2dist.<locals>.adiosr   Nz
*.egg-infozEgg metadata expected at z but not foundz (z) found - possible misnamed archive file?)úPKG-INFOc                 S  s   h d£S )N>   úSOURCES.txtúnot-zip-safeúrequires.txtr1  r"   )ÚxÚyr"   r"   r#   Ú<lambda>L  s    z&bdist_wheel.egg2dist.<locals>.<lambda>)Úignorezdependency_links.txtzutf-8)ÚencodingÚMETADATATF)Úutf8Úmangle_from_Úmax_line_lengthrÞ   )Úpolicy)r}   r   r   rp   )ru   rm   rõ   Úglobra   ÚdirnameÚbasenamer¦   r%  r   Úmkdirr.  Úcopytreer  Úreadr¯   r   r   r  r)  Úcopy)r–   r*  r+  r0  r?  ÚpatÚpossibleÚerrÚaltÚpkg_infoÚpkginfo_pathÚdependency_links_pathÚdependency_links_fileÚdependency_linksÚpkg_info_pathÚserialization_policyÚoutÚlicense_pathÚfilenamer"   r"   r#   ró   #  sP   



ýÿýÿ
zbdist_wheel.egg2dist)r   r·   )r  r   r  r   )rm   r   r   r   )r   r  )r*  r   r+  r   )Ú__name__Ú
__module__Ú__qualname__Údescriptionr   r   r¤   r?   rŠ   ra   r5   Úuser_optionsÚboolean_optionsr—   r³   Úpropertyr£   rË   r  Úwheel_versionrô   rñ   r)  ró   r"   r"   r"   r#   ry   ´   sZ    þÿýÿýýÍ:+


:
[ÿ
,ry   )r   r   r   r   )r   r   r   r   )r   r,   )r   r   )r7   r8   r   r   )TT)
rC   r   rD   r,   rE   r,   rF   r,   r   r,   )r   r8   )rk   rl   rm   r   rn   ro   r   rp   )rk   rl   rm   r   rs   rt   r   rp   )CÚ__doc__Ú
__future__r   Úloggingru   r   r.  rw   r/   r3   r>   rK   Úcollections.abcr   r   Úemail.generatorr   r   Úemail.policyr   r?  r   r	   Útypingr
   r   r   r   Úzipfiler   r   Ú
setuptoolsÚ	packagingr   r   r'   r   rS   r   r[  Ú	_metadatar   Ú	wheelfiler   ÚtypesÚ
__import__ÚImportErrorr   Ú	configureÚ	getLoggerr­   r$   r+   Úintr`   r  r«   r1   r5   r?   rN   rf   ri   rj   rr   rq   ry   r"   r"   r"   r#   Ú<module>   sb    ü





ÿ

(


