o
    5‘ðiÂV  ã                   @  sp  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
mZmZ ddlmZ ddlmZ ddlmZm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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dl(m)Z) d0dd„Z*e+e ,d¡d ƒZ-dZ.d1dd„Z/d2dd„Z0d3d!d"„Z1	#d4d5d(d)„Z2d6d*d+„Z3d0d,d-„Z4G d.d/„ d/eƒZ5dS )7zI
Create a wheel (.whl) distribution.

A wheel is a built archive format.
é    )ÚannotationsN)ÚIterableÚSequence)ÚBytesGenerator)Úiglob)ÚLiteralÚcast)ÚZIP_DEFLATEDÚ
ZIP_STORED)ÚtagsÚversion)Ú	WheelFileé   )ÚCommandÚ__version__Ú_shutil)Ú_safe_license_file)Ú
safer_name)ÚSetuptoolsDeprecationWarningé   )Úegg_info)Úlogr   ÚstrÚreturnc                 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
    ú Ú.z[^A-Za-z0-9.]+ú-)r   Ú_packaging_versionÚVersionÚInvalidVersionÚreplaceÚreÚsub©r   © r$   ú]/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/command/bdist_wheel.pyÚsafe_version"   s   þr&   r   zcp3\dÚboolc                   C  s   t  d¡dkS )NÚPé   )ÚstructÚcalcsizer$   r$   r$   r%   Ú_is_32bit_interpreter3   ó   r,   c                   C  s   dt jj› �S )NÚpy)ÚsysÚversion_infoÚmajorr$   r$   r$   r%   Ú
python_tag7   r-   r2   Ú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Úwheel.macosx_libfiler6   r,   r    )r3   Úresultr6   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 incorrectr   ©Ú
stacklevel)r:   Úget_config_varÚwarningsrB   ÚRuntimeWarning)r?   r@   rA   rB   Úvalr$   r$   r%   Úget_flagO   s   

