o
    gd\                     @  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, erddl-m.Z. dBddZ/dCddZ0e1e'2dd Z3dZ4dDdd Z5dEd!d"Z6dFd%d&Z7	'dGdHd,d-Z8dId.d/Z9dBd0d1Z:dCd2d3Z;dJd:d;Z<dKd>d?Z=G d@dA dAe&Z>dS )LzI
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__)SetuptoolsDeprecationWarning   )egg_info)log)ExcInfonamestr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$   [/var/www/rescue_company/venv/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py	safe_name&   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_version-   s   r.   r(   zcp3\dboolc                   C  s   t ddkS )NP   )structcalcsizer$   r$   r$   r%   _is_32bit_interpreter>   s   r4   c                   C  s   dt jd  S )Npyr   )sysversion_infor$   r$   r$   r%   
python_tagB      r8   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_libfiler=   r4   r,   )r:   resultr=   r$   r$   r%   rB   F   s   rB   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)rA   get_config_varwarningsrI   RuntimeWarning)rF   rG   rH   rI   valr$   r$   r%   get_flagZ   s   

rP   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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gettotalrefcountrR   )rI   dWITH_PYMALLOC)      mcpythonr    r   r   rS   Nr   r(   r@   graalpyrZ   )rA   rL   r   interpreter_namehasattrr6   rP   r7   interpreter_versionrC   splitjoinr,   )soabiimplrX   r\   uabir$   r$   r%   get_abi_tagk   sH   

	rh   c                 C     t | ddS Nr    r@   )r&   r,   r#   r$   r$   r%   
safer_name   r9   rk   c                 C  ri   rj   )r.   r,   r-   r$   r$   r%   safer_version   r9   rl   funcCallable[..., object]pathexcinfor   Nonec                 C  s   t | ||d  d S )Nr   )remove_readonly_exc)rm   ro   rp   r$   r$   r%   remove_readonly   s   rs   excBaseExceptionc                 C  s   t |tj | | d S )N)oschmodstatS_IWRITE)rm   ro   rt   r$   r$   r%   rr      s   rr   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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d@d.d/ZdAd1d2ZedBd4d5ZdCd8d9ZdDd;d<ZdS )E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=rX   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=rf   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))r   r   r   r   r   rq   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zipFr|   )	bdist_dirdata_dir	plat_nameplat_tagformat	keep_tempdist_dirdist_info_diregginfo_dirroot_is_pure
skip_buildr   ownergroupr   compressionr8   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 )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  r[      )due_datez1Build tag (build-number) must start with a digit.)"r   get_finalized_command
bdist_baserv   ro   rc   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   rI   striplowerr   r   emitr   isdigit
ValueError)r   r   r   need_optionsr   rO   r$   r$   r%   finalize_options  s8   

zbdist_wheel.finalize_optionsc                 C  sP   | j sd S tt| j stdt dtdr&t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   rA   rL   r6   abiflagsr   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    )rk   r   get_namerl   get_versionr   appendrc   )r   
componentsr$   r$   r%   r   I  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anyr<   )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$   )interpreterrg   ).0tr   r$   r%   
<listcomp>  s    z'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )r   r   r   rC   rB   r   r4   r   r,   r   r8   r   r_   ra   r   r   rh   sys_tags)r   re   tag	impl_nameimpl_verabi_tagsupported_tagsr$   r   r%   get_tagT  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| . }|/| W d    n	1 sw   Y  t0| jdg 1ddj2t3j4d d  |f | j5s^td| j  | j6s`t3j4dk rUt&| jt7d d S t&| jt8d  d S d S d S )!Nbuild_scriptspythonT	build_extFbuildinstall)reinit_subcommandsinstall_scripts)headersscriptsdatapurelibplatlibinstall_rU   ntz..install_purelibinstall_platlibzinstalling to r    install_egg_info)targetr   z
.dist-infozreusing z.whlw
dist_filesrz   z{}.{}r   z	removing )rZ      )onerror)onexc)9reinitialize_command
executableforceinplacer   run_commandr   rootcompilewarn_dirno_epsetattrrv   ro   rc   r   r   normpathinstall_libbaseinstall_libr   r   infor   r   r   _ensure_relativeinstall_baser   rk   r   r   rl   r   r   debugshutilcopytreer   r   egg2distwrite_wheelfileexistsr   makedirsr   _zip_compressionwrite_filesgetattrr   r   r6   r7   r   dry_runrs   rr   )r   r   r   r   r   keybasedir_observedimpl_tagr   r   archive_basenamer:   distinfo_dirnamedistinfo_dir
wheel_pathwfr$   r$   r%   run  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-Versionr   zRoot-Is-PurelibBuildr(   r    TagWHEELz	creating wb)maxheaderlen)email.messager  r   r   r   r   r   rb   rc   rv   ro   r   r   openr   flatten)r   r  r  r  msgr  r   r   re   rg   platwheelfile_pathfr$   r$   r%   r     s&   

"zbdist_wheel.write_wheelfilero   c                 C  s6   t j|\}}|dd t jkr||dd   }|S )Nr   r   )rv   ro   
splitdrivesep)r   ro   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rtj|rtd| d| d || qZqT|S )N9   r$   metadata*   license_filesr   license_filezEThe "license_file" option is deprecated. Use "license_files" instead.r   rJ   )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   rb   rM   rI   DeprecationWarningadd
isinstancelistr   endswithr   r   rv   ro   isfiler   )r   filesr#  patternspatternro   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 sw   Y  |s|| t j|d}tdddd}t|ddd}t||d|	 W d   n1 sw   Y  | jD ]}t j|}t|t j|| q|| dS )z:Convert an .egg-info directory into a .dist-info directoryr~   r   r   rq   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)rv   ro   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>   SOURCES.txtnot-zip-saferequires.txtr:  r$   )xyr$   r$   r%   <lambda>d  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   rq   )rv   ro   r   globrc   dirnamebasenamer   r/  r   mkdirr   r   r  readr   r   r   r  r3  copy)r   r4  r5  r9  rH  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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   r\  supported_compressionsvaluesgetr   r   )r   r   r$   r$   r%   r    s   
zbdist_wheel._zip_compression)r   rq   r   r   )r   r   )r  r   r  r   r   rq   )ro   r   r   r   )r   r!  )r4  r   r5  r   r   rq   )r   r\  )__name__
__module____qualname__descriptionr   r   r]  rB   r   rc   r8   user_optionsboolean_optionsr   r   r   propertyr   r   r  r   r   r   r3  r   r  r$   r$   r$   r%   rz      s`    A


/

:
b

,Grz   )r   r   r   r   )r   r   r   r   )r   r/   r`  )r:   r;   r   r   )TT)
rF   r   rG   r/   rH   r/   rI   r/   r   r/   )r   r;   )rm   rn   ro   r   rp   r   r   rq   )rm   rn   ro   r   rt   ru   r   rq   )?__doc__
__future__r   rv   r!   r   rx   r2   r6   rA   rM   email.generatorr   r   email.policyr   rH  r   r   typingr   r	   r
   r   r   r   zipfiler   r   	packagingr   r   r)   wheel.metadatar   wheel.wheelfiler   rU   r   r   r   r   r   	distutilsr   	_typeshedr   r&   r.   r\  rb   r(  r   r4   r8   rB   rP   rh   rk   rl   rs   rr   rz   r$   r$   r$   r%   <module>   sP     






(


