o
    {ŸŽiD/  ã                   @   sÂ  d Z ddlZddlZddlZddl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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! ddl"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l0m1Z1 ddl2m3Z3 e 4e5¡Z6e 7dej8¡Z9ee#ge:f Z;ee
e# e
e# f Z<dd„ Z=dd„ Z>dd„ Z?dd„ Z@dd„ ZAd d!„ ZBd"d#„ ZCd$d%„ ZDd&d'„ ZEd(d)„ ZFd*d+„ ZGd,d-„ ZHdS ).z;Orchestrator for building wheels from InstallRequirements.
é    N)ÚAnyÚCallableÚIterableÚListÚOptionalÚTuple)Úcanonicalize_nameÚcanonicalize_version)ÚInvalidVersionÚVersion)Ú
WheelCache)ÚInvalidWheelFilenameÚUnsupportedWheel)Úget_wheel_distribution)ÚLink)ÚWheel)Úbuild_wheel_pep517)Úbuild_wheel_legacy)ÚInstallRequirement)Ú
indent_log)Ú
ensure_dirÚ	hash_fileÚis_wheel_installed)Úmake_setuptools_clean_args)Úcall_subprocess)ÚTempDirectory)Úpath_to_url)Úvcsz([a-z0-9_.]+)-([a-z0-9_.!+-]+)c                 C   s   t t | ¡ƒS )zjDetermine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    N)ÚboolÚ_egg_info_reÚsearch)Ús© r"   úeC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\site-packages\pip/_internal/wheel_builder.pyÚ_contains_egg_info%   s   r$   c                 C   s~   | j rdS | jr|rt d| j¡ dS |rdS | js| jsdS | jr$dS || ƒs1t d| j¡ dS tƒ s=t d| j¡ dS dS )zBReturn whether an InstallRequirement should be built into a wheel.Fz(Skipping %s, due to already being wheel.TzCSkipping wheel build for %s, due to binaries being disabled for it.zOUsing legacy 'setup.py install' for %s, since package 'wheel' is not installed.N)	Ú
constraintÚis_wheelÚloggerÚinfoÚnameÚeditableÚ
source_dirÚ
use_pep517r   )ÚreqÚ
need_wheelÚcheck_binary_allowedr"   r"   r#   Ú_should_build.   s6   ÿþþr0   c                 C   s   t | dtd�S )NT©r.   r/   )r0   Ú_always_true)r-   r"   r"   r#   Úshould_build_for_wheel_command^   s   ÿr3   c                 C   s   t | d|d�S )NFr1   )r0   )r-   r/   r"   r"   r#   Ú should_build_for_install_commandg   s   ÿr4   c                 C   sŠ   | j s| jsdS | jr1| jjr1| j rJ ‚| jsJ ‚t | jj¡}|s$J ‚| | jj| j¡r/dS dS | js6J ‚| j 	¡ \}}t
|ƒrCdS dS )zÍ
    Return whether a built InstallRequirement can be stored in the persistent
    wheel cache, assuming the wheel cache is available, and _should_build()
    has determined a wheel needs to be built.
    FTN)r*   r+   ÚlinkÚis_vcsr   Úget_backend_for_schemeÚschemeÚis_immutable_rev_checkoutÚurlÚsplitextr$   )r-   Úvcs_backendÚbaseÚextr"   r"   r#   Ú_should_cacheq   s   	


r?   c                 C   s@   t |jƒ}| js
J ‚|rt| ƒr| | j¡}|S | | j¡}|S )zdReturn the persistent or temporary cache directory where the built
    wheel need to be stored.
    N)r   Ú	cache_dirr5   r?   Úget_path_for_linkÚget_ephem_path_for_link)r-   Úwheel_cacheÚcache_availabler@   r"   r"   r#   Ú_get_cache_dir’   s   

ÿrE   c                 C   s   dS )NTr"   )Ú_r"   r"   r#   r2   £   s   r2   c           	      C   sè   t | jpdƒ}ttj |¡ƒ}t |jƒ|krtd ||j¡ƒ‚t||ƒ}t	|j
ƒ}t|ƒt|j
ƒkr;td ||j
¡ƒ‚|j}|d u rFtdƒ‚zt|ƒ}W n ty\   d|› �}t|ƒ‚w |tdƒkrpt|j
tƒsrtd |¡ƒ‚d S d S )NÚ z7Wheel has unexpected file name: expected {!r}, got {!r}zMissing Metadata-VersionzInvalid Metadata-Version: z1.2z6Metadata 1.2 mandates PEP 440 version, but {!r} is not)r   r)   r   ÚosÚpathÚbasenamer   Úformatr   ÚstrÚversionr	   Úmetadata_versionr   r   r
   Ú
isinstance)	r-   Ú
wheel_pathÚcanonical_nameÚwÚdistÚdist_verstrÚmetadata_version_valuerN   Úmsgr"   r"   r#   Ú_verify_one¨   s>   
þ


