+
    Qi$                         R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RItRR.tRRRRRRRR/R	 ltRR
 lt	R t
R tR tR tR tR tR# )zb
Build a c-extension module on-the-fly in tests.
See build_and_import_extensions for usage hints

Nbuild_and_import_extensioncompile_extension_moduleprologue 	build_dirinclude_dirs	more_initc                  Vf   . pV\        W4      ,           pRpV'       g   \        P                  ! R4      pV'       d   VR,          pWu,          pVR,          p\        WV4      p\	        WWH4      p	^ RIp
V
P                  P                  W	4      pV
P                  P                  V4      pVP                  P                  V4       V# )a  
Build and imports a c-extension module `modname` from a list of function
fragments `functions`.


Parameters
----------
functions : list of fragments
    Each fragment is a sequence of func_name, calling convention, snippet.
prologue : string
    Code to precede the rest, usually extra ``#include`` or ``#define``
    macros.
build_dir : pathlib.Path
    Where to build the module, usually a temporary directory
include_dirs : list
    Extra directories to find include files when compiling
more_init : string
    Code to appear in the module PyMODINIT_FUNC

Returns
-------
out: module
    The module will have been loaded and is ready for use

Examples
--------
>>> functions = [("test_bytes", "METH_O", """
    if ( !PyBytesCheck(args)) {
        Py_RETURN_FALSE;
    }
    Py_RETURN_TRUE;
""")]
>>> mod = build_and_import_extension("testme", functions)
>>> assert not mod.test_bytes('abc')
>>> assert mod.test_bytes(b'abc')
Nz
    PyObject *mod = PyModule_Create(&moduledef);
    #ifdef Py_GIL_DISABLED
    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
    #endif
           .z.#define INITERROR return NULL
                z
return mod;)_make_methodspathlibPath_make_sourcer   importlib.utilutilspec_from_file_locationmodule_from_specloaderexec_module)modname	functionsr   r   r   r   bodyinitsource_stringmod_so	importlibspecfoos   &&$$$$       e/Users/mibo/.openclaw/workspace/.venv/lib/python3.14/site-packages/numpy/testing/_private/extbuild.pyr   r      s    N mI77DD LL%	  	OD 5M%L9F>>11'BD
..
)
)$
/CKKC J    c                    V P                  R4      R,          pW,          pVP                  RR7       \        W74      pT;'       g    . pT;'       g    . pT;'       g    . p\        WV,          W$VR7      # )a  
Build an extension module and return the filename of the resulting
native code file.

Parameters
----------
name : string
    name of the module, possibly including dots if it is a module inside a
    package.
builddir : pathlib.Path
    Where to build the module, usually a temporary directory
include_dirs : list
    Extra directories to find include files when compiling
libraries : list
    Libraries to link into the extension module
library_dirs: list
    Where to find the libraries, ``-L`` passed to the linker
r
   Texist_ok)outputfilenamer   	librarieslibrary_dirs)splitmkdir_convert_str_to_file
_c_compile)	namebuilddirr   r   r$   r%   r   dirnamecfiles	   &&&&&&   r   r   r   R   su    * jjob!GoGMM4M  8E%%2LRI%%2L/!!
 
r   c                    VR,          pVP                  R4      ;_uu_ 4       pVP                  \        V 4      4       RRR4       V#   + '       g   i     T# ; i)zwHelper function to create a file ``source.c`` in `dirname` that contains
the string in `source`. Returns the file name
zsource.cwN)openwritestr)sourcer-   filenamefs   &&  r   r)   r)   v   sG     #H	s		q	F 
O 
	Os   AA	c           
     $   . p. pV  FS  w  rEpV RV 2pRV9   d   RpMRpVP                  RV: RV: RV: R24       R	V V R
V R2p	VP                  V	4       KU  	  RP                  V4      RRRP                  V4      RV/,          ,           p
V
# )zTurns the name, signature, code in functions into complete functions
and lists them in a methods_table. Then turns the methods_table into a
``PyMethodDef`` structure and returns the resulting code fragment ready
for compilation
_METH_KEYWORDSz2(PyObject *self, PyObject *args, PyObject *kwargs)z (PyObject *self, PyObject *args)z{"z", (PyCFunction)z, z},z
        static PyObject* z
        {
        z
        }
        
