
    -PhO9                       d dl mZ ddlmZ d dlZeej        d<   d dlZd dlZd dl	Z	d dl
Z
d dlZddlmZmZ ddlmZ ddZ G d d          ZddZd dZd!dZd Zd"dZd#dZedk    r ej         e                       dS dS )$    )annotations   )_pathlibNpathlib)MesonExceptionMesonBugException)mloge	Exceptioncommandstrreturnintc                f    dd l }t           t                    rt          j                    t          j                    }|nt          j        dt          j        |                     t          j        |dt          j
                            |           d          }|rt          |           t          j                            d          r dS t          j                            d          r |                                 |dk    rdS t           t                     r(t          j        t#          d	                      j        S d
}t'           fddD                       r"t)          | j         j         j                   nt)          |           t          j                    dS )Nr   z
A full log can be found atz%CI platform detected, click here for z
 contents.MESON_FORCE_BACKTRACEr   	runpython   zeUnhandled python OSError. This is probably not a Meson bug, but an issue with your build environment.zUnhandled python exceptionc              3  >   K   | ]}t          |d           d uV  d S N)getattr).0ar
   s     T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mesonbuild/mesonmain.py	<genexpr>zerrorhandler.<locals>.<genexpr>7   s4      XXq71a&&d2XXXXXX    )filelinenocolno)	traceback
