a
    |Ä#d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)Ú&LegacyInstallReasonMissingWheelPackageÚ2LegacyInstallReasonNoBinaryForcesSetuptoolsInstall)Ú
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&   úR/var/www/html/gsl.tools/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
|ƒ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)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 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   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Ü|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.
    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�}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 )
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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©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ú