a6  
    static PyMethodDef methods[] = {
    %(methods)s
    { NULL }
    };
    static struct PyModuleDef moduledef = {
        PyModuleDef_HEAD_INIT,
        "%(modname)s",  /* m_name */
        NULL,           /* m_doc */
        -1,             /* m_size */
        methods,        /* m_methods */
    };
    methodsr   )appendjoin)r   r   methods_tablecodesfuncnameflagscode	cfuncname	signature	func_coder   s   &&         r   r   r      s     ME!*iq
+	e#LI:I08)UK	M#YK 0		 		 	Y "+  99U  dii.	7
CD DD Kr   c                $    RRV RVRV/,          pV# )zFCombines the code fragments into source code ready to be compiled
    zn
    #include <Python.h>

    %(body)s

    PyMODINIT_FUNC
    PyInit_%(name)s(void) {
    %(init)s
    }
    r+   r   r    )r+   r   r   rB   s   &&& r   r   r      s)    	 	fdFDD Kr   c           	          . p\         P                  R 8X  d   R.pVP                  R4       M,\         P                  P                  R4      '       d   . ROpM. p\	        WWeW#V4      # )win32z/we4013z/DEBUGlinux)z-O0z-gz%-Werror=implicit-function-declarationz-fPIC)sysplatformr<   
startswithbuild)r.   r#   r   r$   r%   
link_extracompile_extras   &&&&&  r   r*   r*      sd    J
||w"(#		 	 	)	)K / /r   c                   V P                   R,          p\        P                  ! VRR7       \        V P                   R,          R4      ;_uu_ 4       pV U	u. uF  p	RV	,           NK  	  p
p	VP	                  \
        P                  ! RVP                  R,           RV P                  R,           R	V R
V
 RV R24      4       RRR4       V P                   R,          p\        VR4      ;_uu_ 4       pVP	                  \
        P                  ! R\        P                   R24      4       RRR4       \        P                  R8X  d   \        P                  ! . ROVR7       M4\        P                  ! RRRRR\        P                  ! V4       2.VR7       VP                  R,          \        4       ,           p\        P                  ! RR.VR7       \        P                  ! \!        W|,          4      V P                   V,          4       V P                   V,          # u up	i   + '       g   i     ELg; i  + '       g   i     EL; i)zuse meson to buildrN   Tr!   zmeson.buildwtz-Lz            project('foo', 'c')
            py = import('python').find_installation(pure: false)
            py.extension_module(
                'z',
                'z',
                c_args: z,
                link_args: z',
                include_directories: z,
            )
        Nz.mesonpy-native-file.iniz-            [binaries]
            python = 'z
'
        rI   mesonsetup--vsenv..)cwdz--native-file=compiler&   )rS   rT   z--buildtype=releaserU   rV   )parentosmakedirsr1   r2   textwrapdedentpartsrK   
executablerL   
subprocess
check_callfspathget_so_suffixrenamer3   )r.   r#   rP   rO   r   r$   r%   r   fidd	link_dirsnative_file_nameso_names   &&&&&&&      r   rN   rN      s    w&IKK	D)	ell]*D	1	1S'34|!TAXX|	4		(// ' !&&r*+ ,++b/" #& (%; '&&2^ 4	
# 
 
	 
2 ||&@@		%	%		(// '~~& '	#  	 
&
 ||w 0 #,	  	w#~bii@P6Q5R%SU"+	 
 ""2&8G7I.I>IIc)%&w(>?<<'!!C 5 
2	1	1 
&	%	%s+   HH(AH08H3HH0	3I	c                  F    \         P                  ! R 4      p V '       g   Q hV # )
EXT_SUFFIX)	sysconfigget_config_var)rets    r   rc   rc      s    

"
"<
0CJ3Jr   )NN)__doc__rZ   r   r`   rK   rl   r\   __all__r   r   r)   r   r   r*   rN   rc   rG   r   r   <module>rq      su    
   
  ')C
D>(*>6:>>%'>B!
H%P$/$("Vr   