ýrI   c                  C  sj  t  d¡} t ¡ }| s4|dv r4ttdƒr4d}d}tdttdƒ|dkd�r&d	}|› t ¡ › |› |› �}|S | rJ|dkrJ|  d
¡rJd|  	d¡d  }|S | rg|dkrg|  d¡rg|  	d¡d }ttdƒre|d	7 }|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ÚgettotalrefcountrK   )rB   ÚdÚcpythonr   r   r   rL   Nr   r   r9   Úgraalpyé   )r:   rE   r   Úinterpreter_nameÚhasattrr/   rI   Úinterpreter_versionr<   ÚsplitÚjoinr    )ÚsoabiÚimplrQ   ÚuÚabir$   r$   r%   Úget_abi_tag`   s<   
ëî
ô	øûþr^   c                 C  s   t | ƒ dd¡S )Nr   r9   )r&   r    r#   r$   r$   r%   Úsafer_versionƒ   s   r_   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¡› d�fddde	ƒ › d�fdddgZ
g d¢Zd>dd„Zd>dd „Zd>d!d"„Zed?d$d%„ƒZd@d'd(„Zd)d*„ Zd+e› d,�fdAd/d0„ZdBd2d3„ZedCd5d6„ƒZdDd9d:„ZdEd<d=„ZdS )FÚ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=rQ   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=r\   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])Ú	universalNz4*DEPRECATED* make a universal wheel [default: false]zcompression=zzipfile compression (one of: z, z) [default: 'deflated']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])zdist-info-dir=Nz‰directory where a pre-generated dist-info can be found (e.g. as a result of calling the PEP517 'prepare_metadata_for_build_wheel' method))rf   rh   ri   rk   r   ÚNonec                 C  s~   d | _ d| _d | _d | _d| _d| _d | _d | _d | _d | _	d| _
d| _d | _d | _d| _d| _tƒ | _d | _d| _d| _d S )NrN   ÚzipFrb   )Ú	bdist_dirÚdata_dirÚ	plat_nameÚplat_tagÚformatÚ	keep_tempÚdist_dirÚdist_info_dirÚegginfo_dirÚroot_is_pureÚ
skip_buildri   ÚownerÚgrouprk   Úcompressionr2   Úbuild_numberÚpy_limited_apiÚplat_name_supplied©Úselfr$   r$   r%   Úinitialize_optionsÐ   s(   
zbdist_wheel.initialize_optionsc                 C  s  | j s|  d¡j}tj |d¡| _ | jd u r#tt| j	 
d¡ƒ}| ¡  | jd | _t| jƒ| _d}| jdgt||ƒ¢R Ž  | j	 ¡ pF| j	 ¡  | _|  ¡  | j	 d¡}d|v rmt d¡ |d d  ¡ }| ¡ d	v rmd
| _| jrxtjdddd� | jd urŠ| jd d…   ¡ sŒt!dƒ‚d S d S )NÚbdistÚwheelr   z.data)rt   rp   rx   rk   z=The [wheel] section is deprecated. Use [bdist_wheel] instead.r   )Ú1ÚtrueÚyesTz#bdist_wheel.universal is deprecatedaj  
                With Python 2.7 end-of-life, support for building universal wheels
                (i.e., wheels that support both Python 2 and Python 3)
                is being obviated.
                Please discontinue using this option, or if you still need it,
                file an issue with pypa/setuptools describing your use case.
                )ié  é   é   )Údue_datez1Build tag (build-number) must start with a digit.)"rn   Úget_finalized_commandÚ
bdist_baseÚosÚpathrY   ru   r   Úegg_info_clsÚdistributionÚget_command_objÚensure_finalizedÚwheel_dist_namero   r'   rp   r~   Úset_undefined_optionsrm   Úhas_ext_modulesÚhas_c_librariesrw   Ú_validate_py_limited_apiÚget_option_dictr   rB   ÚstripÚlowerrk   r   Úemitr|   ÚisdigitÚ
ValueError)r€   r‹   r   Úneed_optionsrƒ   rH   r$   r$   r%   Úfinalize_optionsæ   s8   
ÿ
÷ÿzbdist_wheel.finalize_optionsc                 C  sH   | j sd S t t| j ¡stdt› d�ƒ‚t d¡r"td| j ›d�ƒ‚d S )Nzpy-limited-api must match 'ú'ÚPy_GIL_DISABLEDz`py_limited_api=zˆ` not supported. `Py_LIMITED_API` is currently incompatible with `Py_GIL_DISABLED`. See https://github.com/python/cpython/issues/111506.)r}   r!   ÚmatchÚPY_LIMITED_API_PATTERNrœ   r:   rE   r   r$   r$   r%   r–     s   
ÿÿz$bdist_wheel._validate_py_limited_apir   c                 C  s8   t | j ¡ ƒt| j ¡ ƒg}| jr| | j¡ d |¡S )z4Return distribution full name with - replaced with _r   )r   r�   Úget_namer_   Úget_versionr|   ÚappendrY   )r€   Ú
componentsr$   r$   r%   r’   $  s   þ
zbdist_wheel.wheel_dist_nameútuple[str, str, str]c                   s(  | j r
| jr
| 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Úanyr5   )r7   Úlinux_x86_64Ú
linux_i686)r8   Úlinux_aarch64Úlinux_armv7lr   r9   r   r   zpy2.py3ÚnoneÚcp3Úabi3c                   s   g | ]	}|j |jˆ f‘qS r$   )Úinterpreterr]   )Ú.0Út©rp   r$   r%   Ú
<listcomp>a  s    ÿz'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )r~   rp   rw   r<   r;   rn   r,   r™   r    rk   r2   r   rU   rW   r}   r   r^   Úsys_tags)r€   r[   ÚtagÚ	impl_nameÚimpl_verÚabi_tagÚsupported_tagsr$   r³   r%   Úget_tag/  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"rßt #d| j"› �¡ t$ %| j"|¡ t& '| j(¡ n|  )| j(|¡ |  *|¡ tj +| j,¡søt -| j,¡ tj | j,|
d ¡}t.|d|  /¡ ƒ�}| 0|¡ W d   ƒ n	1 �sw   Y  t1| jdg ƒ 2dt3j4j5› dt3j4j6› �|f¡ | j7�sKt d| j› �¡ t& '| j¡ d S d S )NÚbuild_scriptsÚpythonTÚ	build_extFÚbuildÚinstall)Úreinit_subcommandsÚinstall_scripts)ÚheadersÚscriptsÚdataÚpurelibÚplatlibÚinstall_rN   Úntz..Úinstall_purelibÚinstall_platlibzinstalling to r   Úinstall_egg_info)Útargetrv   z
.dist-infozreusing z.whlÚwÚ
dist_filesr`   r   z	removing )8Úreinitialize_commandÚ
executableÚforceÚinplacerx   Úrun_commandrn   ÚrootÚcompileÚwarn_dirÚno_epÚsetattrrŒ   r�   rY   ro   ÚnameÚnormpathÚinstall_libbaseÚinstall_librw   r   Úinfor»   r’   ri   Ú_ensure_relativeÚinstall_baser“   r   r�   r£   r_   r¤   ru   ÚdebugÚshutilÚcopytreer   Úrmtreerv   Úegg2distÚwrite_wheelfileÚexistsrt   Úmakedirsr   Ú_zip_compressionÚwrite_filesÚgetattrr¥   r/   r0   r1   Úminorrs   )r€   r¼   r¾   rÀ   rÂ   ÚkeyÚbasedir_observedÚimpl_tagr¹   rq   Úarchive_basenamer3   Údistinfo_dirnameÚdistinfo_dirÚ
wheel_pathÚwfr$   r$   r%   Úruni  sz   




