+
    ei$  c                   s    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prologueZ 	build_dirinclude_dirs	more_initc               s   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pathlibZPath_make_sourcer   Zimportlib.utilZutilZspec_from_file_locationZmodule_from_specZloaderZexec_module)modname	functionsr   r   r   r   bodyinitsource_stringZmod_soZ	importlibZspecZfoos   &&$$$$       F/usr/lib64/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                s    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Zexist_ok)outputfilenamer   	librarieslibrary_dirs)ZsplitZmkdir_convert_str_to_file
_c_compile)	nameZbuilddirr   r   r   r   r
   dirnamecfiles	   &&&&&&   r   r   r   R   su    * jjob!GoGMM4M  8E%%2LRI%%2L/!!
 
r   c                s    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.cZwN)openwritestr)Zsourcer   ZfilenameZfs   &&  r   r   r   v   sG     #H	s		q	F 
O 
	Os   AA	c           
     s$   . 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
Z_ZMETH_KEYWORDSz2(PyObject *self, PyObject *args, PyObject *kwargs)z (PyObject *self, PyObject *args)z{"z", (PyCFunction)z, z},z
        static PyObject* z
        {
        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 */
    };
    Zmethodsr
   )appendZjoin)r   r
   Zmethods_tableZcodesZfuncnameZflagscodeZ	cfuncnameZ	signatureZ	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                s$    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   r   s   &&& r   r	   r	      s)    	 	fdFDD Kr   c           	      s    . 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/DEBUGZlinux)z-O0z-gz%-Werror=implicit-function-declarationz-fPIC)sysplatformr   Z
startswithbuild)r   r   r   r   r   
link_extracompile_extras   &&&&&  r   r   r      sd    J
||w"(#		 	 	)	)K / /r   c                s   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 buildr$   Tr   zmeson.buildZ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
'
        r!   mesonsetup--vsenv..)Zcwdz--native-file=Zcompiler   )r'   r(   z--buildtype=releaser)   r*   )ZparentosZmakedirsr   r   textwrapZdedentZpartsr"   Z
executabler#   
subprocessZ
check_callZfspathget_so_suffixZrenamer   )r   r   r&   r%   r   r   r   r   ZfidZdZ	link_dirsZnative_file_nameZso_names   &&&&&&&      r   r$   r$      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                  sF    \         P                  ! R 4      p V '       g   Q hV # )Z
EXT_SUFFIX)	sysconfigZget_config_var)Zrets    r   r.   r.      s    

"
"<
0CJ3Jr   )NN)Z__doc__r+   r   r-   r"   r/   r,   Z__all__r    r   r   r   r	   r   r$   r.   r    r   r   <module>r0      su    
   
  ')C
D>(*>6:>>%'>B!
H%P$/$("Vr   