U
    X7h[                     @  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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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$ 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. er.ddl/m0Z0 dddddZ1e2e'3dd Z4dZ5ddddZ6dddd Z7d!dd"d#d$Z8d9dddddd&d'd(Z9d!dd)d*Z:dddd+d,Z;d-dd.d/d0d1d2Z<d-dd3d/d4d5d6Z=G d7d8 d8e&Z>dS ):zI
Create a wheel (.whl) distribution.

A wheel is a built archive format.
    )annotationsN)BytesGenerator	Generator)EmailPolicy)iglob)rmtree)TYPE_CHECKINGCallableIterableLiteralSequencecast)ZIP_DEFLATED
ZIP_STORED)tagsversion)pkginfo_to_metadata)	WheelFile   )Command__version__)
safer_name)SetuptoolsDeprecationWarning   )egg_info)log)ExcInfostr)r   returnc                 C  sF   zt t| W S  tjk
r@   | dd} tdd|  Y S X dS )zB
    Convert an arbitrary string to a standard version string
     .z[^A-Za-z0-9.]+-N)r   _packaging_versionVersionInvalidVersionreplaceresubr    r)   X/var/www/formularioweb/env/lib/python3.8/site-packages/setuptools/command/bdist_wheel.pysafe_version'   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_interpreter8   s    r2   c                   C  s   dt jd  S )Npyr   )sysversion_infor)   r)   r)   r*   
python_tag<   s    r6   z
str | None)archive_rootr   c                 C  s^   t  }|dr2| dk	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wheel.macosx_libfiler9   r2   r%   )r7   resultr9   r)   r)   r*   r>   @   s    r>   T)varfallbackexpectedwarnr   c                 C  s:   t | }|dk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 incorrectr   
stacklevel)r=   get_config_varwarningsrD   RuntimeWarning)rA   rB   rC   rD   valr)   r)   r*   get_flagT   s    

rK   c                  C  s  t d} t }| s|dk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 }ttdr|d	7 }n| r<|dkr<d| 
ddd }|dddd}n^| rz|dkrzd| 
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gettotalrefcountrM   )rD   dWITH_PYMALLOC)      mcpythonr!   r   r   rN   Nr   r    r<   graalpyrU   )r=   rG   r   interpreter_namehasattrr4   rK   r5   interpreter_versionr?   splitjoinr%   )soabiimplrS   rW   uabir)   r)   r*   get_abi_tage   sB    


rc   c                 C  s   t | ddS )Nr!   r<   )r+   r%   r(   r)   r)   r*   safer_version   s    rd   zCallable[..., object]r   None)funcpathexcinfor   c                 C  s   t | ||d  d S )Nr   )remove_readonly_exc)rf   rg   rh   r)   r)   r*   remove_readonly   s    rj   BaseException)rf   rg   excr   c                 C  s   t |tj | | d S )N)oschmodstatS_IWRITE)rf   rg   rl   r)   r)   r*   ri      s    ri   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dgZddddgZdddd Zddd!d"Zddd#d$Zed%dd&d'Zd(dd)d*Zd+d, Zd-e d.fd%d%dd/d0d1Zd%d%d2d3d4Zed5dd6d7Zd%d%dd8d9d:Zd;dd<d=ZdS )>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=rS   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=ra   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=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])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)rv   rx   ry   r{   re   r-   c                 C  s~   d | _ d | _d | _d | _d| _d| _d | _d | _d | _d | _	d| _
d| _d | _d | _d| _d| _t | _d | _d| _d| _d S )NzipFrr   )	bdist_dirdata_dir	plat_nameplat_tagformat	keep_tempdist_dirdist_info_diregginfo_dirroot_is_pure
skip_buildry   ownergroupr{   compressionr6   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 krFtt| j	
d}|  | jd | _t| j| _d}| jdt||  | j	 p| j	  | _|   | j	d}d|krtd |d d  }| d	krd
| _| jrtjdddd | jd k	r| jd d   st!dd S )Nbdistwheelr   z.data)r   r   r   r{   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  rV      )due_datez1Build tag (build-number) must start with a digit.)r   )"r}   get_finalized_command
bdist_baserm   rg   r^   r   r   egg_info_clsdistributionget_command_objensure_finalizedwheel_dist_namer~   r,   r   r   set_undefined_optionsr|   has_ext_moduleshas_c_librariesr   _validate_py_limited_apiget_option_dictr   rD   striplowerr{   r   emitr   isdigit
ValueError)r   r   r   Zneed_optionsr   rJ   r)   r)   r*   finalize_options  s6    

 zbdist_wheel.finalize_optionsc                 C  sP   | j s
