o
    Ô­j�,  ã                   @   sd  d dl Z d dlZd dlZd dlmZmZ d dlmZmZ d dl	Z
d dlmZ d dlmZmZmZ d dlmZmZ d dlmZmZmZ d dlmZ d d	lmZmZ d d
lmZ ze
j d¡dkrfejddd� W n e
jjyr   Y nw d#dd„Z da!t!a"dZ#dd„ Z$e$ƒ Z%G dd„ deƒZ&G dd„ de&ƒZ'G dd„ de&ƒZ(G dd„ de&ƒZ)G dd „ d ƒZ*d!d"„ Z+dS )$é    N)ÚmkstempÚmkdtemp)ÚPopenÚPIPE)ÚDistutilsError)Úassert_Úassert_equalÚassert_raises)Ú	ccompilerÚcustomized_ccompiler)Úsystem_infoÚConfigParserÚmkl_info)ÚAliasedOptionError)Údefault_lib_dirsÚdefault_include_dirs)Ú_shell_utilsÚ
setuptoolsÚ60zsetuptools is too newT)Úallow_module_levelé   c                 C   s   t ttdœ |  ¡ t¡}|ƒ S )zg
    notfound_action:
      0 - do nothing
      1 - display warning message
      2 - raise error
    )Útemp1Útemp2Úduplicate_options)Ú	Temp1InfoÚ	Temp2InfoÚDuplicateOptionInfoÚgetÚlowerÚ_system_info)ÚnameÚnotfound_actionÚcl© r#   úc/var/www/html/CropPilot/venv/lib/python3.10/site-packages/numpy/distutils/tests/test_system_info.pyÚ	get_class   s   þýr%   a¼  
[ALL]
library_dirs = {dir1:s}{pathsep:s}{dir2:s}
libraries = {lib1:s},{lib2:s}
extra_compile_args = -I/fake/directory -I"/path with/spaces" -Os
runtime_library_dirs = {dir1:s}

[temp1]
library_dirs = {dir1:s}
libraries = {lib1:s}
runtime_library_dirs = {dir1:s}

[temp2]
library_dirs = {dir2:s}
libraries = {lib2:s}
extra_link_args = -Wl,-rpath={lib2_escaped:s}
rpath = {dir2:s}

[duplicate_options]
mylib_libs = {lib1:s}
libraries = {lib2:s}
z·
/* This file is generated from numpy/distutils/testing/test_system_info.py */
#include<stdio.h>
void foo(void) {
   printf("Hello foo");
}
void bar(void) {
   printf("Hello bar");
}
c                  C   s    t ƒ } z| j}W n$ ty,   z	| js|  ¡  W n ttfy%   Y Y dS w | jg}Y nw zt|t	t	d�}|j
 ¡  |j ¡  | ¡  W dS  tyO   Y dS w )z? Return True if there appears to be an executable compiler
    F)ÚstdoutÚstderrT)r   ÚcompilerÚAttributeErrorÚinitializedÚ
initializer   Ú
ValueErrorÚccr   r   r&   Úcloser'   ÚwaitÚOSError)r(   ÚcmdÚpr#   r#   r$   Úhave_compilerK   s,   
€ÿú


