§ y<ˆjˆãó|—dZddlZddlZddlZddlZddgZddgddœd„Zggfd„Zd „Zd „Z d „Z gggfd „Z d „Z d„Z dS)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ó¼—ddlm}|t||¦«z}d}|stjd¦«}|r |dz }||z }|dz }t |||¦«} t |||| ¦«} n!#|$r} td|›d�¦«| ‚d } ~ wwxYwdd l} | j   || ¦«} | j   | ¦«}| j   |¦«|S) 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(u'abc') >>> assert mod.test_bytes(b'abc') r)Ú CompileErrorz8PyObject *mod = PyModule_Create(&moduledef); ú.z.#define INITERROR return NULL z return mod;zcould not compile in ú:N)Údistutils.errorsr Ú _make_methodsÚpathlibÚPathÚ _make_sourcerÚ RuntimeErrorÚimportlib.utilÚutilÚspec_from_file_locationÚmodule_from_specÚloaderÚ exec_module)ÚmodnameÚ functionsrrrr r ÚbodyÚinitÚ source_stringÚmod_soÚeÚ importlibÚspecÚfoos ús/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib64/python3.11/site-packages/numpy/testing/_private/extbuild.pyrrs9€ðN.Ð-Ð-Ð-Ð-Ð-à •m I¨wÑ7Ô7Ñ 7€Dð €Dà ð&Ý”L Ñ%Ô%ˆ ØðØ ðñ ˆà � ш؈OÑ€DÝ  ¨$°Ñ5Ô5€MðHÝ)Ø �Y  ¨mñ=ô=ˆˆøà ðHðHðHåÐ?°9Ð?Ð?Ð?Ñ@Ô@ÀaÐGøøøøðHøøøðÐÐÐØ Œ>× 1Ò 1°'¸6Ñ BÔ B€DØ Œ.× )Ò )¨$Ñ /Ô /€CØ„K×Ò˜CÑ Ô Ð Ø €JsÁA(Á(BÁ-BÂBcóì—| d¦«d}||z }| d¬¦«t||¦«}|tjd¦«gz}t |||z |gg¬¦«S)aH 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Ú INCLUDEPY)ÚoutputfilenamerÚ librariesÚ library_dirs)ÚsplitÚmkdirÚ_convert_str_to_fileÚ sysconfigÚget_config_varÚ _c_compile) ÚnameÚbuilddirrrr*r+rÚdirnameÚcfiles r$rrPs„€ð*�jŠj˜‰oŒo˜bÔ!€Gؘ‰o€GØ ‡M‚M˜4€MÑ Ô Ð Ý  °Ñ 8Ô 8€EØ¥9Ô#;¸KÑ#HÔ#HÐ"IÑI€Lå Ø ˜g¨Ñ/Ø!¨R¸bð ñ ô ð ócó®—|dz }| d¦«5}| t|¦«¦«ddd¦«n #1swxYwY|S)zHelper function to create a file ``source.c`` in `dirname` that contains the string in `source`. Returns the file name zsource.cÚwN)ÚopenÚwriteÚstr)Úsourcer4ÚfilenameÚfs r$r.r.qs�€ð˜Ñ#€HØ �Š�sÑ Ô ð˜qØ �Š•�F‘ ” ÑÔÐðððñôððððððøøøððððà €Os›#A Á AÁAc óR—g}g}|D]b\}}}|›d|›�}d|vrd}nd}| d|›d|›d|›d�¦«d  |||¬ ¦«} | | ¦«Œcd  |¦«d td  |¦«|¬ ¦«zz} | S)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* {cfuncname}{signature} {{ {code} }} )Ú cfuncnameÚ signatureÚcodeú 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ÚformatÚjoinÚdict) rrÚ methods_tableÚcodesÚfuncnameÚflagsrDrBrCÚ func_coders r$rr{sü€ð €MØ €EØ!*ð ð ш�%˜Ø&˜w˜w¨¨Ð1ˆ Ø ˜eÐ #Ð #ØLˆIˆIà:ˆIØ×ÒÐØ08°°¸)¸)¸)ÀUÀUÀUÐ Kñ Mô Mð Mð ÷ ŠF˜Y°)À$ˆFÑ GÔ Gð ð � Š �YÑÔÐÐà �9Š9�UÑ Ô ð õ �t—y’y Ñ/Ô/¸Ð AÑ AÔ Añ Bñ B€Dð €Kr6có0—dt|||¬¦«z}|S)zG Combines the code fragments into source code ready to be compiled zn #include %(body)s PyMODINIT_FUNC PyInit_%(name)s(void) { %(init)s } )r2rr)rJ)r2rrrDs r$rr£s0€ð õ Ø ˜ 4ð ñ ô ñ €Dð €Kr6c ó —tjdkr2dg}dtj tjd¦«zg}n+tj d¦«rgd¢}d}ndx}} tjdkr|dgz}tjdkr‡d D]„}|d z|vr:tj |d z¦«r| |d z¦«|d z|vr:tj |d z¦«r| |d z¦«Œ…|  t¦«¦«}tj   ¦«} t|||||||¦«| ¦«D]7\} } tj  | ¦«| kr| tj | <Œ8nQ#| ¦«D]7\} } tj  | ¦«| kr| tj | <Œ8wxYw|S) NÚwin32z/we4013z /LIBPATH:ÚlibsÚlinux)z-O0z-gz%-Werror=implicit-function-declarationz-fPICz/DEBUGÚdarwin)z/sw/z /opt/local/ÚincludeÚlib)ÚsysÚplatformÚosÚpathrIÚ base_prefixÚ startswithÚexistsrGÚ with_suffixÚ get_so_suffixÚenvironÚcopyÚbuildÚitemsÚget) r5r)rr*r+Ú compile_extraÚ link_extraÚsÚ saved_environÚkeyÚvalues r$r1r1µs€å „|�wÒÐØ"˜ ˆ Ø!¥B¤G§L¢Lµ´À&Ñ$IÔ$IÑIÐJˆ ˆ Ý Œ× Ò  Ñ )Ô )ð ðKðKðKˆ àˆ ˆ à%)Ð)ˆ ˜ Ø Ý „|�wÒÐØ 8 *Ñ,ˆ Ý „|�xÒÐà(ð /ð /ˆAØ�I‘  \Ð1Ð1ÝœŸš q¨9¡}Ñ5Ô5ð2à×#Ò# A¨ ¡MÑ2Ô2Ð2Ø�5‰y  Ð,Ð,µ´·²ÀÀEÁ Ñ1JÔ1JÐ,Ø×#Ò# A¨¡IÑ.Ô.Ð.øà#×/Ò/µ ±´Ñ@Ô@€NÝ”J—O’OÑ%Ô%€Mð (Ý Ø �>Ø ˜:Ø ˜) \ñ 3ô 3ð 3ð(×-Ò-Ñ/Ô/ð (ð (‰JˆC�ÝŒz�~Š~˜cÑ"Ô" eÒ+Ð+Ø"'•” ˜3‘øð (ø˜-×-Ò-Ñ/Ô/ð (ð (‰JˆC�ÝŒz�~Š~˜cÑ"Ô" eÒ+Ð+Ø"'•” ˜3‘øð (øøøð Ðs ÅF=Æ=AH c󨇗ddlm}|dd¬¦«}| d¦«g} tj¦«} tj‰j¦« | t‰j ¦«g||¬¦«} | ˆfd„| D¦«z } tj| ¦«n#tj| ¦«wxYw|  | t|¦«|||¬ ¦«d S) z@cd into the directory where the cfile is, use distutils to buildr)Ú new_compileréé)ÚforceÚverboser)rÚ extra_preargscó>•—g|]}t‰j|z ¦«‘ŒS©)r;Úparent)Ú.0Úrr5s €r$ú zbuild..ís(ø€Ð7Ð7Ð7¨a•C˜œ  qÑ(Ñ)Ô)Ð7Ð7Ð7r6)r*rrr+N) Únumpy.distutils.ccompilerrmÚ customizerZÚgetcwdÚchdirruÚcompiler;r2Úlink_shared_object) r5r)rfrgrr*r+rmÚcompilerÚobjectsÚoldÚress ` r$rcrcÜsø€ð7Ð6Ð6Ð6Ð6Ð6àˆ| !¨QÐ/Ñ/Ô/€HØ ×Ò�rÑÔÐØ€Gå Œ)‰+Œ+€CÝ„HˆUŒ\ÑÔÐðØ×ÒÝ �”‰_Œ_Ð Ø%Ø'ðñôˆð Ð7Ð7Ð7Ð7°3Ð7Ñ7Ô7Ñ7ˆå Œ�‰ Œ ˆ ˆ ø�Œ�‰ Œ ˆ ˆ øøøà ×ÒØ•�^Ñ$Ô$ØØ Ø!ð  ñ#ô#ð#ð#ð#s Árˆsúðððð  € € € Ø€€€Ø € € € ØÐÐÐà 'Ð)CÐ D€ð)+°dØ 2ð>ð>ð>ð>ð>ðF"$°"ð ð ð ð ðBððð%ð%ð%ðPððð$46ÀØð$ð$ð$ð$ðN#ð#ð#ð8ððððr6