þ
þ
ÿþþrW   c              
   C   sÐ   zt |ƒ W n ty! } zt d| j|¡ W Y d}~dS d}~ww | j� t| |||ƒ}W d  ƒ n1 s7w   Y  |rf|rfzt| |ƒ W |S  tt	fye } zt d| j|¡ W Y d}~dS d}~ww |S )zaBuild one wheel.

    :return: The filename of the built wheel, or None if the build failed.
    ú Building wheel for %s failed: %sNz!Built wheel for %s is invalid: %s)
r   ÚOSErrorr'   Úwarningr)   Ú	build_envÚ_build_one_inside_envrW   r   r   )r-   Ú
output_dirÚverifyÚbuild_optionsÚglobal_optionsÚerP   r"   r"   r#   Ú
_build_oneÈ   s2   þ€ûÿÿý€þrb   c                 C   sh  t dd��¥}| jsJ ‚| jr7| jsJ ‚| jsJ ‚|r!t d| j¡ |r*t d| j¡ t| j| j| j|jd�}nt	| j| j
| j|||jd�}|d ur™tj |¡}tj ||¡}z(t|ƒ\}}	t ||¡ t d| j||	| ¡ ¡ t d|¡ |W W  d   ƒ S  ty˜ }
 zt d	| j|
¡ W Y d }
~
nd }
~
ww | js¡t| |ƒ 	 W d   ƒ d S 1 s­w   Y  d S )
NÚwheel)Úkindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r)   ÚbackendÚmetadata_directoryÚtempd)r)   Úsetup_py_pathr+   r`   r_   rg   z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %srX   )r   r)   r,   rf   Úpep517_backendr'   rZ   r   rI   r   rh   Úunpacked_source_directoryrH   rJ   Újoinr   ÚshutilÚmover(   Ú	hexdigestÚ	ExceptionÚ_clean_one_legacy)r-   r]   r_   r`   Útemp_dirrP   Ú
wheel_nameÚ	dest_pathÚ
wheel_hashÚlengthra   r"   r"   r#   r\   ë   sf   


ÿÿüú	ýØ)þ€ÿ
$Ïr\   c                 C   sT   t | j|d�}t d| j¡ z
t|| jd� W dS  ty)   t d| j¡ Y dS w )N)r`   zRunning setup.py clean for %s)ÚcwdTz Failed cleaning build dir for %sF)	r   rh   r'   r(   r)   r   r+   ro   Úerror)r-   r`   Ú
clean_argsr"   r"   r#   rp   &  s   þþrp   c           
      C   s  | sg g fS t  dd dd„ | D ƒ¡¡ tƒ �> g g }}| D ].}t||ƒ}t|||||ƒ}	|	rHtt|	ƒƒ|_|jj	|_
|jjsBJ ‚| |¡ q| |¡ qW d  ƒ n1 sXw   Y  |rmt  dd dd	„ |D ƒ¡¡ |r}t  d
d dd	„ |D ƒ¡¡ ||fS )z˜Build wheels.

    :return: The list of InstallRequirement that succeeded to build and
        the list of InstallRequirement that failed to build.
    z*Building wheels for collected packages: %sz, c                 s   s   � | ]}|j V  qd S )N©r)   ©Ú.0r-   r"   r"   r#   Ú	<genexpr>I  s   € zbuild.<locals>.<genexpr>NzSuccessfully built %sú c                 S   ó   g | ]}|j ‘qS r"   ry   rz   r"   r"   r#   Ú
<listcomp>`  ó    zbuild.<locals>.<listcomp>zFailed to build %sc                 S   r~   r"   ry   rz   r"   r"   r#   r   e  r€   )r'   r(   rk   r   rE   rb   r   r   r5   Ú	file_pathÚlocal_file_pathr&   Úappend)
ÚrequirementsrC   r^   r_   r`   Úbuild_successesÚbuild_failuresr-   r@   Ú
wheel_filer"   r"   r#   Úbuild6  s@   þ


ÿ
ôþþþrˆ   )IÚ__doc__ÚloggingÚos.pathrH   Úrerl   Útypingr   r   r   r   r   r   Úpip._vendor.packaging.utilsr   r	   Zpip._vendor.packaging.versionr
   r   Úpip._internal.cacher   Úpip._internal.exceptionsr   r   Úpip._internal.metadatar   Úpip._internal.models.linkr   Úpip._internal.models.wheelr   Ú$pip._internal.operations.build.wheelr   Ú+pip._internal.operations.build.wheel_legacyr   Zpip._internal.req.req_installr   Úpip._internal.utils.loggingr   Úpip._internal.utils.miscr   r   r   Ú$pip._internal.utils.setuptools_buildr   Úpip._internal.utils.subprocessr   Úpip._internal.utils.temp_dirr   Úpip._internal.utils.urlsr   Úpip._internal.vcsr   Ú	getLoggerÚ__name__r'   ÚcompileÚ
IGNORECASEr   r   ÚBinaryAllowedPredicateÚBuildResultr$   r0   r3   r4   r?   rE   r2   rW   rb   r\   rp   rˆ   r"   r"   r"   r#   Ú<module>   sN     
	0	
! #;