þÿr3   c                   @   s$   e Zd Zeedfdd„Zdd„ ZdS )r   r   c              	   C   s2   i | j _g | _dddddddddœ}t|ƒ| _d S )NÚ Ú0)Úlibrary_dirsÚinclude_dirsÚruntime_library_dirsÚrpathÚsrc_dirsÚsearch_static_firstÚextra_compile_argsÚextra_link_args)Ú	__class__ÚinfoÚlocal_prefixesr   Úcp)Úselfr   r   Ú	verbosityÚdefaultsr#   r#   r$   Ú__init__g   s   ùz_system_info.__init__c                 C   s   ||dœ}|S )z-Override _check_libs to return with all dirs )Ú	librariesr6   r#   )rB   Úlib_dirsÚlibsÚopt_libsÚextsr?   r#   r#   r$   Ú_check_libsz   s   
z_system_info._check_libsN)Ú__name__Ú
__module__Ú__qualname__r   r   rE   rK   r#   r#   r#   r$   r   e   s    
ýr   c                   @   ó   e Zd ZdZdZdS )r   úFor testing purposesr   N©rL   rM   rN   Ú__doc__Úsectionr#   r#   r#   r$   r   €   ó    r   c                   @   rO   )r   rP   r   NrQ   r#   r#   r#   r$   r   …   rT   r   c                   @   rO   )r   rP   r   NrQ   r#   r#   r#   r$   r   ‰   rT   r   c                   @   sº   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Ze	j
je dd�dd„ ƒZe	j
je dd�e	j
jdee ¡ ƒv dd�dd„ ƒƒZdeƒ  ¡  dg ¡v Ze	j
jedd�dd„ ƒZdS )ÚTestSystemInfoReadingc                 C   s˜  t ƒ | _tj | jd¡| _tj | jd¡| _t ƒ | _tj | jd¡| _tj | jd¡| _	t
jdi | j| j| j| j	tjtj | j	g¡dœ¤Žatƒ \}| _t |¡ t| jdƒ�}| t¡ W d  ƒ n1 sgw   Y  t| jdƒ�}| t¡ W d  ƒ n1 s‚w   Y  t| jdƒ�}| t¡ W d  ƒ n1 s�w   Y  dd	„ }|td
ƒ| jƒ| _|tdƒ| jƒ| _|tdƒ| jƒ| _|tdƒ| jƒ| _dS )z Create the libraries zfoo.cz	libfoo.sozbar.cz	libbar.so)Údir1Úlib1Údir2Úlib2ÚpathsepÚlib2_escapedÚwNc                 S   s   |g| _ |  ¡  | S ©N)ÚfilesÚparse_config_files)ÚcÚsite_cfgr#   r#   r$   Úsite_and_parse¯   s   z:TestSystemInfoReading.setup_method.<locals>.site_and_parseÚdefaultr   r   r   r#   )r   Ú_dir1ÚosÚpathÚjoinÚ_src1Ú_lib1Ú_dir2Ú_src2Ú_lib2Úsimple_siteÚformatrZ   r   ÚNativeParserra   r   Ú_sitecfgr.   ÚopenÚwriteÚfakelib_c_textr%   Ú	c_defaultÚc_temp1Úc_temp2Úc_dup_options)rB   Úfdrb   r#   r#   r$   Úsetup_method�   s@   
ú	
ÿÿÿ
ÿz"TestSystemInfoReading.setup_methodc                 C   sp   zt  | j¡ W n	 ty   Y nw zt  | j¡ W n	 ty#   Y nw z	t | j¡ W d S  ty7   Y d S w r]   )ÚshutilÚrmtreerd   Ú	Exceptionrj   re   Úremoverp   )rB   r#   r#   r$   Úteardown_method¹   s   ÿÿÿz%TestSystemInfoReading.teardown_methodc                 C   sb   | j }t| ¡ | j| jgƒ t| ¡ | j| jgƒ t| ¡ | jgƒ | 	¡ }t|d g d¢ƒ d S )Nr<   )z-I/fake/directoryz-I/path with/spacesz-Os)
rt   r   Úget_lib_dirsrd   rj   Úget_librariesri   rl   Úget_runtime_lib_dirsÚcalc_extra_info©rB   ÚtsiÚextrar#   r#   r$   Útest_allÈ   s   zTestSystemInfoReading.test_allc                 C   s@   | j }t| ¡ | jgƒ t| ¡ | jgƒ t| ¡ | jgƒ d S r]   )ru   r   r   rd   r€   ri   r�   ©rB   r„   r#   r#   r$   Ú
test_temp1Ñ   s   z TestSystemInfoReading.test_temp1c                 C   sb   | j }t| ¡ | jgƒ t| ¡ | jgƒ t|jdd�| jgƒ | ¡ }t|d d| j gƒ d S )Nr9   )Úkeyr=   z-Wl,-rpath=)rv   r   r   rj   r€   rl   r�   r‚   rƒ   r#   r#   r$   Ú
test_temp2Ø   s   z TestSystemInfoReading.test_temp2c                 C   sN   | j }tt|jddƒ t| d| jg¡| jgƒ t| d| jg¡| jgƒ d S )NÚ
mylib_libsrF   )rw   r	   r   Úget_option_singler   Úget_libsri   rl   r‡   r#   r#   r$   Útest_duplicate_optionsâ   s   z,TestSystemInfoReading.test_duplicate_optionszMissing compiler)Úreasonc              	   C   s„   t ƒ }t ¡ }z4t | j¡ |jtj | j¡g| jd� t	tj 
| j dd¡¡p2tj 
| j dd¡¡ƒ W t |¡ d S t |¡ w )N)Ú
output_dirú.cú.oz.obj)r   re   ÚgetcwdÚchdirrd   Úcompilerf   Úbasenamerh   r   ÚisfileÚreplace)rB   r`   ÚpreviousDirr#   r#   r$   Útest_compile1é   s   ÿz#TestSystemInfoReading.test_compile1ÚmsvczFails with MSVC compiler c              	   C   s‚   | j }tƒ }| ¡ d }t ¡ }z*t | j¡ |jtj 	| j
¡g| j|d� ttj | j
 dd¡¡ƒ W t |¡ d S t |¡ w )Nr=   )r�   Úextra_postargsr‘   r’   )rv   r   r‚   re   r“   r”   rj   r•   rf   r–   rk   r   r—   r˜   )rB   r„   r`   r=   r™   r#   r#   r$   Útest_compile2ø   s   ÿz#TestSystemInfoReading.test_compile2Úmkl_rtrF   zD`[DEFAULT]` override doesn't work if numpy is built with MKL supportc              	   C   s„  t  ¡ }t j | jd¡}t | j|¡ z¨t  | j¡ t	ƒ }|j
