a
    3g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 ZAeBe?dddZCd8e%e?e
e@ e?dddZDe%e?ddd ZEe%e@e?d!d"d#ZFe%e
e? dd$d%ZGe%eeBd&d'd(ZHe%eBdd)d*d+ZIe%eBe?e	eB e	eB e?e
eB d,d-d.ZJe%eBe	eB e	eB e?e
eB d/d0d1ZKe%e	eB e?d2d3d4ZLee% ee?e	eB e	eB eAd5d6d7ZMdS )9z;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&   i/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/pip/_internal/wheel_builder.py_contains_egg_info*   s    r(   )req
need_wheelcheck_bdist_wheelr"   c                 C   s   | j r
dS | jr&|r"td| j dS |r.dS | js8dS | jrF|  S | jrPdS |dus\J || snt	| _
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   )r)   r"   c                 C   s   t | ddS )NT)r*   r6   )r)   r&   r&   r'   should_build_for_wheel_commandf   s    r8   )r)   check_bdist_wheel_allowedr"   c                 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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
|rd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   )r)   wheel_cacher"   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_dirr;   rE   get_path_for_linkget_ephem_path_for_link)r)   rF   cache_availablerG   r&   r&   r'   _get_cache_dir   s    

rK   )r)   
wheel_pathr"   c           	      C   s   t | jp
d}ttj|}t |j|kr>td||jtt	||}t
|j}t|t|jkrztd||j|j}|d u rtdzt|}W n$ ty   d| }t|Y n0 |tdkrt|jtstd|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\   )r)   
output_dirverifybuild_optionsglobal_optionsr2   r"   c           	   
   C   s   |rdnd}zt | W n8 tyP } z td|| j| W Y d}~dS d}~0 0 | j  t| ||||}W d   n1 s~0    Y  |r|rz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.
    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   s,    
"rh   )r)   r]   r_   r`   r2   r"   c                 C   s  t ddl}| jsJ | jr| js(J | js2J |rDtd| j |rVtd| j |rtt| j| j| j|jd}qt	| j| j| j|jd}nt
| j| j| j|||jd}|d urVtj|}tj||}zPt|\}	}
t|| td| j||
|	  td| |W W  d    S  tyT } ztd	| j| W Y d }~n
d }~0 0 | jsht| | W d    d S 1 s0    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      st    


	

re   )r)   r`   r"   c                 C   sZ   t | j|d}td| j zt|d| jd W dS  tyT   td| j Y dS 0 d S )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   )requirementsrF   r^   r_   r`   r"   c           
   	   C   s2  | sg g fS t dddd | D  t  g g  }}| D ]}|jsLJ t||}t||||||jol|j}	|	r|j	dur|
||j	 tt|	|_|jj|_|jjsJ || q>|| q>W d   n1 s0    Y  |rt dddd	 |D  |r*t 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      zbuild.<locals>.<genexpr>NzSuccessfully built %s c                 S   s   g | ]
}|j qS r&   r   r   r&   r&   r'   
<listcomp>v  r   zbuild.<locals>.<listcomp>zFailed to build %sc                 S   s   g | ]
}|j qS 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  sL    





*r   )N)N__doc__logging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   
 5
!'G