a
    b3jT                     @  sH  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.yV   ddl%m/Z/ e/0  Y n0 e1dZ2dddddZ3dddddZ4e5ej&6dd Z7dZ8ddd d!Z9ddd"d#Z:d$dd%d&d'Z;d>dddddd)d*d+Z<d$dd,d-Z=dddd.d/Z>dddd0d1Z?d2dd3d4d5d6d7Z@d2dd8d4d9d:d;ZAG d<d= d=e$ZBdS )?zI
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str)namereturnc                 C  s   t dd| S )zConvert 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"   o/www/wwwroot/dpstar/app/297b3aabda72fedb274352021c2dd8b5_venv/lib/python3.9/site-packages/wheel/_bdist_wheel.py	safe_name2   s    r$   )r   r   c                 C  sD   zt t| W S  tjy>   | dd} tdd|  Y S 0 dS )zB
    Convert an arbitrary string to a standard version string
     .r   r   N)r   _packaging_versionVersionInvalidVersionreplacer   r    r   r"   r"   r#   safe_version9   s
    r+   r&   zcp3\dboolr   c                   C  s   t ddkS )NP   )structcalcsizer"   r"   r"   r#   _is_32bit_interpreterJ   s    r2   c                   C  s   dt jd  S )Npyr   )sysversion_infor"   r"   r"   r#   
python_tagN   s    r6   z
str | None)archive_rootr   c                 C  s^   t  }|dr2| dur2ddlm} || |}n t rR|dkrFd}n|dkrRd}|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macosx_libfiler9   r2   r*   )r7   resultr9   r"   r"   r#   r>   R   s    r>   T)varfallbackexpectedwarnr   c                 C  s:   t | }|du r2|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warningsrD   RuntimeWarning)rA   rB   rC   rD   valr"   r"   r#   get_flagf   s    

rL   c                  C  s  t d} t }| s|dv rttdrd}d}d}tdttd|dkdrPd	}td
|dk|dkojtjdk dr~tjdk r~d}| t  | | | }n| r|dkr| 	drd| 
dd  }n| r|dkr| 	dr| 
dd }n| r*|dkr*d| 
ddd }|dddd}n^| rh|dkrhd| 
ddd }|dddd}n | r| dddd}nd}|S )zJReturn the ABI tag based on SOABI (if available) or emulate SOABI (PyPy2).SOABI)cppp
maxunicode Py_DEBUGgettotalrefcountrN   )rD   dWITH_PYMALLOC)      mcpythonr   r   r   rO   NrE   r&   r<   ZgraalpyrV   )r=   rH   r   interpreter_namehasattrr4   rL   r5   interpreter_versionr?   splitjoinr*   )ZsoabiimplrT   rX   uabir"   r"   r#   get_abi_tagw   s>    
rb   c                 C  s   t | ddS Nr   r<   )r$   r*   r!   r"   r"   r#   
safer_name   s    rd   c                 C  s   t | ddS rc   )r+   r*   r   r"   r"   r#   safer_version   s    re   zCallable[..., object]z6tuple[type[Exception], Exception, types.TracebackType]None)funcpathexcinfor   c                 C  s   t | ||d  d S )Nr   )remove_readonly_exc)rg   rh   ri   r"   r"   r#   remove_readonly   s    rk   	Exception)rg   rh   excr   c                 C  s   t |tj | | d S )N)oschmodstatS_IWRITE)rg   rh   rm   r"   r"   r#   rj      s    rj   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dd d!d"Zd#d$ Zd%e dfd&d&d'd(d)Zd&d&d*d+d,Zed-d d.d/Zd&d&d0d1d2ZdS )3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=rT   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])	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))rw   ry   rz   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zipFrs   )	bdist_dirdata_dir	plat_nameplat_tagformat	keep_tempdist_diregginfo_dirroot_is_pure
skip_buildrz   ownergroupr|   compressionr6   build_numberpy_limited_apiplat_name_supplied)selfr"   r"   r#   initialize_options   s&    zbdist_wheel.initialize_optionsc                 C  sR  | j d u r&| dj}tj|d| _ | jd}|  | j	d | _
| jd u| _z| j| j | _W n$ ty   td| j d Y n0 d}| jdgt||R   | j p| j  | _| jrtt| jstdt d| jd}d	|v r&td
 |d	 d  }| dv r&d| _| j d urN| j d d ! sNtd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_basern   rh   r^   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   Zneed_optionsr   rK   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   )rd   r   get_namere   get_versionr   r^   )r   
componentsr"   r"   r#   r   8  s    zbdist_wheel.wheel_dist_nameztuple[str, str, str]r-   c                   s(  | j rtt| j nN| jr d nB| jr:| jds:| j n
t| j t rb dv rVd  dv rbd  	 
dd
d	d
d
d | jr| jrd}n| j}|d f}n~t }t }|| }| jr|| dr| j}d}ntt 	 }|| f} fddt D }||v s$J d| |S )Nanyr8   )r:   linux_x86_64
linux_i686)r;   linux_aarch64linux_armv7lr   r<   r&   r%   zpy2.py3noneZcp3abi3c                   s   g | ]}|j |j fqS r"   )interpreterra   ).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~   r2   r   r*   r|   r6   r   rZ   r\   r   rb   sys_tags)r   r_   tagZ	impl_nameZimpl_verabi_tagsupported_tagsr"   r   r#   get_tagC  sD    


