o
    NZhV                     @  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$   M/var/www/auris/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
startswithZ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warningsrA   RuntimeWarning)r>   r?   r@   rA   valr$   r$   r%   get_flagO   s   

rH   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rd
| 	ddd }|dddd}|S | r|dkrd
| 	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gettotalrefcountrJ   )rA   dcpythonr   r   r   rK   Nr   r   r9   Zgraalpy   )r:   rD   r   interpreter_namehasattrr/   rH   interpreter_versionr<   splitjoinr    )ZsoabiimplrP   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)Z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=rP   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=rY   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=Nzdirectory where a pre-generated dist-info can be found (e.g. as a result of calling the PEP517 'prepare_metadata_for_build_wheel' method))rb   rd   re   rg   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 )NrM   zipFr^   )	bdist_dirdata_dir	plat_nameplat_tagformat	keep_tempdist_dirdist_info_diregginfo_dirroot_is_pure
skip_buildre   ownergrouprg   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   st!dd S d S )NZbdistwheelr   z.data)rp   rl   rt   rg   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        )Zdue_datez1Build tag (build-number) must start with a digit.)"rj   Zget_finalized_command
bdist_baseospathrW   rq   r   egg_info_clsdistributionZget_command_objZensure_finalizedwheel_dist_namerk   r'   rl   rz   set_undefined_optionsri   Zhas_ext_modulesZhas_c_librariesrs   _validate_py_limited_apiget_option_dictr   rA   striplowerrg   r   emitrx   isdigit
ValueError)r|   r   r   Zneed_optionsr~   rG   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 ''Z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.)ry   r!   matchPY_LIMITED_API_PATTERNr   r:   rD   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_versionrx   appendrW   )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 sJ d| |S )Nanyr5   )r7   linux_x86_64
linux_i686)r8   linux_aarch64linux_armv7lr   r9   r   r   zpy2.py3noneZcp3abi3c                   s   g | ]	}|j |j fqS r$   )interpreterrZ   ).0trl   r$   r%   
<listcomp>a  s    z'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )rz   rl   rs   r<   r;   rj   r,   r   r    rg   r2   r   rS   rU   ry   r   r[   sys_tags)r|   rX   tagZ	impl_nameZ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"rt#d| j"  t$%| j"| t&'| j( n| )| j(| | *| tj+| j,st-| 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sOtd| j  | j8sQt&'| j d S d S d S )Nbuild_scriptspythonT	build_extFbuildinstall)Zreinit_subcommandsinstall_scripts)headersscriptsdatapurelibplatlibZinstall_rM   ntz..Zinstall_purelibZinstall_platlibzinstalling to r   Zinstall_egg_info)targetrr   z
.dist-infozreusing z.whlwZ
dist_filesr]   r   z	removing )9Zreinitialize_command
executableforceZinplacert   run_commandrj   rootcompileZwarn_dirZno_epsetattrr   r   rW   rk   namenormpathZinstall_libbaseZinstall_librs   r   infor   r   re   _ensure_relativeZinstall_baser   r   r   r   r\   r   rq   debugshutilcopytreer   rmtreerr   egg2distwrite_wheelfileexistsrp   makedirsr   _zip_compressionZwrite_filesgetattrr   r/   r0   r1   minorro   dry_run)r|   r   r   r   r   keyZbasedir_observedimpl_tagr   rm   Zarchive_basenamer3   Zdistinfo_dirnamedistinfo_dir
wheel_pathZwfr$   r$   r%   runi  s~   






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-PurelibZBuildr   r   TagWHEELz	creating wb)maxheaderlen)email.messager   r   rs   r   rx   r   rV   rW   r   r   r   r   openr   flatten)r|   r   r   r   msgr   r   rm   rX   rZ   platZ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rtj|rtd| d| d || q\qV|S )N9   r$   metadata*   license_filesr   Zlicense_filezEThe "license_file" option is deprecated. Use "license_files" instead.r   rB   )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   rV   rE   rA   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 directoryr`   r   r   rh   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)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>   zrequires.txtzSOURCES.txtr   znot-zip-safer$   )xyr$   r$   r%   <lambda>6  s    z&bdist_wheel.egg2dist.<locals>.<lambda>)ignorezdependency_links.txtzutf-8)encodingMETADATAZlicensesT)exist_ok)r`   r   r   rh   )r   r   r   globrW   dirnamebasenamer   r   r   r   readr   copyr   r   r   )r|   r   r   r   r  patpossibleerrZaltZpkginfo_pathZdependency_links_pathZdependency_links_fileZdependency_linksZmetadata_pathZlicenses_folder_pathZlicense_pathZ	safe_pathZ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   rw   r  supported_compressionsvaluesgetr   r   )r|   rw   r$   r$   r%   r   Q  s   
zbdist_wheel._zip_compression)r   rh   r   r   )r   r   )r   r   r   r   r   rh   )r   r   r   r   )r   r   )r   r   r   r   r   rh   )r   r  )__name__
__module____qualname__descriptionr
   r	   r  r;   rW   r2   Zuser_optionsZ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'   r  )r3   r4   r   r   )TT)
r>   r   r?   r'   r@   r'   rA   r'   r   r'   )r   r4   )6__doc__
__future__r   r   r!   r   r*   r/   r:   rE   collections.abcr   r   email.generatorr   r  r   typingr   r   zipfiler	   r
   	packagingr   r   r   Zwheel.wheelfiler   rM   r   r   r   Z_core_metadatar   Z_normalizationr   r   r   r   	distutilsr   r&   r  rV   r   r   r,   r2   r;   rH   r[   r\   r]   r$   r$   r$   r%   <module>   sB    





#