isinstancer   r	   	exceptionshutdownlogboldci_fold_fileospathbasenameprintenvironget	print_excOSErrorr   errnoallr   r   r   r   )r
   r   r   logfilecontentsmsgs   `     r   errorhandlerr3      s   !^$$ #q-//H3TYw5G5GHHH(2Z\ZaZjZjkrZsZs222  A  AH  h:>>122 	Gq :>>122 	Gk!!17## 
	N9 &G H H I I I7N.CXXXX<WXXXXX +%c1618QWEE%c**N1qr   c                  J    e Zd ZddZ	 dddZddZddZddZddZddZ	dS ) CommandLineParserr   Nonec                p    ddl m}m}m}m}m}m}m}mm	}m
}	m}
m}m} ddlm}m} ddlm} dd l}|                                j         _         fd _        i  _        g  _        t5          j        d j                   _         j                            d	d
d           _                             d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d|j         |j!        d                                d  fd!j!        d"                                d#|
j         |
j!        d$                                d%|j         |j!        d&                                d'|j         |j!        d(                                d)|j         |j!        d*                                d+|j         |j!        d,gd-.                                d/ j"         j#        d0                                d1 j$         j%        t4          j&                                        d2|	j         |	j!        t4          j&                   d S )3Nr   )mconfmdistminitminstallmintromsetupmtestrewritermsubprojectsmunstable_coredatamcompilemdevenvmformat)	env2mfile	reprotest)wraptoolr   c                f    t          j        | t          j        dz            j                  S )Nr   )max_help_positionwidth)argparseHelpFormatterr   
term_width)progselfs    r   <lambda>z,CommandLineParser.__init__.<locals>.<lambda>I   s=    h&<TUXY]YhklYlUmUmuy  vE  'F  'F  'F r   mesonrN   formatter_classCommandsr   z8If no command is specified it defaults to setup command.)titledestdescriptionsetupzConfigure the project)help_msg	configurezChange project optionsdistzGenerate release archiveinstallzInstall the project
introspectzIntrospect projectinitzCreate a new projecttestz	Run testswrapz
Wrap toolssubprojectszManage subprojectsrewritec                :                         | j                  S r   )add_arguments	formatter)parserr?   rO   s    r   rP   z,CommandLineParser.__init__.<locals>.<lambda>b   s    83I3I&RVR`3a3a r   zModify the project definitioncompilezBuild the projectdevenvz%Run commands in developer environmentrE   z5Convert current environment to a cross or native filerF   z#Test if project builds reproduciblyformatfmtzFormat meson source file)aliasesrY   helpzPrint help of a subcommandr   zunstable-coredata)' r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   scriptsrE   rF   r`   rG   shutilget_terminal_sizecolumnsrM   re   commandshidden_commandsrK   ArgumentParserrf   add_subparsers
subparsersadd_commandrd   runadd_help_argumentsrun_help_commandadd_runpython_argumentsrun_runpython_commandSUPPRESS)rO   r8   r9   r:   r;   r<   r=   r>   r@   rA   rB   rC   rD   rE   rF   rG   ro   r?   s   `                @r   __init__zCommandLineParser.__init__A   s    	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S  	S11111111"""""" 2244< F  F  F  F>@,.-7DN[[[+44:IA{ 5 } }&"6
"9 	 	; 	; 	;e&959": 	 	= 	= 	=!4ei"< 	 	? 	? 	?H$:HL"7 	 	9 	9 	9v';VZ"6 	 	8 	8 	8!4ei"8 	 	: 	: 	:!4ei"- 	 	/ 	/ 	/!7". 	 	0 	0 	0(BLDT"6 	 	8 	8 	8$a$a$a$a$ackco"A 	 	C 	C 	CH$:HL"5 	 	7 	7 	77#8'+"I 	 	K 	K 	Ki&=y}"Y 	 	[ 	[ 	[i&=y}"G 	 	I 	I 	I7#8'+PUw"< 	 	> 	> 	> 	!8$:O"> 	 	@ 	@ 	@ 	d&BDD^"*"3 	 	5 	5 	5,.@.NPbPf"*"3 	 	5 	5 	5 	5 	5r   Nnamer   add_arguments_func+T.Callable[[argparse.ArgumentParser], None]run_func%T.Callable[[argparse.Namespace], int]rY   rk   T.List[str]c                N   |pg }|t           j        k    r9t          j        d|z   | j                  }| j                            |           n#| j                            |||| j                  } ||           |                    |           |g|z   D ]}|| j	        |<   d S )Nzmeson rR   )rl   rk   rS   )r   )
rK   r}   rt   re   rs   appendrv   
add_parserset_defaultsrr   )rO   r   r   r   rY   rk   pis           r   rw   zCommandLineParser.add_commandx   s    -R x((('X_dn]]]A ''----**4haeao*ppA1	)))'! 	! 	!A DM!	! 	!r   rf   argparse.ArgumentParserc                    |                     dddd           |                     ddt          j                               |                     d	           |                     d
t          j                   d S )Nz-c
store_trueeval_argF)actionrV   defaultz	--versionversion)r   r   script_filescript_args)nargs)add_argumentplatformpython_versionrK   	REMAINDERrO   rf   s     r   r{   z)CommandLineParser.add_runpython_arguments   sz    DJPUVVVK	8CZC\C\]]]M***M1CDDDDDr   optionsargparse.Namespacer   c                .   |j         t          j        dd <   |j        rt	          |j                   nbdd l}t          j                            dt          j        
                    |j                             |                    |j        d           dS )Nr   r   __main__)run_name)r   sysargvr   execr   runpyr'   insertr&   dirnamerun_path)rO   r   r   s      r   r|   z'CommandLineParser.run_runpython_command   s    * 	E$%%%%LLLHOOArww/BCCDDDNN7.NDDDqr   c                ~    |                     ddt          | j                                                             d S )Nr   ?)r   choices)r   listrr   keysr   s     r   ry   z$CommandLineParser.add_help_arguments   s9    IS$t}?Q?Q?S?S:T:TUUUUUr   c                    |j         r%| j        |j                                                   n| j                                         dS )Nr   )r   rr   
print_helprf   )rO   r   s     r   rz   z"CommandLineParser.run_help_command   sC    ? 	%M'/*557777K""$$$qr   argsc                   d}t          | j                                                  ddgz   }|r
|d         |vrd}dg|z   }|d         | j        v r |d         }| j        |         }|dd          }n	| j        }d }ddlm} |                    |          }|                    |          }||j	        }|d	v ot          j        d
k     }	 |                    |          |rt          j        dd           |rt          j        dd           t          j                     S # t"          $ r]}	t%          |	|          cY d }	~	|rt          j        dd           |rt          j        dd           t          j                     S d }	~	ww xY w# |rt          j        dd           |rt          j        dd           t          j                     w xY w)NFz-hz--helpr   TrX   r   mesonlib>   r_   rX   rg   r\   )      znRunning the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.)fatalzdYou are using Python 3.6 which is EOL. Starting with v0.62.0, Meson will require Python 3.7 or newer)r   rr   r   rs   rf   rm   r   expand_arguments
parse_argsr   r   version_infor   r	   warningnoticer"   r   r3   )
rO   r   implicit_setup_command_noticeknown_commandsr   rf   r   r   !pending_python_deprecation_noticer
   s
             r   rx   zCommandLineParser.run   s   (-% dm002233tX6FF 	$tAwn44,0)9t#D 7d***1gG]7+F8DD[FG((..##D))?oG >>\3CSV\C\ 	*	##G,, - b T[`b b b b0 S ELQS S S SMOOOO  	, 	, 	,7+++++++, b T[`b b b b0 S ELQS S S SMOOOO	, - b T[`b b b b0 S ELQS S S SMOOOOs1   D   
F*F9F:F
 FF
 
AGr   r6   r   )r   r   r   r   r   r   rY   r   rk   r   r   r6   )rf   r   r   r6   )r   r   r   r   )r   r   r   r   )
__name__
__module____qualname__r~   rw   r{   r|   ry   rz   rx    r   r   r5   r5   @   s        55 55 55 55p lp! ! ! ! !E E E E   V V V V   * * * * * *r   r5   script_namer   r   c                ~   ddddddd}|                     | |           }	 t          j        d|z             }n,# t          $ r}t	          j        |           Y d }~d	S d }~ww xY w	 |                    |          S # t          $ r7}t	          j        d
|  d           t	          j        |           Y d }~d	S d }~ww xY w)N	meson_exemeson_installdelwithsuffixgtkdochelperhotdochelperregen_checker)exer\   	delsuffixgtkdochotdoc
regencheckzmesonbuild.scripts.r   z	Error in z helper script:)	r+   	importlibimport_moduleModuleNotFoundErrorr	   r!   rx   r   error)r   r   
script_mapmodule_namemoduler
   s         r   run_script_commandr      s    $,.** /1 1J ..k::K()>)LMM   qqqqqqzz+&&&   