zbdist_wheel.get_tagc                 C  s  |  d}d|_d|_|  d}d|_| js6| d | j ddd}| j|_d|_| j|_d|_	|  d	}d|_
d
D ] }t|d| tj| j| qtd}tjdkrtjtj| jd}| | _| _t|| jrdnd| td| j  | d |  \}}}	| j d| d| d|	 }
| js4| j}ntj| j| |j}| dd t| j  dt | j!  d}tj| j|}| "| j#| | $| tj%| j&st'| j& tj| j&|
d }t(|d| j)}|*| W d    n1 s0    Y  t+| jdg ,ddj-t.j/d d  |f | j0std| j  | j1st.j/dk rvt2| jt3d nt2| jt4d d S ) Nbuild_scriptspythonT	build_extFbuildinstall)reinit_subcommandsinstall_scripts)headersscriptsdatapurelibplatlibinstall_rQ   ntz..install_purelibinstall_platlibzinstalling to r   install_egg_info)targetr   z
.dist-infoz.whlw
dist_filesrr   z{}.{}rE   z	removing )rV      )onerror)Zonexc)5reinitialize_command
executableforceZinplacer   run_commandr~   rootcompilewarn_dirZno_epsetattrrn   rh   r^   r   r   normpathinstall_libbaseinstall_libr   r   infor   r   rz   _ensure_relativeinstall_baser   rd   r   r   re   r   egg2distr   write_wheelfileexistsr   makedirsr   r   Zwrite_filesgetattrappendr   r4   r5   r   dry_runr	   rk   rj   )r   r   r   r   r   keyZbasedir_observedimpl_tagr   r   Zarchive_basenamer7   Zdistinfo_dirnamedistinfo_dir
wheel_pathZwfr"   r"   r#   run}  sv    






*zbdist_wheel.runzbdist_wheel (r   )wheelfile_base	generatorc                 C  s   ddl m} | }d|d< ||d< t| j |d< | jd urH| j|d< |  \}}}|dD ]8}|dD ](}	|dD ]}
d	||	|
f|d
< q|qnq`t	j
|d}td|  t|d"}t|dd| W d    n1 s0    Y  d S )Nr   )Messagez1.0zWheel-Versionr   zRoot-Is-PurelibBuildr&   r   TagZWHEELz	creating wb)maxheaderlen)email.messager   r   r   r   r   r   r]   r^   rn   rh   r   r   openr   flatten)r   r   r   r   msgr   r   r   r_   ra   platZwheelfile_pathfr"   r"   r#   r     s     

zbdist_wheel.write_wheelfile)rh   r   c                 C  s6   t j|\}}|dd t jkr2||dd   }|S )Nr   r   )rn   rh   
splitdrivesep)r   rh   driver"   r"   r#   r     s    zbdist_wheel._ensure_relativezIterable[str]c              	   C  s  t dkr| jjjpdS t }| jd}t dkrFttt | jjj}nd|v r`|d d 	 }nd}d|v rt
jdtd	d
 ||d d  |s|st|tsd}|D ]f}t|D ]X}|drtd| d q||vrtj|rtd| d| d || qq|S )N9   r"   metadata*   license_filesr   license_filezEThe "license_file" option is deprecated. Use "license_files" instead.rE   rF   )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]   rI   rD   DeprecationWarningadd
isinstancelistr   endswithr   debugrn   rh   isfiler   )r   filesr   patternspatternrh   r"   r"   r#   license_paths  s>    

zbdist_wheel.license_paths)egginfo_pathdistinfo_pathc                 C  s  ddddd}|| t j|sddl}t jt j|d}||}d	| d
}|r|t j|d }|d| d7 }t|t j|rt	||}	t 
| nt j|d}
t	||
}	tj||dd d t j|d}t|dd}|  }W d   n1 s0    Y  |s(|| t j|d}tdddd}t|ddd"}t||d|	 W d   n1 s|0    Y  | jD ](}t j|}t|t j|| q|| dS )z:Convert an .egg-info directory into a .dist-info directoryr   rf   )ru   r   c                 S  sJ   t j| r0t j| s0t j| r0t|  nt j| rFt |  dS )z-Appropriately delete directory, file or link.N)rn   rh   r   islinkisdirshutilr	   unlink)ru   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SOURCES.txtzrequires.txtznot-zip-safer  r"   )xyr"   r"   r#   <lambda>L      z&bdist_wheel.egg2dist.<locals>.<lambda>)ignorezdependency_links.txtzutf-8)encodingMETADATATF)utf8mangle_from_max_line_lengthr   )policy)rn   rh   r   globr^   dirnamebasenamer   r  r   mkdirr  copytreer   readr   r   r   r   r  copy)r   r  r  r  r%  patpossibleerrZaltpkg_infoZpkginfo_pathZdependency_links_pathZdependency_links_filedependency_linksZpkg_info_pathZserialization_policyoutZlicense_pathfilenamer"   r"   r#   r   #  sL    


,2
zbdist_wheel.egg2dist)__name__
__module____qualname__descriptionr   r   r   r>   r   r^   r6   user_optionsboolean_optionsr   r   propertyr   r   r   wheel_versionr   r   r  r   r"   r"   r"   r#   rr      sX   :+

:[
,rr   )TT)C__doc__
__future__r   loggingrn   r   r  rp   r0   r4   r=   rI   collections.abcr   r   email.generatorr   r   email.policyr   r%  r   r	   typingr
   r   r   r   zipfiler   r   
setuptools	packagingr   r   r'   r   rQ   r   r:  	_metadatar   Z	wheelfiler   types
__import__ImportErrorr   	configure	getLoggerr   r$   r+   intr]   r  r   r2   r6   r>   rL   rb   rd   re   rk   rj   rr   r"   r"   r"   r#   <module>   s^   
 (