o
    a+)h3                     @   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 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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( ddl)m*Z* ddl+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 e9e:Z;e<dej=Z>ee%ge?f Z@ee	e% e	e% f ZAdeBde?fddZC	d<de%de?de
e@ de?fdd ZDde%de?fd!d"ZEde%d#e@de?fd$d%ZFde%de
e? fd&d'ZGde%d(edeBfd)d*ZHde%d+eBddfd,d-ZIde%d.eBd/e?d0e	eB d1e	eB d2e?de
eB fd3d4ZJde%d.eBd0e	eB d1e	eB d2e?de
eB fd5d6ZKde%d1e	eB de?fd7d8ZLd9ee% d(ed/e?d0e	eB d1e	eB deAfd:d;ZMdS )=z;Orchestrator for building wheels from InstallRequirements.
    N)CallableIterableListOptionalTuple)canonicalize_namecanonicalize_version)InvalidVersionVersion)
WheelCache)InvalidWheelFilenameUnsupportedWheel)FilesystemWheelget_wheel_distribution)Link)Wheel)build_wheel_pep517)build_wheel_editable)build_wheel_legacy)InstallRequirement)&LegacyInstallReasonMissingWheelPackage2LegacyInstallReasonNoBinaryForcesSetuptoolsInstall)
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_.!+-]+)sreturnc                 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)r!    r&   ZC:\Users\User\Downloads\Proyecto_IoT\venv\Lib\site-packages\pip/_internal/wheel_builder.py_contains_egg_info*   s   r(   req
need_wheelcheck_bdist_wheelc                 C   s   | j rdS | jr|rtd| j dS |rdS | jsdS | jr#|  S | jr(dS |dus.J || s7t	| _
dS t s?t| _
dS dS )zBReturn whether an InstallRequirement should be built into a wheel.Fz(Skipping %s, due to already being wheel.TN)
constraintis_wheelloggerinfoname
source_direditablesupports_pyproject_editable
use_pep517r   legacy_install_reasonr   r   )r)   r*   r+   r&   r&   r'   _should_build2   s2   r6   c                 C   s   t | ddS )NT)r*   r6   )r)   r&   r&   r'   should_build_for_wheel_commandf   s   r8   check_bdist_wheel_allowedc                 C   s   t | d|dS )NF)r*   r+   r7   )r)   r9   r&   r&   r'    should_build_for_install_commandl   s   r:   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.
    FT)r2   r1   linkis_vcsr    get_backend_for_schemeschemeis_immutable_rev_checkouturlsplitextr(   )r)   vcs_backendbaseextr&   r&   r'   _should_cacheu   s   


rE   wheel_cachec                 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.
    )r#   	cache_dirr;   rE   get_path_for_linkget_ephem_path_for_link)r)   rF   cache_availablerG   r&   r&   r'   _get_cache_dir   s   

rK   
wheel_pathc           	      C   s   t | jpd}ttj|}t |j|krtd||jtt	||}t
|j}t|t|jkr=td||j|j}|d u rHtdzt|}W n ty^   d| }t|w |tdkrrt|jtstt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   r0   r   ospathbasenamer   formatr   r   strversionr   metadata_versionr   r
   r	   
isinstance)	r)   rL   canonical_namewdistdist_verstrmetadata_version_valuerT   msgr&   r&   r'   _verify_one   s:   



r\   
output_dirverifybuild_optionsglobal_optionsr2   c           	   
   C   s   |rdnd}zt | W n ty( } ztd|| j| W Y d}~dS d}~ww | j t| ||||}W d   n1 s?w   Y  |ro|rozt| | W |S  tt	fyn } 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.
    r2   wheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s)
r   OSErrorr.   warningr0   	build_env_build_one_inside_envr\   r   r   )	r)   r]   r^   r_   r`   r2   artifacterL   r&   r&   r'   
_build_one   s8   

rh   c                 C   s  t dd}| jsJ | jrF| jsJ | jsJ |r!td| j |r*td| j |r9t| j| j| j|jd}nt	| j| j| j|jd}nt
| j| j| j|||jd}|d urt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st| | 	 W d    d S 1 sw   Y  d S )
Nra   )kindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r0   backendmetadata_directorytempd)r0   setup_py_pathr1   r`   r_   rl   z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)r   r0   r4   rk   pep517_backendr.   rc   r   rO   r   r   rm   unpacked_source_directoryrN   rP   joinr   shutilmover/   	hexdigest	Exception_clean_one_legacy)r)   r]   r_   r`   r2   temp_dirrL   
wheel_name	dest_path
wheel_hashlengthrg   r&   r&   r'   re      s|   


	4
$re   c                 C   sV   t | j|d}td| j zt|d| jd W dS  ty*   td| j Y dS w )N)r`   zRunning setup.py clean for %szpython setup.py clean)command_desccwdTz Failed cleaning build dir for %sF)	r   rm   r.   r/   r0   r   r1   rt   error)r)   r`   
clean_argsr&   r&   r'   ru   0  s   ru   requirementsc           
   	   C   s.  | sg g fS t dddd | D  t T g g }}| D ]D}|js&J t||}t||||||jo6|j}	|	r^|j	durF|
||j	 tt|	|_|jj|_|jjsXJ || q|| qW d   n1 snw   Y  |rt dddd	 |D  |rt d
ddd	 |D  ||fS )zBuild 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r0   .0r)   r&   r&   r'   	<genexpr>S  s    zbuild.<locals>.<genexpr>NzSuccessfully built %s c                 S      g | ]}|j qS r&   r   r   r&   r&   r'   
<listcomp>v      zbuild.<locals>.<listcomp>zFailed to build %sc                 S   r   r&   r   r   r&   r&   r'   r   {  r   )r.   r/   rp   r   r0   rK   rh   r2   permit_editable_wheelsdownload_inforecord_download_originr   r   r;   	file_pathlocal_file_pathr-   append)
r   rF   r^   r_   r`   build_successesbuild_failuresr)   rG   
wheel_filer&   r&   r'   buildA  sP   





r   r   )N__doc__loggingZos.pathrN   rerq   typingr   r   r   r   r   Zpip._vendor.packaging.utilsr   r   Zpip._vendor.packaging.versionr	   r
   pip._internal.cacher   pip._internal.exceptionsr   r   pip._internal.metadatar   r   pip._internal.models.linkr   pip._internal.models.wheelr   $pip._internal.operations.build.wheelr   -pip._internal.operations.build.wheel_editabler   +pip._internal.operations.build.wheel_legacyr   Zpip._internal.req.req_installr   pip._internal.utils.deprecationr   r   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#   BdistWheelAllowedPredicateBuildResultrR   r(   r6   r8   r:   rE   rK   r\   rh   re   ru   r   r&   r&   r&   r'   <module>   s    

4

	
 

&
G