a
    hbòf0  ã                   @   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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/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 e 7e8¡Z9e :dej;¡Z<ee&ge=f Z>ee
e& e
e& f Z?e@e=dœdd„ZAe&e=e>e=dœdd„ZBe&e=dœdd„ZCe&e>e=d œd!d"„ZDe&ee= dœd#d$„ZEe&ee@d%œd&d'„ZFee=d(œd)d*„ZGe&e@dd+œd,d-„ZHe&e@e=e
e@ e
e@ e=ee@ d.œd/d0„ZIe&e@e
e@ e
e@ e=ee@ d1œd2d3„ZJe&e
e@ e=d4œd5d6„ZKe	e& ee=e
e@ e
e@ e?d7œd8d9„ZLdS ):z;Orchestrator for building wheels from InstallRequirements.
é    N)ÚAnyÚ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)Ú
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%   úX/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_internal/wheel_builder.pyÚ_contains_egg_info&   s    r'   )ÚreqÚ
need_wheelÚcheck_binary_allowedr!   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 || ƒsjt 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.)
Ú
constraintÚis_wheelÚloggerÚinfoÚnameÚ
source_dirÚeditableÚsupports_pyproject_editableÚ
use_pep517r   )r(   r)   r*   r%   r%   r&   Ú_should_build.   s<    þþýr4   )r(   r!   c                 C   s   t | dtd�S )NT©r)   r*   )r4   Ú_always_true)r(   r%   r%   r&   Úshould_build_for_wheel_commandc   s    r7   )r(   r*   r!   c                 C   s   t | d|d�S )NFr5   )r4   )r(   r*   r%   r%   r&   Ú should_build_for_install_commandi   s    ÿr8   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)r1   r0   ÚlinkÚis_vcsr   Úget_backend_for_schemeÚschemeÚis_immutable_rev_checkoutÚurlÚsplitextr'   )r(   Úvcs_backendÚbaseÚextr%   r%   r&   Ú_should_cacher   s    


rC   )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_dirr9   rC   Úget_path_for_linkÚget_ephem_path_for_link)r(   rD   Úcache_availablerE   r%   r%   r&   Ú_get_cache_dir’   s    

rI   )Ú_r!   c                 C   s   dS )NTr%   )rJ   r%   r%   r&   r6   ¢   s    r6   )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 r�tdƒ‚zt|ƒ}W n$ tyÀ   d|› �}t|ƒ‚Y n0 |tdƒkrèt|jtƒsèt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   r/   r   ÚosÚpathÚbasenamer   Úformatr   r   ÚstrÚversionr	   Úmetadata_versionr   r   r
   Ú
isinstance)	r(   rK   Úcanonical_nameÚwÚdistÚdist_verstrÚmetadata_version_valuerS   Úmsgr%   r%   r&   Ú_verify_one¦   s<    ÿÿ
ÿÿ
ÿÿr[   )r(   Ú
output_dirÚverifyÚbuild_optionsÚglobal_optionsr1   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Ü|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.
    r1   ÚwheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s)
r   ÚOSErrorr-   Úwarningr/   Ú	build_envÚ_build_one_inside_envr[   r   r   )	r(   r\   r]   r^   r_   r1   ÚartifactÚerK   r%   r%   r&   Ú
_build_oneÄ   s,    ü
ÿ"rg   )r(   r\   r^   r_   r1   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�}qªt	| 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 �s€0    Y  d S )
Nr`   )Ú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_pathr0   r_   r^   rk   z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)r   r/   r3   rj   Úpep517_backendr-   rb   r   rN   r   r   rl   Úunpacked_source_directoryrM   rO   Újoinr   ÚshutilÚmover.   Ú	hexdigestÚ	ExceptionÚ_clean_one_legacy)r(   r\   r^   r_   r1   Útemp_dirrK   Ú
wheel_nameÚ	dest_pathÚ
wheel_hashÚlengthrf   r%   r%   r&   rd   ê   st    


ÿÿüüú	
ûý
rd   )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   rl   r-   r.   r/   r   r0   rs   Úerror)r(   r_   Ú
clean_argsr%   r%   r&   rt   1  s    þÿrt   )ÚrequirementsrD   r]   r^   r_   r!   c           
   	   C   s  | sg g fS t  dd dd„ | D ƒ¡¡ tƒ �� g g  }}| D ]p}|jsLJ ‚t||ƒ}t||||||jol|jƒ}	|	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/   ©Ú.0r(   r%   r%   r&   Ú	<genexpr>T  ó    zbuild.<locals>.<genexpr>NzSuccessfully built %sú c                 S   s   g | ]
}|j ‘qS r%   r   r€   r%   r%   r&   Ú
<listcomp>q  rƒ   zbuild.<locals>.<listcomp>zFailed to build %sc                 S   s   g | ]
}|j ‘qS r%   r   r€   r%   r%   r&   r…   v  rƒ   )r-   r.   ro   r   r/   rI   rg   r1   Úpermit_editable_wheelsr   r   r9   Ú	file_pathÚlocal_file_pathr,   Úappend)
r~   rD   r]   r^   r_   Úbuild_successesÚbuild_failuresr(   rE   Ú
wheel_filer%   r%   r&   ÚbuildB  sH    þ



ú
*þþr�   )MÚ__doc__ÚloggingÚos.pathrM   Úrerp   Ú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   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.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ÚBuildResultrQ   r'   r4   r7   r8   rC   rI   r6   r[   rg   rd   rt   r�   r%   r%   r%   r&   Ú<module>   s�    
	ü6þý
þ!ýù'úGú