d S tt| j s(tdt dtdrLtd| j dtjdd S )Nzpy-limited-api must match ''Py_GIL_DISABLEDz`py_limited_api=za` not supported. `Py_LIMITED_API` is currently incompatible with `Py_GIL_DISABLED` (sys.abiflags=z7). See https://github.com/python/cpython/issues/111506.)	r   r&   matchPY_LIMITED_API_PATTERNr   r=   rG   r4   abiflagsr   r)   r)   r*   r   3  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_namerd   get_versionr   appendr^   )r   
componentsr)   r)   r*   r   B  s    zbdist_wheel.wheel_dist_nameztuple[str, str, str]c                   s(  | j r| jr| j nN| jr d nB| jr:| jds:| j n
t| j t rb dkrVd  dk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 }||ks$td| |S )Nanyr8   )r:   linux_x86_64
linux_i686)r;   linux_aarch64Zlinux_armv7lr!   r<   r    r   zpy2.py3noneZcp3abi3c                   s   g | ]}|j |j fqS r)   )interpreterrb   ).0tr   r)   r*   
<listcomp>  s    z'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )r   r   r   r?   r>   r}   r2   r   r%   r{   r6   r   rZ   r\   r   r   rc   sys_tagsAssertionError)r   r`   tagZ	impl_nameZimpl_verabi_tagZsupported_tagsr)   r   r*   get_tagM  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"rt#d| j"  t$%| j"| t$&| j' n| (| j'| | )| tj*| j+st,| j+ tj| j+|
d }t-|d| . }|/| W 5 Q R X t0| jdg 1ddj2t3j4d d  |f | j5std| j  | j6st3j4dk rt&| jt7d nt&| jt8d  d S )!Nbuild_scriptspythonT	build_extFbuildinstall)reinit_subcommandsinstall_scripts)headersscriptsdatapurelibplatlibinstall_rP   ntz..Zinstall_purelibZinstall_platlibzinstalling to r!   Zinstall_egg_info)targetr   z
.dist-infozreusing z.whlw
dist_filesrq   z{}.{}r   z	removing )rU      )onerror)Zonexc)9reinitialize_command
executableforceZinplacer   run_commandr}   rootcompileZwarn_dirZno_epsetattrrm   rg   r^   r~   namenormpathZinstall_libbaseinstall_libr   r   infor   r   ry   _ensure_relativeZinstall_baser   r   r   r   rd   r   r   debugshutilcopytreer   r   egg2distwrite_wheelfileexistsr   makedirsr   _zip_compressionZwrite_filesgetattrr   r   r4   r5   r   dry_runrj   ri   )r   r   r   r   r   keyZbasedir_observedimpl_tagr   r   Zarchive_basenamer7   Zdistinfo_dirnameZdistinfo_dirZ
wheel_pathZwfr)   r)   r*   run  sz    





 
"
zbdist_wheel.runzsetuptools ())wheelfile_base	generatorr   c              	   C  s   ddl m} | }d|d< ||d< t| j |d< | jd k	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 5 Q R X d S )Nr   )Messagez1.0zWheel-Versionr   zRoot-Is-PurelibZBuildr    r!   TagZWHEELz	creating wb)maxheaderlen)email.messager   r   r   r   r   r   r]   r^   rm   rg   r   r   openr   flatten)r   r   r   r   msgr   r   r   r`   rb   ZplatZwheelfile_pathfr)   r)   r*   r     s     

zbdist_wheel.write_wheelfile)rg   r   c                 C  s6   t j|\}}|dd t jkr2||dd   }|S )Nr   r   )rm   rg   
splitdrivesep)r   rg   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|kr`|d d 	 }nd}d|krt
jdtd	d
 ||d d  |s|st|tsd}|D ]f}t|D ]X}|drtd| d q||krtj|rtd| d| d || qq|S )N9   r)   metadata*   license_filesr   license_filezEThe "license_file" option is deprecated. Use "license_files" instead.r   rE   )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]   rH   rD   DeprecationWarningadd
isinstancelistr   endswithr   r   rm   rg   isfiler   )r   filesr   patternspatternrg   r)   r)   r*   license_paths  s>    

zbdist_wheel.license_paths)egginfo_pathdistinfo_pathr   c              	   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 
| nlt j|d}
t	||
}	tj||dd d t j|d}t|dd}|  }W 5 Q R X |s|| t j|d}tdddd}t|ddd}t||d|	 W 5 Q R X | jD ](}t j|}t|t j|| q`|| dS )z:Convert an .egg-info directory into a .dist-info directoryr   re   )rt   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)rm   rg   r   islinkisdirr   r   unlink)rt   r)   r)   r*   adios7  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   ddddhS )Nr  zrequires.txtzSOURCES.txtznot-zip-safer)   )xyr)   r)   r*   <lambda>]  s
    z&bdist_wheel.egg2dist.<locals>.<lambda>)ignorezdependency_links.txtzutf-8)encodingMETADATATF)utf8mangle_from_max_line_lengthr   )policy)rm   rg   r   globr^   dirnamebasenamer   r  r   mkdirr   r   r   readr   r   r   r   r  copy)r   r  r  r  r!  patpossibleerrZaltZpkg_infoZpkginfo_pathZdependency_links_pathZdependency_links_filedependency_linksZpkg_info_pathZserialization_policyoutZlicense_pathfilenamer)   r)   r*   r   4  sL    



zbdist_wheel.egg2distintc                 C  sT   t | jtr"| j| j kr"| jS | jt| j}|d k	r@|S td| jd S )NzUnsupported compression: )r  r   r-  supported_compressionsvaluesgetr   r   )r   r   r)   r)   r*   r   {  s    
zbdist_wheel._zip_compression)__name__
__module____qualname__descriptionr   r   r.  r>   r   r^   r6   user_optionsboolean_optionsr   r   r   propertyr   r   r   r   r   r   r  r   r   r)   r)   r)   r*   rq      sZ   A/
:b
,Grq   )TT)?__doc__
__future__r   rm   r&   r   ro   r0   r4   r=   rH   email.generatorr   r   email.policyr   r!  r   r   typingr   r	   r
   r   r   r   zipfiler   r   	packagingr   r   r"   Zwheel.metadatar   Zwheel.wheelfiler   rP   r   r   _normalizationr   r   r   r   	distutilsr   Z	_typeshedr   r+   r-  r]   r  r   r2   r6   r>   rK   rc   rd   rj   ri   rq   r)   r)   r)   r*   <module>   sN       +