o
    Ëý°j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?de@de=fdd„ZAde&de=de>de=fdd„ZBde&de=fd d!„ZCde&de>de=fd"d#„ZDde&dee= fd$d%„ZEde&d&ede@fd'd(„ZFd)ede=fd*d+„ZGde&d,e@ddfd-d.„ZHde&d/e@d0e=d1e
e@ d2e
e@ d3e=dee@ fd4d5„ZIde&d/e@d1e
e@ d2e
e@ d3e=dee@ fd6d7„ZJde&d2e
e@ de=fd8d9„ZKd:e	e& d&ed0e=d1e
e@ d2e
e@ de?fd;d<„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%   úŽ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/wheel_builder.pyÚ_contains_egg_info&   s   r'   ÚreqÚ
need_wheelÚcheck_binary_allowedc                 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 || ƒs5t d| j¡ dS t	ƒ sAt 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   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   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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)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   Ú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_dirr9   rC   Úget_path_for_linkÚget_ephem_path_for_link)r(   rD   Úcache_availablerE   r%   r%   r&   Ú_get_cache_dir’   s   

ÿrI   Ú_c                 C   s   dS )NTr%   )rJ   r%   r%   r&   r6   ¢   s   r6   Ú
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   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[   Ú
output_dirÚverifyÚbuild_optionsÚglobal_optionsr1   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.
    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Ä   s8   ü€ù

ÿÿý€þrg   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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 )
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   ê   s|   


ÿÿüüú	ûÍ4ý€ÿ
$Ãrd   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   rl   r-   r.   r/   r   r0   rs   Úerror)r(   r_   Ú
clean_argsr%   r%   r&   rt   1  s   þÿþrt   Úrequirementsc           
   	   C   s  | sg g fS t  dd dd„ | D ƒ¡¡ tƒ �H g g }}| D ]8}|js&J ‚t||ƒ}t||||||jo6|jƒ}	|	rRt	t
|	ƒƒ|_|jj|_|jjsLJ ‚| |¡ q| |¡ qW d  ƒ n1 sbw   Y  |rwt  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  s   € zbuild.<locals>.<genexpr>NzSuccessfully built %sú c                 S   ó   g | ]}|j ‘qS r%   r   r€   r%   r%   r&   Ú
<listcomp>q  ó    zbuild.<locals>.<listcomp>zFailed to build %sc                 S   r„   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  sL   þ



ú
îþþþrŽ   )MÚ__doc__ÚloggingÚos.pathrM   Úrerp   Útypingr   r   r   r   r   r   Úpip._vendor.packaging.utilsr   r	   Ú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   Ú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Ô     
ÿþý
ü5ÿ
þÿþ
ý	ÿ
þ ÿþ
ýÿþýüûú
ù&ÿþýüû
úGÿþýüûú