K is'ddlmZddlZddlZddlmZddlZddlm Z ddl m Z m Z ddl mZddlmZddlmZd d lmZd d lmZddlmcm Zdd lmZd ej8vZGddZGddZdZ y)) annotationsN)cache_from_source)path) build_extget_abi3_suffix) Distribution) CompileError) Extension) environment)DALS)get_config_var__pypy__c0eZdZdZdZdZdZdZdZy) TestBuildExtct}t|}d|jd<|jd}tjj|d}||k(sJy)z Setuptools needs to give back the same result as distutils, even if the fullname is not in ext_map. zfoo/barfooN)rrext_mapget_ext_filenameorig)selfdistcmdreswanteds e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/tests/test_build_ext.pytest_get_ext_filenamez"TestBuildExt.test_get_ext_filenamesT ~o!# I""5)00e<f}}ctttddgd}tt |g}t |}|j d|jvsJ|jd}ts|jtdsJy tjdk(r|jdsJy d |vsJy ) z} Filename needs to be loadable by several versions of Python 3 if 'is_abi3' is truthy on Extension() spam.eggseggs.cTpy_limited_api ext_modules EXT_SUFFIXwin32zeggs.pydabi3N) printrr rdictrfinalize_optionsrrendswithrsysplatform)r extensionrrrs rtest_abi3_filenamezTestBuildExt.test_abi3_filename&s o kH:dK Di[9:o ckk)))"";/ <<| <= == \\W $<< + ++S= =rct}t|}tddgdx|jd<}d|_t s|j d}nd} dtjd<|j d }d |k(sJ|j d}||k(sJ tjd=y #tjd=wxYw) zd SETUPTOOLS_EXT_SUFFIX variable always overrides default extension options. for_abi3zs.cTr#Fzfor_abi3.test-suffixz .test-suffixSETUPTOOLS_EXT_SUFFIXnormalznormal.test-suffixN) rrr r_links_to_dynamicIS_PYPYrosenviron)rrrextexpectrs rtest_ext_suffix_overridez%TestBuildExt.test_ext_suffix_override;s ~o(1  G )   J#!&))*5F,F 42@BJJ. /&&x0C'3. ..&&z2CS= = 23 23s AB,,B?cddddiiidddiid}tdd g}td d g}td d g}tj|td|||gddidS)Nmypkgsubpkgzext2.crext1zmain.c)srcz c-extensionsz mypkg.ext1zc-extensions/ext1/main.czmypkg.subpkg.ext2zsrc/mypkg/subpkg/ext2.cext3zc-extension/ext3.cz%test%rA) script_namer& package_dir)r rbuildr)rfilesr@ext2rBs rdist_with_examplezTestBuildExt.dist_with_example[sh278#h^4  (B'CD,/H.IJ"6!78 5# $-;   rc L|jdd|jdd|j}|jd}d|_|j |j jtjd}|jDcgc]"}|jtjd$}}||d|d|d gk(sJ|jik(sJ|jdd |_|j |jjD cic]D\}} |jtjd| jtjdF} }} | |dd |dd |d d ik(sJycc}wcc} }w)Nr4.mp3&setuptools.command.build_ext.use_stubsFr/ /ext3.mp3/mypkg/ext1.mp3/mypkg/subpkg/ext2.mp3T src/ext3.mp3src/mypkg/ext1.mp3src/mypkg/subpkg/ext2.mp3)setenvsetattrrHget_command_obj editable_modeensure_finalized build_libreplacer8sep get_outputsget_output_mappingreinitialize_commanditems) r tmpdir_cwd monkeypatchrrrXxoutputskvmappings rtest_get_outputszTestBuildExt.test_get_outputsls2F;DeL%%'((5 "' " ""$''//< 3H93H3H3JKa199RVVS)KKk #k )k/ 0    ,y++-333 !!+."& " ""$5 446<<> 1 IIbffc "AIIbffc$: :  k #^k )+?k/ 02M    !L s 'F8A F c r|jdd|jdd|j}|jd}d|_|j |j D]}|j|dd|jjtjd}|jjDcic]D\}}|jtjd|jtjdF} }}d} | | |d | d |d d | |d | d|dd| |d| d|ddik(sJ|d | vsJ|d| vsJ| |d } | | vsJ| j|dsJ| jdsJycc}}w)Nr4rJrKTr _needs_stubrLcTt|jtjdS)zDMake it possible to do comparisons and tests in a OS-independent wayrL)_compiled_file_namerYr8rZ)files rCz9TestBuildExt.test_get_output_mapping_with_stub..Cs&t,44RVVSA Arz/ext3.pyz src/ext3.pyrMrPz/mypkg/ext1.pyzsrc/mypkg/ext1.pyrNrQz/mypkg/subpkg/ext2.pyzsrc/mypkg/subpkg/ext2.pyrOrRz/mypkg/__pycache__/ext1z.pyc)rSrTrHrUrVrW extensionsrXrYr8rZr\r^ startswithr-) rr_r`rrr:rXrcrdrerl example_stubs r!test_get_output_mapping_with_stubz.TestBuildExt.test_get_output_mapping_with_stubs2F;DdK%%'((5 "& " ""$'' :C   ]D 9 :''//< 5 446<<> 1 IIbffc "AIIbffc$: :   B  8$ %q'7k #^  >* +Q/B-Ck )+?  01 2A6P4Qk/ 02M     N+7:::12'AAAI;n56 w&&&&&)4K'LMMM$$V,,,5 sA F3N) __name__ __module__ __qualname__rr1r<rHrfrprrrrs" !*4@ " @'-rrc&eZdZddZdZdZdZy)TestBuildExtInplacec  diidd}tj|tddg|}tt |g}d|_t |}t|jd d d d ||j|S) Nz#include missingheader.h )libtmp)r"z.buildr!r")optionalr%setup.pyz .build/libz .build/tmp)rX build_temprt) rrEr rr+rCrvarsupdaterW)rrzoptsrFr0rrs rget_build_ext_cmdz%TestBuildExtInplace.get_build_ext_cmds2 ,=  5kH:I Di[9:%oS Qz4TestBuildExtInplace.test_optional..s  ? s N)rrunanyr)rr_rrrs r test_optionalz!TestBuildExtInplace.test_optionalsN $$dD$A   ,,VV<    rc|jdd}tjt5|j dddy#1swYyxYw)NFTr)rpytestraisesr r)rr_rs rtest_non_optionalz%TestBuildExtInplace.test_non_optionalsA$$eT$B ]]< (  GGI   s AAN)rzboolreturnr)rqrrrsrrrrrtrrrvrvs M  rrvctdtdtdd}tj|tjdgd\}\}}|dk(s Jd |d |y) Nz from setuptools import Extension, setup setup( name='foo', version='0.0.0', ext_modules=[Extension('foo', ['foo.c'])], ) a #include "Python.h" #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "foo", NULL, 0, NULL, NULL, NULL, NULL, NULL }; #define INITERROR return NULL PyMODINIT_FUNC PyInit_foo(void) #else #define INITERROR return void initfoo(void) #endif { #if PY_MAJOR_VERSION >= 3 PyObject *module = PyModule_Create(&moduledef); #else PyObject *module = Py_InitModule("extension", NULL); #endif if (module == NULL) INITERROR; #if PY_MAJOR_VERSION >= 3 return module; #endif } zD [build] build_base = foo_build )r{zfoo.cz setup.cfgrE)r)r data_streamrz STDOUT: z STDERR: )r rrEr run_setup_py)r_rFcodestdoutstderrs rtest_build_ext_config_handlingrs   ( * V  m< Ez JJu(55 ID 66 19? F8;vh??9r)! __future__rr8r.importlib.utilrrjrjaracorsetuptools.command.build_extrrsetuptools.distrsetuptools.errorsr setuptools.extensionr rr textwrapr distutils.command.build_extcommandrdistutils.sysconfigrbuiltin_module_namesr7rrvrrtrrrsa" C C(****. 00 0[-[-|))XC@r