ý
ÿÿÿ
ÿýþzbdist_wheel.runzsetuptools (ú)Úwheelfile_baseÚ	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-VersionÚ	GeneratorzRoot-Is-PurelibÚBuildr   r   ÚTagÚWHEELz	creating Úwb)Úmaxheaderlen)Úemail.messagerù   r   rw   r™   r|   r»   rX   rY   rŒ   r�   r   rÞ   Úopenr   Úflatten)r€   r÷   rø   rù   Úmsgrï   r¹   rq   r[   r]   ÚplatÚwheelfile_pathÚfr$   r$   r%   ræ   Æ  s&   

ÿÿ"ÿzbdist_wheel.write_wheelfiler�   c                 C  s6   t j |¡\}}|dd… t jkr||dd …  }|S )Nr   r   )rŒ   r�   Ú
splitdriveÚsep)r€   r�   Ú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t ƒ }| j d¡}t dkr%ttt | jjjƒ}nd|v r2|d d  	¡ }nd}d|v rIt
jdtd	d
� | |d d ¡ |sT|sTt|tƒsTd}|D ]3}t|ƒD ],}| d¡rmt d|› d�¡ q\||vrˆtj |¡rˆt d|› d|› d�¡ | |¡ q\qV|S )Né9   r$   Úmetadataé*   Úlicense_filesr   Úlicense_filezEThe "license_file" option is deprecated. Use "license_files" instead.r   rC   )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   rX   rF   rB   ÚDeprecationWarningÚaddÚ
isinstanceÚlistr   Úendswithr   rá   rŒ   r�   ÚisfilerÞ   )r€   Úfilesr  ÚpatternsÚpatternr�   r$   r$   r%   Úlicense_pathså  sB   
ý

ÿÿ
€õzbdist_wheel.license_pathsÚegginfo_pathÚdistinfo_pathc                 C  sj  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 |d¡}	tj	||dd„ d� t j |d¡}
t
|
dd��}| ¡  ¡ }W d  ƒ n1 snw   Y  |sy||
ƒ t j |d¡}t |	|¡ t j |d¡}| jD ]}t|ƒ}t j ||¡}t jt j |¡dd� t ||¡ q�||ƒ dS )z:Convert an .egg-info directory into a .dist-info directoryrd   r   r   rl   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)rŒ   r�   rç   ÚislinkÚisdirr   rä   Úunlink)rd   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.txtr#  r$   )ÚxÚyr$   r$   r%   Ú<lambda>5  s    z&bdist_wheel.egg2dist.<locals>.<lambda>)Úignorezdependency_links.txtzutf-8)ÚencodingÚMETADATAÚlicensesT)Úexist_ok)rd   r   r   rl   )rŒ   r�   rç   ÚglobrY   ÚdirnameÚbasenamerœ   râ   rã   r  Úreadr˜   Úcopyr  r   rè   )r€   r  r  r"  r/  ÚpatÚpossibleÚerrÚaltÚpkginfo_pathÚdependency_links_pathÚdependency_links_fileÚdependency_linksÚmetadata_pathÚlicenses_folder_pathÚlicense_pathÚ	safe_pathÚdist_info_license_pathr$   r$   r%   rå     s@   

ýÿ
zbdist_wheel.egg2distÚintc                 C  sP   t | jtƒr| j| j ¡ v r| jS | j t| jƒ¡}|d ur |S td| j›�ƒ‚)NzUnsupported compression: )r  r{   rA  Úsupported_compressionsÚvaluesÚgetr   rœ   )r€   r{   r$   r$   r%   ré   P  s   
ÿzbdist_wheel._zip_compression)r   rl   ©r   r   )r   r§   )r÷   r   rø   r   r   rl   )r�   r   r   r   )r   r
  )r  r   r  r   r   rl   )r   rA  )Ú__name__Ú
__module__Ú__qualname__Údescriptionr
   r	   rB  r;   rY   r2   Úuser_optionsÚboolean_optionsr�   rž   r–   Úpropertyr’   r»   rõ   r   ræ   rß   r  rå   ré   r$   r$   r$   r%   r`   ‡   s\    þÿýýýÊ?


/

:
^ÿ

,>r`   )r   r   r   r   )r   r'   rE  )r3   r4   r   r   )TT)
r?   r   r@   r'   rA   r'   rB   r'   r   r'   )r   r4   )6Ú__doc__Ú
__future__r   rŒ   r!   râ   r*   r/   r:   rF   Úcollections.abcr   r   Úemail.generatorr   r/  r   Útypingr   r   Úzipfiler	   r
   Ú	packagingr   r   r   Úwheel.wheelfiler   rN   r   r   r   Ú_core_metadatar   Ú_normalizationr   r   r   rŽ   Ú	distutilsr   r&   rA  rX   r  r¢   r,   r2   r;   rI   r^   r_   r`   r$   r$   r$   r%   Ú<module>   sB    



ÿ

#