ó
    Eñi$  ã                   ó„   • S r SSKrSSKrSSKrSSKrSSKrSSKrSS/rSSSSS.S jr SS jr	S	 r
S
 rS rS rS rS rg)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                ón  • Uc  / nU[        X5      -   nSnU(       d  [        R                  " S5      nU(       a	  US-  nXu-  nUS-  n[        XU5      n[	        XXH5      n	SSKn
U
R                  R                  X	5      nU
R                  R                  U5      nUR                  R                  U5        U$ )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;r   )Ú_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                Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/numpy/testing/_private/extbuild.pyr   r      sº   € ðN ÑØˆØ”m IÓ7Ñ7€Dð€Dö Ü—L’L Ó%ˆ	ÞØð ñ 	ˆàÑˆØˆOÑ€DÜ  °Ó5€MÜ%Ø˜Ló9€FãØ�>‰>×1Ñ1°'ÓB€DØ
�.‰.×
)Ñ
)¨$Ó
/€CØ‡K�K×Ñ˜CÔ Ø€Jó    c                 óÄ   • U R                  S5      S   nX-  nUR                  SS9  [        X75      nU=(       d    / nU=(       d    / nU=(       d    / n[        X‡U-  X$US9$ )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   sm   € ð* �j‰j˜‹o˜bÑ!€GØ‰o€GØ‡M�M˜4€MÑ Ü  Ó8€EØ×% 2€LØ—˜R€IØ×% 2€LäØ¨Ñ/Ø!Ø!ñ
ð 
r    c                 óœ   • US-  nUR                  S5       nUR                  [        U 5      5        SSS5        U$ ! , (       d  f       U$ = f)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   sD   € ð ˜Ñ#€HØ	�‰�sÔ	˜qØ	�‰”�F“Ô÷ 
à€O÷ 
Ô	à€Oús	   —<¼
Ac           
      ó  • / n/ nU  HR  u  pEnU SU 3nSU;   a  SnOSnUR                  SU< SU< SU< S35        S	U U S
U S3n	UR                  U	5        MT     SR                  U5      SSR                  U5      US.-  -   n
U
$ )zäTurns 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Û!*Ñˆ˜Ø�i˜q  
Ð+ˆ	Ø˜eÓ#ØL‰Ià:ˆIØ×ÒÛ08»)ÃUÐKô	MðØ#˜ Y Kð 0	à	ˆð 	ðˆ	ð 	�‰�YÖñ "+ð  �9‰9�UÓð ð —i‘i Ó.¸7Ñ
CñDñ D€Dð €Kr    c                 ó   • SXUS.-  nU$ )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   rC   s       r   r   r   ¨   s!   € ð	ð ¨Dññ€Dð €Kr    c           	      óÊ   • / n[         R                  S:X  a  S/nUR                  S5        O+[         R                  R                  S5      (       a  / SQnO/ n[	        XXeX#U5      $ )NÚ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                 óô  • U R                   S-  n[        R                  " USS9  [        U R                   S-  S5       nU V	s/ s H  n	SU	-   PM
     n
n	UR	                  [
        R                  " SUR                  S    S	U R                  S    S
U SU
 SU S35      5        SSS5        U R                   S-  n[        US5       nUR	                  [
        R                  " S[        R                   S35      5        SSS5        [        R                  S:X  a  [        R                  " / SQUS9  O1[        R                  " SSSSS[        R                  " U5       3/US9  UR                  S   [        5       -   n[        R                  " SS/US9  [        R                  " [!        X|-  5      U R                   U-  5        U R                   U-  $ s  sn	f ! , (       d  f       GN;= f! , (       d  f       Nñ= f)zuse meson to buildrO   Tr#   zmeson.buildÚwtz-Lz“            project('foo', 'c')
            py = import('python').find_installation(pure: false)
            py.extension_module(
                'r"   z',
                'z',
                c_args: z,
                link_args: z',
                include_directories: z,
            )
        Nz.mesonpy-native-file.iniz-            [binaries]
            python = 'z
'
        rJ   )ÚmesonÚsetupz--buildtype=releaseú--vsenvú..)ÚcwdrT   rU   rV   rW   z--native-file=Úcompile)ÚparentÚosÚmakedirsr2   r3   ÚtextwrapÚdedentÚpartsrL   Ú
executablerM   Ú
subprocessÚ
check_callÚfspathÚget_so_suffixÚrenamer4   )r/   r%   rQ   rP   r   r&   r'   r   ÚfidÚdÚ	link_dirsÚnative_file_nameÚso_names                r   rO   rO   Ì   sà  € ð —‘˜wÑ&€IÜ‡K‚K�	 DÒ)Ü	ˆe�l‰l˜]Ñ*¨DÔ	1°SÙ'3Ó4¢| !�T˜A”X¡|ˆ	Ð4Ø�	‰	”(—/’/ð 'ð !×&Ñ& rÑ*Ð+ð ,Ø—+‘+˜b‘/Ð"ð #Ø&˜ð (Ø%˜;ð '&Ø&2 ^ð 4	ð
#ó 
ô 
	÷ 
2ð —|‘|Ð&@Ñ@ÐÜ	Ð Ô	%¨Ø�	‰	”(—/’/ð 'ä—~‘~Ð&ð '	ð#ó ô 	÷ 
&ô
 ‡|�|�wÓÜ×Òò 0ð #,ó	 ô 	×Ò˜w¨°Ø# ~´b·i²iÐ@PÓ6QÐ5RÐ%SðUà"+ò	 ð
 ×"Ñ" 2Ñ&¬«Ñ8€GÜ×Ò˜7 IÐ.°IÒ>Ü‡I‚IŒc�)Ñ%Ó&¨¯©°wÑ(>Ô?Ø�<‰<˜'Ñ!Ð!ùòC 5÷ 
2Ö	1ú÷ 
&Õ	%ús*   ¾GÁGÁAGÃ8G)ÇGÇ
G&Ç)
G7c                  óD   • [         R                  " S5      n U (       d   eU $ )NÚ
EXT_SUFFIX)Ú	sysconfigÚget_config_var)Úrets    r   rd   rd   ÷   s   € Ü
×
"Ò
" <Ó
0€CÞ€Jˆ3Ø€Jr    )NN)Ú__doc__r[   r   ra   rL   rm   r]   Ú__all__r   r   r*   r   r   r+   rO   rd   rH   r    r   Ú<module>rr      sf   ðñó 
Û Û Û 
Û Û à'Ð)CÐ
D€ð )+°dØ Rõ>ðF 59ô!
òHò%òPò$/ò$("óVr    