d d  t j¡}| ¡ |ks0J ‚t|ƒ�}| ¡  ddd¡}W d   ƒ n1 sHw   Y  t|dƒ�}| |¡ W d   ƒ n1 sbw   Y  t	ƒ }| ¡ |ksrJ ‚t|ƒ�}| ¡  ddd¡}W d   ƒ n1 sŠw   Y  t|dƒ�}| |¡ W d   ƒ n1 s¤w   Y  t	ƒ }| ¡ |ks´J ‚W t  |¡ d S t  |¡ w )	Nzsite.cfgÚALLr6   z[ALL]z[mkl]r   r\   z	[DEFAULT])re   r“   rf   rg   rd   rz   Úcopyrp   r”   r   rA   ÚsplitrZ   r   rq   Úreadr˜   rr   )rB   r™   Úcfgr?   rG   ÚfidÚmklÚdfltr#   r#   r$   Útest_overrides  s2   
ÿÿ
ÿÿz$TestSystemInfoReading.test_overridesN)rL   rM   rN   ry   r~   r†   rˆ   rŠ   rŽ   ÚpytestÚmarkÚskipifÚHAVE_COMPILERrš   Úreprr
   Únew_compilerr�   r   Úcalc_libraries_infor   ÚHAS_MKLÚxfailr§   r#   r#   r#   r$   rU   Ž   s"    )	

ÿrU   c                 C   s|  ddl m} d}tdƒ}|  |d¡ |||ƒ\}}t|ƒdks!J ‚|tdƒks)J ‚t|ƒdks1J ‚|  |d	¡ |||ƒ\}}t|ƒdksFJ ‚t|ƒdksNJ ‚d
D ]*}|  ||› d�¡ |||ƒ\}}t|ƒdksjJ ‚|tdƒksrJ ‚t|ƒdkszJ ‚qPt t¡� |  |d¡ |||ƒ W d   ƒ n1 s–w   Y  t t¡� |  |d¡ |||ƒ W d   ƒ d S 1 s·w   Y  d S )Nr   )Ú_parse_env_orderÚ#NPY_TESTS_DISTUTILS_PARSE_ENV_ORDERÚabcdefzb,i,e,fé   Úbefr   r4   z^!zb,i,eé   Úacdfzb,^e,iz!b,^e,i)Únumpy.distutils.system_infor±   ÚlistÚsetenvÚlenr¨   Úraisesr,   )Úmonkeypatchr±   ÚenvÚ
base_orderÚorderÚunknownÚprefixr#   r#   r$   Útest_distutils_parse_env_order/  s4   þ"þrÃ   )r   ),re   rz   r¨   Útempfiler   r   Ú
subprocessr   r   Úimportlib.metadataÚ	importlibÚdistutils.errorsr   Únumpy.testingr   r   r	   Únumpy.distutilsr
   r   r¸   r   r   r   r   r   r   r   ÚmetadataÚversionÚskipÚPackageNotFoundErrorr%   rm   ra   rs   r3   r«   r   r   r   r   rU   rÃ   r#   r#   r#   r$   Ú<module>   sB    €þ
 "