a b"@slddlZddlZzeWney.eZYn0ddZddZddZdd Zd d Z d d Z ddZ dS)NcCsddlm}||dS)Nr)DistutilsSetupError)distutils.errorsr)msgrr:/tmp/pip-target-98j97qn4/lib/python/cffi/setuptools_ext.pyerror s rcCsTt|}|}Wdn1s&0Y|d7}t||d}t|||dS)N exec)openreadcompiler )filenameglobfsrccoderrrexecfiles  & rc Csddlm}t|ts*tdt|jft|}z|d\}}Wn t ydtd|fYn0t j |sd}| ddd }t j |rd |d|f}td ||fd |d }t||z ||}Wn"tytd||fYn0t||s |}t||s,td|t|jft|dsFtd|f|j\} } } } |jrn| } || | durt||| nt||| | | | dS)Nr)FFIzEargument to 'cffi_modules=...' must be a str or a list of str, not %r:z3%r must be of the form 'path/build.py:ffi_variable'./.pyz (rewrite cffi_modules to [%r])z#%r does not name an existing file%sZ__cffi__)__name____file__z!%r: object %r not found in modulez"%r is not an FFI instance (got %r)_assigned_sourcez*%r: the set_source() method was not called)Zcffi.apir isinstance basestringrtyperstrsplit ValueErrorospathexistsreplacerKeyErrorhasattrrZ_windows_unicodecopyZ_apply_windows_unicode_add_py_module _add_c_module) distZmod_specrZbuild_file_nameZ ffi_var_nameextZ rewrittenZmod_varsffi module_namesourcesource_extensionkwdsrrradd_cffi_modulesV                 r2cCstddlm}d|vrpttdsp|jrpddl}z(t|jdd}|dkrRd|d<Wnt ynd|d<Yn0|S) a7 Add py_limited_api to kwds if setuptools >= 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_apigettotalrefcountNrT) cffir4r'sysZUSE_LIMITED_API setuptoolsint __version__ partitionr!) Extensionr1r4r9Zsetuptools_major_versionrrr_set_py_limited_apiIs   r>c sddlm}ddlm}ddlmddlmddlm dg}| | dgt ||}|f|d |d fd d |j durg|_ |j |jd |Gfd dd} | |jd <dS)Nr)r= build_extmkpathlogr3 $PLACEHOLDERsources)namerFcs\tj|}d|||dur:||}|sXd|SNzgenerating cffi module %rzalready up-to-date)r"r#joininfoZ make_c_source)Ztmpdirpre_runZc_fileupdated)r,r-rDrBr.r4r/r0rrmake_modws  z_add_c_module..make_modr@cseZdZfddZdS)z)_add_c_module..build_ext_make_modcs:jddkr,t|dd}|j|jd<|dS)NrrErK)rFgetattr build_temprun)selfrK base_classr,rMrrrPs z-_add_c_module..build_ext_make_mod.runNr __module__ __qualname__rPrrRrrbuild_ext_make_modsrW)N)distutils.corer=setuptools.command.build_extr@distutils.dir_utilrB distutilsrDr7r4extendpopr> ext_modulesappendcmdclassget) r+r-r.r/r0r1r=r@Z allsourcesrWr) rSr,r-rDrMrBr.r4r/r0rr*js         r*csddlmddlm}ddlm}ddlmddlm fdd|j d |Gfd d d }||j d <|j durg|_ |j |j d |Gfd dd}||j d <dS)NrrA)build_pyr?rCr3cs>d|tj||}|s:ddSrH)rJr"r#dirnameZmake_py_source)Zpy_filerL)r-rDrBr.r4rr generate_mods z$_add_py_module..generate_modrbcs*eZdZfddZfddZdS)z)_add_py_module..build_py_make_modcsB|d}|dd7<tjj|jg|RdS)Nrr)rPr r"r#rI build_lib)rQ module_pathrSrdr.rrrPs  z-_add_py_module..build_py_make_mod.runcs>|j}z*|r fdd|D|_|W||_S||_0dS)Ncsg|]}|kr|qSrr).0m)r.rr szN_add_py_module..build_py_make_mod.get_source_files..) py_modulesget_source_files)rQZsaved_py_modules)rSr.rrrms z:_add_py_module..build_py_make_mod.get_source_filesN)rrUrVrPrmrrhrrbuild_py_make_modsrnr@cseZdZfddZdS)z*_add_py_module..build_ext_make_modcsb||jr^d}d|dd}|d}||}|dd}tj||dS)Nrrerbr)rPZinplacer rIget_finalized_commandZget_package_dirr"r#)rQrgpackagerb package_dir file_name base_class_2rdr.rrrPs     z._add_py_module..build_ext_make_mod.runNrTrrsrrrWsrW)rZrBZsetuptools.command.build_pyrbrYr@r[rDr7r4r`rarlr_)r+r-r.rbr@rnrWr)rSrtr-rdrDrBr.r4rr)s        r)cCs4|dks Jt|tr|g}|D]}t||q dS)N cffi_modules)rrr2)r+attrvalueZ cffi_modulerrrrus   ru) r"r8r NameErrorrrrr2r>r*r)rurrrrs   -!.=