a
    ‡Ààgq.  ã                   @   sü  d 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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l(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ e)�rxddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z: e2e:ge;f Z<e6e4e: e4e: f Z=e >e?¡Z@e AdejB¡ZCdd„ ZDdd„ ZEdd„ ZFdd „ ZGd!d"„ ZHd#d$„ ZId%d&„ ZJd'd(„ ZKd)d*„ ZLd+d,„ ZMd-d.„ ZNd/d0„ ZOd1d2„ ZPdS )3z;Orchestrator for building wheels from InstallRequirements.
é    N)Úcanonicalize_nameÚcanonicalize_version)ÚInvalidVersionÚVersion)Úparse)ÚDistribution)ÚInvalidWheelFilenameÚUnsupportedWheel)ÚLink)ÚWheel)Úbuild_wheel_pep517)Úbuild_wheel_legacy)Ú
indent_log)Ú
ensure_dirÚ	hash_fileÚis_wheel_installed)Úmake_setuptools_clean_args)Úcall_subprocess)ÚTempDirectory)ÚMYPY_CHECK_RUNNING)Úpath_to_url)Ú$pkg_resources_distribution_for_wheel)Úvcs)ÚAnyÚCallableÚIterableÚListÚOptionalÚTuple)Ú
WheelCache)ÚInstallRequirementz([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
    )ÚboolÚ_egg_info_reÚsearch)Ús© r%   úT/var/www/sistema_ama/venv/lib/python3.9/site-packages/pip/_internal/wheel_builder.pyÚ_contains_egg_info,   s    r'   c                 C   sz   | j r
dS | jr&|r"t d| j¡ dS |r.dS | js:| js>dS || ƒsXt d| j¡ dS | jsvtƒ svt 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.)	Ú
constraintÚis_wheelÚloggerÚinfoÚnameÚeditableÚ
source_dirÚ
use_pep517r   )ÚreqÚ
need_wheelÚcheck_binary_allowedr%   r%   r&   Ú_should_build5   s2    ÿþþr3   c                 C   s   t | dtd�S )NT©r1   r2   )r3   Ú_always_true)r0   r%   r%   r&   Úshould_build_for_wheel_commandb   s    ÿr6   c                 C   s   t | d|d�S )NFr4   )r3   )r0   r2   r%   r%   r&   Ú should_build_for_install_commandk   s    ÿr7   c                 C   sŠ   | j s| jsdS | jrb| jjrb| j r(J ‚| js2J ‚t | jj¡}|sHJ ‚| | jj| j¡r^dS dS | jslJ ‚| j 	¡ \}}t
|ƒr†d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.
    FT)r-   r.   ÚlinkÚis_vcsr   Úget_backend_for_schemeÚschemeÚis_immutable_rev_checkoutÚurlÚsplitextr'   )r0   Úvcs_backendÚbaseÚextr%   r%   r&   Ú_should_cacheu   s    	


rB   c                 C   s>   t |jƒ}| jsJ ‚|r.t| ƒr.| | j¡}n| | j¡}|S )zdReturn the persistent or temporary cache directory where the built
    wheel need to be stored.
    )r!   Ú	cache_dirr8   rB   Úget_path_for_linkÚget_ephem_path_for_link)r0   Úwheel_cacheZcache_availablerC   r%   r%   r&   Ú_get_cache_dir–   s    

rG   c                 C   s   dS )NTr%   )Ú_r%   r%   r&   r5   §   s    r5   c              	   C   st   |   | j¡D ]Z}| ¡  d¡r| dd¡d  ¡ }zt|ƒW   S  tyd   d |¡}t	|ƒ‚Y q0 qt	dƒ‚d S )Nzmetadata-version:ú:é   éÿÿÿÿzInvalid Metadata-Version: {}zMissing Metadata-Version)
Úget_metadata_linesÚPKG_INFOÚlowerÚ
startswithÚsplitÚstripr   r   Úformatr	   )ÚdistÚlineÚvalueÚmsgr%   r%   r&   Ú_get_metadata_version¬   s    
rW   c                 C   sÐ   t | jƒ}ttj |¡ƒ}t |jƒ|kr:td ||j¡ƒ‚tj	|dd��}t
|||ƒ}W d   ƒ n1 sj0    Y  t|jƒt|jƒkrœtd |j|j¡ƒ‚t|ƒtdƒkrÌtt|jƒtƒsÌtd |j¡ƒ‚d S )Nz7Wheel has unexpected file name: expected {!r}, got {!r}T)Ú
allowZip64z1.2z6Metadata 1.2 mandates PEP 440 version, but {!r} is not)r   r,   r   ÚosÚpathÚbasenamer   rR   ÚzipfileÚZipFiler   r   ÚversionrW   r   Ú
isinstanceÚparse_versionr	   )r0   Ú
wheel_pathÚcanonical_nameÚwÚzfrS   r%   r%   r&   Ú_verify_one¹   s4    
ÿÿÿ"ÿÿÿÿÿre   c              
   C   sÎ   zt |ƒ W n6 tyB } zt d| j|¡ W Y d}~dS d}~0 0 | j� t| |||ƒ}W d  ƒ n1 sn0    Y  |rÊ|rÊzt| |ƒ W n: tt	fyÈ } zt d| j|¡ W Y d}~dS d}~0 0 |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_envre   r   r	   )r0   Ú