;{;;;<<<qqqqqqs-   9 
A"AA"&A; ;
B<,B77B<r6   c                     t           j        j        rXt           j        j                                                            d          s$t           j                            d           d S d S d S )NzUTF-surrogateescape)errors)r   stdoutencodingupper
startswithreconfigurer   r   r   ensure_stdout_accepts_unicoder      si    
z 93:#6#<#<#>#>#I#I&#Q#Q 9
&7888889 9 9 9r   mainfilec                <    ddl m} |                    |            d S )Nr   r   )rm   r   set_meson_command)r   r   s     r   r   r      s.    x(((((r   c           
     @   dd l }dd l}d }|                    |j        j        |j        j                  D ]g}|j                            |j                  }d|j         d} || |          r/ || |          r#t          j	        d|j         d| d| d           hd S )	Nr   c                @    | D ]}|                     |          r dS dS )NTF)r   )colltargetentrys      r   has_startswithz.validate_original_args.<locals>.has_startswith   s8     	 	E'' ttur   z-D=zGot argument z	 as both z and z. Pick one.)
mesonbuild.options	itertoolschainr   BUILTIN_DIR_OPTIONSBUILTIN_CORE_OPTIONSargparse_name_to_argr   r   exit)r   
mesonbuildr   r   	optionkeylongargshortargs          r   validate_original_argsr      s       __Z%7%KZM_Mtuu ^ ^	$99).II)	)))>$(( 	^^^D(-K-K 	^H\	\\\\\\\^ ^ ^	^ ^r   original_argsc                n   t           j                            d          rPdd l}t          t
          t          t          fD ]}|                    d|d           |                    dd           t          j
        d	k    r]t           j                            d
          r>dd l}|                    dt          d           |                    ddt                     t                       t          j        dk    rLt           j                            dd          dvr*t          j        d           t          j        d           dS | d d          }t!          |          dk    r|d         dk    r|d         dk    r^t#          |           ddlm} 	 |                    dg|dd          z             S # t*          $ r}t-          |d          cY d }~S d }~ww xY wt/          |d         |dd                    S t#          |           t1          |           t3                                          |          S )NMESON_SHOW_DEPRECATIONSr   r   r   )categoryr   ignorez.*importlib-resources.*)message)r   
   MESON_RUNNING_IN_PROJECT_TESTSz)UTF-8 Mode affects .*getpreferredencoding)r   r   cygwinMSYSTEMrm   )MSYSrm   zYThis python3 seems to be msys/python on MSYS2 Windows, but you are in a MinGW environmentzFPlease install it via https://packages.msys2.org/base/mingw-w64-pythonr   z
--internalr   
regenerate)r=   z--reconfigurerX   )r&   r*   r+   warningsDeprecationWarningSyntaxWarningFutureWarningPendingDeprecationWarningfilterwarningsr   r   EncodingWarningr   r   r	   r   lenr   rm   r=   rx   r   r3   r   r   r5   )r   r   r  typr   r=   r
   s          r   rx   rx      sN   	z~~/00 M&}F_` 	P 	PC##Gc,#OOOO2KLLL
7""rz~~6V'W'W"/,WWW 	2]hwxxx
 "### |xBJNN9b$A$A$U$U
nooo
[\\\qD 4yyA~~$q'\117l""h'''      0zz?"3d122h">??? 0 0 0#Aw////////0 &d1gtABBx888h4   ""4(((s    F3 3
G=GGGc                 @   t          t          dd          r8t          j                            t          j                  sJ t          j        } n/t          j                            t          j        d                   } t          t          j        dd          |           S )NfrozenFr   r   )	r   r   r&   r'   isabs
executableabspathr   rx   )launchers    r   mainr  2  sn    sHe$$ 0w}}S^,,,,,>7??38A;//sx|X&&&r   r   )r
   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r6   )r   r   r   r   r   r   )r   r   )
__future__r   rm   r   r   modulesos.pathr&   r   r   rK   typingT
utils.corer   r   r	   r3   r5   r   r   r   r   rx   r  r   r   r   r   r   <module>r     s   # " " " " "       



!I             9 9 9 9 9 9 9 9      % % % %RK K K K K K K KZ   .9 9 9 9) ) ) )
^ ^ ^&0) 0) 0) 0)d' ' ' ' zCHTTVV r   