o
    UgW                     @  sl  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% d3ddZ&d4ddZ'e(e)dd Z*dZ+d5ddZ,d6ddZ-d7d"d#Z.	$d8d9d)d*Z/d:d+d,Z0d3d-d.Z1d4d/d0Z2G d1d2 d2eZ3dS );zI
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)SetuptoolsDeprecationWarning   )egg_info)log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   j/var/www/html/Testing_prj/Navya-Bakers/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_interpreter8      r.   c                   C  s   dt jj S )Npy)sysversion_infomajorr   r   r   r   
python_tag<   r/   r4   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_libfiler8   r.   r&   )r5   resultr8   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warningsrD   RuntimeWarning)rA   rB   rC   rD   valr   r   r   get_flagT   s   

rK   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gettotalrefcountrM   )rD   dcpythonr   r   r   rN   Nr   r"   r;   graalpy   )r<   rG   r   interpreter_namehasattrr1   rK   interpreter_versionr>   splitjoinr&   )soabiimplrS   uabir   r   r   get_abi_tage   s<   

	r`   c                 C     t | ddS Nr   r;   )r    r&   r   r   r   r   
safer_name      rc   c                 C  ra   rb   )r(   r&   r'   r   r   r   safer_version   rd   re   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=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=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=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))rl   rn   ro   rq   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 )NrP   zipFrh   )	bdist_dirdata_dir	plat_nameplat_tagformat	keep_tempdist_dirdist_info_diregginfo_dirroot_is_pure
skip_buildro   ownergrouprq   compressionr4   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)rz   rv   r~   rq   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.)"rt   get_finalized_command
bdist_baseospathr[   r{   r   egg_info_clsdistributionget_command_objensure_finalizedwheel_dist_nameru   r)   rv   r   set_undefined_optionsrs   has_ext_moduleshas_c_librariesr}   _validate_py_limited_apiget_option_dictr   rD   striplowerrq   r   emitr   isdigit
ValueError)r   r   r   need_optionsr   rJ   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   r<   rG   r1   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   )rc   r   get_namere   get_versionr   appendr[   )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anyr7   )r9   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   )interpreterr_   ).0trv   r   r   
<listcomp>j  s    z'bdist_wheel.get_tag.<locals>.<listcomp>z'would build wheel with unsupported tag )r   rv   r}   r>   r=   rt   r.   r   r&   rq   r4   r   rW   rY   r   r   r`   sys_tags)r   r]   tag	impl_nameimpl_verabi_tagsupported_tagsr   r   r   get_tag8  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)reinit_subcommandsinstall_scripts)headersscriptsdatapurelibplatlibinstall_rP   ntz..install_purelibinstall_platlibzinstalling to r   install_egg_info)targetr|   z
.dist-infozreusing z.whlw
dist_filesrf   r"   z	removing )9reinitialize_command
executableforceinplacer~   run_commandrt   rootcompilewarn_dirno_epsetattrr   r   r[   ru   r   normpathinstall_libbaseinstall_libr}   r   infor   r   ro   _ensure_relativeinstall_baser   rc   r   r   re   r   r{   debugshutilcopytreer   rmtreer|   egg2distwrite_wheelfileexistsrz   makedirsr   _zip_compressionwrite_filesgetattrr   r1   r2   r3   minorry   dry_run)r   r   r   r   r   keybasedir_observedimpl_tagr   rw   archive_basenamer5   distinfo_dirnamedistinfo_dir
wheel_pathwfr   r   r   runr  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-PurelibBuildr"   r   TagWHEELz	creating wb)maxheaderlen)email.messager   r   r}   r   r   r   rZ   r[   r   r   r   r   openr   flatten)r   r   r   r   msgr   r   rw   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rtj|rtd| d| d || q\qV|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   rZ   rH   rD   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  sF  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|	| | jD ]}t j|}t|t j|| q|| dS )z:Convert an .egg-info directory into a .dist-info directoryrj   r   r   rr   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)rj   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>?  s    z&bdist_wheel.egg2dist.<locals>.<lambda>)ignorezdependency_links.txtzutf-8)encodingMETADATA)rj   r   r   rr   )r   r   r   globr[   dirnamebasenamer   r   r   r  readr   copyr#  )r   r$  r%  r)  r4  patpossibleerraltpkginfo_pathdependency_links_pathdependency_links_filedependency_linksmetadata_pathlicense_pathfilenamer   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   rD  supported_compressionsvaluesgetr   r   )r   r   r   r   r   r   W  s   
zbdist_wheel._zip_compression)r   rr   r   r   )r   r   )r   r   r   r   r   rr   )r   r   r   r   )r   r  )r$  r   r%  r   r   rr   )r   rD  )__name__
__module____qualname__descriptionr
   r	   rE  r=   r[   r4   user_optionsboolean_optionsr   r   r   propertyr   r   r   r   r   r   r#  r   r   r   r   r   r   rf      s\    ?


/

:
_

,;rf   )r   r   r   r   )r   r   r   r   )r   r)   rH  )r5   r6   r   r   )TT)
rA   r   rB   r)   rC   r)   rD   r)   r   r)   )r   r6   )4__doc__
__future__r   r   r   r   r,   r1   r<   rH   collections.abcr   r   email.generatorr   r4  r   typingr   r   zipfiler	   r
   	packagingr   r   r#   wheel.wheelfiler   rP   r   r   r   r   r   r   	distutilsr   r    r(   rD  rZ   r  r   r.   r4   r=   rK   r`   rc   re   rf   r   r   r   r   <module>   sB    






#
