3 L]" @snddlZddlZyeWnek r0eZYnXddZddZddZdd Zd d Z d d Z ddZ dS)NcCsddlm}||dS)Nr)DistutilsSetupError)distutils.errorsr)msgrr5/tmp/pip-install-wfra5znf/cffi/cffi/setuptools_ext.pyerror s rc Cs@t|}|j}WdQRX|d7}t||d}t|||dS)N exec)openreadcompiler )filenameglobfsrccoderrrexecfiles   rc Csddlm}t|ts*tdt|jft|}y|jd\}}Wn"t k rftd|fYnXt j j |sd}|j ddd }t j j |rd |d|f}td ||fd |d }t||y ||}Wn$tk rtd||fYnXt||s|}t||s0td|t|jft|dsJtd|f|j\} } } } |jrr| j} |j| | dkrt||| 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'./z.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_modulesL            r1c Cspd|krlttd rltjdkrlddl}y(t|jjdd}|dkrLd|d<Wntk rjd|d<YnX|S) a 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. For now we'll skip py_limited_api on all Windows versions to avoid an inconsistent mess. Zpy_limited_apigettotalrefcountwin32rNrT)r&sysplatform setuptoolsint __version__ partitionr ) Extensionr0r7Zsetuptools_major_versionrrr_set_py_limited_apiIs  r<c sddlm}ddlm}ddlmddlmddlm dg}|j |j dgt ||}|f|d |d fd d |j dkrg|_ |j j|jjd |Gfd dd} | |jd <dS)Nr)r;) build_ext)mkpath)log) recompilerz $PLACEHOLDERsources)namerAcs\tjj|}jd|||dk r:|j|}|sXjd|S)Nzgenerating cffi module %rzalready up-to-date)r!r"joininfoZ make_c_source)Ztmpdirpre_runZc_fileupdated)r+r,r?r>r-r@r.r/rrmake_modus  z_add_c_module..make_modr=cseZdZfddZdS)z)_add_c_module..build_ext_make_modcs:jddkr,t|dd}|j|jd<j|dS)Nrz $PLACEHOLDERrE)rAgetattr build_temprun)selfrE) base_classr+rGrrrJs z-_add_c_module..build_ext_make_mod.runN)r __module__ __qualname__rJr)rLr+rGrrbuild_ext_make_modsrO)N)distutils.corer;setuptools.command.build_extr=distutils.dir_utilr> distutilsr?cffir@extendpopr< ext_modulesappendcmdclassget) r*r,r-r.r/r0r;r=Z allsourcesrOr) rLr+r,r?rGr>r-r@r.r/rr)hs         r)csddlmddlm}ddlm}ddlmddlm fdd|j j d |Gfd d d }||j d <|j dkrg|_ |j j |j j d |Gfd dd}||j d <dS)Nr)r>)build_py)r=)r?)r@cs>jd|tjj|j|}|s:jddS)Nzgenerating cffi module %rzalready up-to-date)rDr!r"dirnameZmake_py_source)Zpy_filerF)r,r?r>r-r@rr generate_mods z$_add_py_module..generate_modr[cs*eZdZfddZfddZdS)z)_add_py_module..build_py_make_modcs@j|jd}|dd7<tjj|jf|dS)Nrz.py)rJrr!r"rC build_lib)rK module_path)rLr]r-rrrJs  z-_add_py_module..build_py_make_mod.runc s6|j}z"|r fdd|D|_j|S||_XdS)Ncsg|]}|kr|qSrr).0m)r-rr szN_add_py_module..build_py_make_mod.get_source_files..) py_modulesget_source_files)rKZsaved_py_modules)rLr-rrrfs  z:_add_py_module..build_py_make_mod.get_source_filesN)rrMrNrJrfr)rLr]r-rrbuild_py_make_modsrgr=cseZdZfddZdS)z*_add_py_module..build_ext_make_modcsbj||jr^jd}dj|dd}|jd}|j|}|dd}tjj||dS)Nrr^r[z.pyr_r_)rJZinplacerrCget_finalized_commandZget_package_dirr!r")rKrapackager[ package_dir file_name) base_class_2r]r-rrrJs     z._add_py_module..build_ext_make_mod.runN)rrMrNrJr)rlr]r-rrrOsrO)rRr>Zsetuptools.command.build_pyr[rQr=rSr?rTr@rYrZrerX)r*r,r-r[r=rgrOr)rLrlr,r]r?r>r-r@rr(s        r(cCs8|dks tt|tr|g}x|D]}t||q"WdS)N cffi_modules)AssertionErrorrrr1)r*attrvalueZ cffi_modulerrrrms    rm) r!r5r NameErrorrrrr1r<r)r(rmrrrrs  -.=