U ¸cã"ã@snddlZddlZzeWnek r0eZYnXdd„Zdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dS)éNcCsddlm}||ƒ‚dS)Nr)ÚDistutilsSetupError)Údistutils.errorsr)Úmsgr©rú= 26 is in use. Do not alter the setting if it already exists. Setuptools takes care of ignoring the flag on Python 2 and PyPy. CPython itself should ignore the flag in a debugging version (by not listing .abi3.so in the extensions it supports), but it doesn't so far, creating troubles. That's why we check for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401) On Windows, with CPython <= 3.4, it's better not to use py_limited_api because virtualenv *still* doesn't copy PYTHON3.DLL on these versions. Recently (2020) we started shipping only >= 3.5 wheels, though. So we'll give it another try and set py_limited_api on Windows >= 3.5. r©Ú recompilerZpy_limited_apiÚgettotalrefcountNréT) Úcffir5r'ÚsysZUSE_LIMITED_APIÚ setuptoolsÚintÚ __version__Ú partitionr!)Ú Extensionr2r5r:Zsetuptools_major_versionrrrÚ_set_py_limited_apiIs ÿ r?c sÞddlm}ddlm}ddlm‰ddlm‰ddlm ‰dg}|  |  dg¡¡t ||ƒ}|fˆ|d œ|—މd‡‡‡‡‡‡‡‡ fd d „ ‰|j dkržg|_ |j  ˆ¡|j d |¡‰G‡‡‡fd d„dˆƒ} | |jd <dS)Nr)r>©Ú build_ext©Úmkpath©Úlogr4ú $PLACEHOLDERÚsources)ÚnamerGcs\tj |ˆˆ¡}ˆ d|¡ˆ|ƒ|dk r:|ˆˆƒˆ ˆˆˆ|¡}|sXˆ d¡|S©Nzgenerating cffi module %rzalready up-to-date)r"r#ÚjoinÚinfoZ make_c_source)ZtmpdirÚpre_runZc_fileÚupdated)r-r.rErCr/r5r0r1rrÚmake_modws  z_add_c_module..make_modrAcseZdZ‡‡‡fdd„ZdS)z)_add_c_module..build_ext_make_modcs:ˆjddkr,t|ddƒ}ˆ|j|ƒˆjd<ˆ |¡dS)NrrFrL)rGÚgetattrÚ build_tempÚrun)ÚselfrL©Ú base_classr-rNrrrQŒs z-_add_c_module..build_ext_make_mod.runN©rÚ __module__Ú __qualname__rQrrSrrÚbuild_ext_make_mod‹srX)N)Údistutils.corer>Úsetuptools.command.build_extrAÚdistutils.dir_utilrCÚ distutilsrEr8r5ÚextendÚpopr?Ú ext_modulesÚappendÚcmdclassÚget) r+r.r/r0r1r2r>rAZ allsourcesrXr) rTr-r.rErNrCr/r5r0r1rr*js         r*csÐddlm‰ddlm}ddlm}ddlm‰ddlm ‰‡‡‡‡‡fdd„‰|j   d |¡‰G‡‡‡fd d „d ˆƒ}||j d <|j dkrg|_ |j   ˆ¡|j   d |¡‰G‡‡‡fd d„dˆƒ}||j d <dS)NrrB)Úbuild_pyr@rDr4cs>ˆ d|¡ˆtj |¡ƒˆ ˆˆ|¡}|s:ˆ d¡dSrI)rKr"r#ÚdirnameZmake_py_source)Zpy_filerM)r.rErCr/r5rrÚ generate_modŸs z$_add_py_module..generate_modrccs*eZdZ‡‡‡fdd„Z‡‡fdd„ZdS)z)_add_py_module..build_py_make_modcs@ˆ |¡ˆ d¡}|dd7<ˆtjj|jf|žŽƒdS)Nréÿÿÿÿr)rQr r"r#rJÚ build_lib)rRÚ module_path©rTrer/rrrQ¨s  z-_add_py_module..build_py_make_mod.runcs:|j}z&|r ‡fdd„|Dƒ|_ˆ |¡W¢S||_XdS)Ncsg|]}|ˆkr|‘qSrr)Ú.0Úm)r/rrÚ ³sÿzN_add_py_module..build_py_make_mod.get_source_files..)Ú py_modulesÚget_source_files)rRZsaved_py_modules)rTr/rrrn­s z:_add_py_module..build_py_make_mod.get_source_filesN)rrVrWrQrnrrirrÚbuild_py_make_mod§srorAcseZdZ‡‡‡fdd„ZdS)z*_add_py_module..build_ext_make_modcsbˆ |¡|jr^ˆ d¡}d |dd…¡}| d¡}| |¡}|dd}ˆtj ||¡ƒdS)Nrrfrcr)rQZinplacer rJÚget_finalized_commandZget_package_dirr"r#)rRrhÚpackagercÚ package_dirÚ file_name©Ú base_class_2rer/rrrQÉs     z._add_py_module..build_ext_make_mod.runNrUrrtrrrXÈsrX)r[rCZsetuptools.command.build_pyrcrZrAr\rEr8r5rarbrmr`)r+r.r/rcrArorXr)rTrur.rerErCr/r5rr)˜s        r)cCs4|dks t‚t|tƒr|g}|D]}t||ƒq dS)NÚ cffi_modules)ÚAssertionErrorrrr3)r+ÚattrÚvalueZ cffi_modulerrrrvÕs   rv) r"r9rÚ NameErrorrrrr3r?r*r)rvrrrrÚs  -!.=