output_dirÚverifyÚbuild_optionsÚglobal_optionsÚera   r%   r%   r&   Ú
_build_oneÓ   s&    þÿ"rp   c                 C   sD  t dd���"}| jsJ ‚| jrD| js(J ‚t| j| j| j||jd�}nt| j| j| j	|||jd�}|d u�rt
j |¡}t
j ||¡}zPt|ƒ\}}	t ||¡ t d| j||	| ¡ ¡ t d|¡ |W W  d   ƒ S  t�y
 }
 zt d| j|
¡ W Y d }
~
n
d }
~
0 0 | j�st| |ƒ W d   ƒ d S 1 �s60    Y  d S )NÚwheel)Úkind)r,   ÚbackendÚmetadata_directoryrm   Útempd)r,   Úsetup_py_pathr.   rn   rm   ru   z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %srf   )r   r,   r/   rt   r   Úpep517_backendrZ   r   rv   Úunpacked_source_directoryrY   r[   Újoinr   ÚshutilÚmover*   r+   Ú	hexdigestÚ	Exceptionrh   Ú_clean_one_legacy)r0   rk   rm   rn   Útemp_dirra   Ú
wheel_nameÚ	dest_pathZ
wheel_hashÚlengthro   r%   r%   r&   rj   ö   sN    

ûú	
ýþ
rj   c                 C   sX   t | j|d�}t d| j¡ zt|| jd� W dS  tyR   t d| j¡ Y dS 0 d S )N)rn   zRunning setup.py clean for %s)ÚcwdTz Failed cleaning build dir for %sF)	r   rv   r*   r+   r,   r   r.   r}   Úerror)r0   rn   Z
clean_argsr%   r%   r&   r~   )  s    þr~   c           
      C   s  | sg g fS t  dd dd„ | D ƒ¡¡ tƒ �| g g  }}| D ]\}t||ƒ}t|||||ƒ}	|	r�tt|	ƒƒ|_|jj	|_
|jjs„J ‚| |¡ q>| |¡ q>W d  ƒ n1 s°0    Y  |rÚt  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,   ©Ú.0r0   r%   r%   r&   Ú	<genexpr>L  ó    zbuild.<locals>.<genexpr>NzSuccessfully built %sú c                 S   s   g | ]
}|j ‘qS r%   r…   r†   r%   r%   r&   Ú
<listcomp>c  r‰   zbuild.<locals>.<listcomp>zFailed to build %sc                 S   s   g | ]
}|j ‘qS r%   r…   r†   r%   r%   r&   r‹   h  r‰   )r*   r+   ry   r   rG   rp   r
   r   r8   Ú	file_pathÚlocal_file_pathr)   Úappend)
ÚrequirementsrF   rl   rm   rn   Zbuild_successesÚbuild_failuresr0   rC   Z
wheel_filer%   r%   r&   Úbuild9  s<    þ


ÿ
*þþr‘   )QÚ__doc__ÚloggingÚos.pathrY   Úrerz   r\   Úpip._vendor.packaging.utilsr   r   Zpip._vendor.packaging.versionr   r   r   r`   Zpip._vendor.pkg_resourcesr   Úpip._internal.exceptionsr   r	   Úpip._internal.models.linkr
   Úpip._internal.models.wheelr   Z$pip._internal.operations.build.wheelr   Z+pip._internal.operations.build.wheel_legacyr   Ú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.typingr   Úpip._internal.utils.urlsr   Úpip._internal.utils.wheelr   Úpip._internal.vcsr   Útypingr   r   r   r   r   r   Úpip._internal.cacher   Úpip._internal.req.req_installr    r!   ÚBinaryAllowedPredicateZBuildResultÚ	getLoggerÚ__name__r*   ÚcompileÚ
IGNORECASEr"   r'   r3   r6   r7   rB   rG   r5   rW   re   rp   rj   r~   r‘   r%   r%   r%   r&   Ú<module>   sX    
	-	
!#3