_d`DddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z ddl mZddlmZddlmZddlmZmZdd lmZdd lmZdd lmZmZ ddlmZe d ed ddlm"Z#dZ$dZ%dZ&dZ'ejPdk(rdZ&nejRdk7r ddl*Z*e+e*dxZ&Z%dZ,dZ-GddeZe&sejRdk(r ddZ.ydZ' ddZ.y#e!$reZYwxYw#e!$rYVwxYw)NEXTENSION_SUFFIXES)cache_from_source)DictIteratorListTuple)Path) build_ext) new_compiler)customize_compilerget_config_var)log) BaseError) ExtensionLibraryzCython.Compiler.MainLDSHARED) _config_varscftjdk(retj} dtd<dtd<dtd<t |tj tj |yt |y#tj tj |wxYw)Ndarwinz0gcc -Wl,-x -dynamiclib -undefined dynamic_lookuprz -dynamiclibCCSHAREDz.dylibSO)sysplatform _CONFIG_VARScopyr clearupdate)compilertmps >/usr/lib/python3/dist-packages/setuptools/command/build_ext.py_customize_compiler_for_shlibr" s ||x! %C  (6L $!)L  x (       $8$       $s &B+B0FsharedrTntRTLD_NOWctr|SdS)N) have_rtld)ss r!if_dlr*Ds1!r!c<tD]}d|vr|cS|dk(s|cSy)z;Return the file extension for an abi3-compliant Extension()z.abi3z.pydNr)suffixs r!get_abi3_suffixr.Hs+$ f M v M r+c(eZdZUdZeed<dZeed<dZdede e e ffdZ dZ ded e de fd Z dee e e ffd Zd Zd ZdZdZdZdZdZdee fdZdee fdZdee fdZdee e ffdZdZdZddZdde defdZ de fdZ!y)r F editable_modeinplacec|jdc}|_tj|||_|r|jyy)z;Build extensions in build directory, then copy if --inplacerN)r1 _build_extruncopy_extensions_to_source)self old_inplaces r!r4z build_ext.runUs;$(LL!! T\t"   * * , r+extreturnc|j|j}|j|}|jd}dj |dd}|j |}t jj |t jj|}t jj |j|} || fS)N.) get_ext_fullnamenameget_ext_filenamesplitjoinget_package_dirospathbasename build_lib) r6build_pyr8fullnamefilenamemodpathpackage package_dir inplace_file regular_files r!_get_inplace_equivalentz!build_ext._get_inplace_equivalent]s((2((2..%((73B<(..w7 ww||K1A1A(1KL ww||DNNH= l++r+cj|jd}|jD]}|j||\}}tjj |s |j s|j|||j|jsn|j||}|j||dy)NrG)levelT)compile) get_finalized_command extensionsrOrCrDexistsoptional copy_fileverbose _needs_stub_get_equivalent_stub_write_stub_file)r6rGr8rMrN inplace_stubs r!r5z#build_ext.copy_extensions_to_sourcegs--j9?? GC)-)E)EhPS)T &L, ww~~l+3<<|\N#88lK %%lC%F Gr+ output_filectjj|}|jj d\}}}tjj ||dSNr;.py)rCrDdirnamer> rpartitionrA)r6r8r]dir__r>s r!rZzbuild_ext._get_equivalent_stubxsKww{+XX((- 1d'',,tT*+3//r+c#K|jsy|jd}|jdjxsd}|jD]n}|j ||\}}||f|j s+|j ||}|j ||}t||}t||} | |fpyw)NrG install_libr') optimization)r1rSoptimizerTrOrYrZ_compiled_file_name) r6rGoptr8rMrNr\ regular_stub inplace_cache output_caches r!_get_output_mappingzbuild_ext._get_output_mapping}s|| --j9((7@@FB?? 4C)-)E)EhPS)T &L,. . $88lK #88lK 3Ls S 27AB>ctjd}|r/tjj|j d|z}n!t j ||}td}||jvr|j|}t|dxr t}|r|dt| }t}||z}t|trBtjj|\}}|jj!|t"St$rQ|j&rEtjj |\}}tjj|d|zS|S)NSETUPTOOLS_EXT_SUFFIXr; EXT_SUFFIXpy_limited_apizdl-)rCgetenvrDrAr@r3r?rext_mapgetattrr.len isinstancersplitextshlib_compilerlibrary_filenamelibtype use_stubs_links_to_dynamic)r6rHso_extrIr8use_abi3fnds r!r?zbuild_ext.get_ext_filenames 23 ww||X^^C%89FBH!224BH#L1F t|| #,,x(Cs$45K/:KH#Ns6{l3(*#f,#w'''**84C**;;BHHs44 h/2ww||Aurz22r+cftj|d|_g|_i|_d|_y)NF)r3initialize_optionsryshlibsrtr0r6s r!rzbuild_ext.initialize_optionss.%%d+"  "r+ctj||jxsg|_|j|j|jDcgc]}t |t s|c}|_|j r|j|jD]"}|j|j|_ $|jD]j}|j}||j|<||j|jdd<|j xr|j|xsd}|xrtxrt |t  }||_||_|j#|x}|_t&j(j+t&j(j-|j.|}|r)||j0vr|j0j3||sts$t&j4|j6vsB|j6j3t&j4m|j8rd|_yycc}w)Nr;r<FT)r3finalize_optionsrTcheck_extensions_listrwrrsetup_shlib_compilerr=r> _full_namertr@links_to_dynamicr|r}rYr? _file_namerCrDrarArF library_dirsappendcurdirruntime_library_dirsr0r1)r6r8rHltdnsrIlibdirs r!rzbuild_ext.finalize_optionss##D)///R ""4??3&*ooRsC9QsR ;;  % % '?? =C!22388valuemacros r!rzbuild_ext.setup_shlib_compilers<)5]]DLL *  4& &h/    (  % %d&7&7 8 ;; "#{{ 3 e%%dE2 3 :: ! /''. / >> %  " "4>> 2    (  % %d&7&7 8 :: !  - -djj 9    (  % %d&7&7 8'9&@&@&J#r+cft|tr |jStj||SN)rwrexport_symbolsr3get_export_symbols)r6r8s r!rzbuild_ext.get_export_symbolss+ c7 #%% %,,T377r+cD|j|j} t|tr|j|_t j |||jr-|jdj}|j||||_y#||_wxYw)NrG) _convert_pyx_sources_to_langrrwrryr3build_extensionrYrSrF write_stub)r6r8 _compilerrFs r!rzbuild_ext.build_extensions} ((*MM  &#w' $ 3 3  & &tS 1 66zBLL  3/%DMIDMs A0B Bctj|jDcgc]}|jc}dj |jj ddddgzt fd|jDScc}w)z?Return true if 'ext' links to a dynamic lib in the same packager;Nr<r'c3,K|] }|zv ywr).0libnamelibnamespkgs r! z-build_ext.links_to_dynamic..sJ3=H,Js)dictfromkeysrrrAr@anyr)r6r8librrs @@r!rzbuild_ext.links_to_dynamicsl ==DKK!HS#..!HIhhs~~++C0"5<=JCMMJJJ"IsB cPgtj||jSr)r3get_source_files_get_internal_dependsrs r!rzbuild_ext.get_source_files s&R,,T2RT5O5O5QRRr+c#0Kt|jjxstjj }d|j D}dtdtddfd}|D]y}t|}|jr ||d(d|jvr ||d @ ||z j d } |j||j{y#t$r ||d YwxYw#t$r ||d YwxYww)zAYield ``ext.depends`` that are contained by the project directoryc3BK|]}|jD]}|ywr)depends)rr8deps r!rz2build_ext._get_internal_depends..s I3S[[Ic3I3Is orig_pathreasonr9Nc2tjd||y)NzJdependency %s won't be automatically included in the manifest: the path %s)rinfo)rrs r!skipz-build_ext._get_internal_depends..skips HH8  r+zmust be relativez..zcan't have `..` segmentsT)strictz doesn't existzmust be inside the project root)r distributionsrc_rootrCrresolverTstr is_absolutepartsOSError relative_to ValueErroras_posix)r6 project_rootrrrrDresolveds r!rzbuild_ext._get_internal_depends sD--66C"))DLLN I$//I C    "C9D!S,-tzz!S45 (4/888E  $$\2 --/ !/ " S/*   S;< sHB'D*C&C>D&C;8D:C;;D>DDDDc|jr't|jjSt t j ||jzSr)r1listget_output_mappingkeyssortedr3 get_outputs_build_ext__get_stubs_outputsrs r!rzbuild_ext.get_outputs2sJ <<//16689 9j,,T2T5M5M5OOPPr+cP|j}tt|dS)z1See :class:`setuptools.commands.build.SubCommand`c |dS)Nrr)xs r!z.build_ext.get_output_mapping..:s !A$r+)key)rnrr)r6mappings r!rzbuild_ext.get_output_mapping7s"**,F7788r+cfdjD}tj|j}t d|DS)Nc3K|]S}|jrEtjjjg|j j dUyw)r;N)rYrCrDrArFrr@)rr8r6s r!rz0build_ext.__get_stubs_outputs..>sE  GGLL D#..*>*>s*C D sAAc3,K|] \}}||zywrr)rbasefnexts r!rz0build_ext.__get_stubs_outputs..Es:[T5D5L:s)rT itertoolsproduct!_build_ext__get_output_extensionsr)r6 ns_ext_basespairss` r!__get_stubs_outputszbuild_ext.__get_stubs_outputs<sD  !!,0L0L0NO:E:::r+c#\Kdd|jdjrdyyw)Nr`z.pycrGz.pyo)rSrhrs r!__get_output_extensionsz!build_ext.__get_output_extensionsGs.   % %j 1 : :L ;s*,ctjj|g|jj ddz}|j |||yr_)rCrDrArr@r[)r6 output_dirr8rR stub_files r!rzbuild_ext.write_stubMs?GGLLHcnn.B.B3.GH5P  ig6r+rc(tjd|j||r-tjj |rt |dz|jst|d}|jdjdddtdzd tjj|jzd d d td dddtddddddtddddg|j|r|j|yy)Nz writing stub loader for %s to %sz already exists! Please delete.w zdef __bootstrap__():z- global __bootstrap__, __file__, __loader__z0 import sys, os, pkg_resources, importlib.utilz, dlz: __file__ = pkg_resources.resource_filename(__name__,%r)z del __bootstrap__z if '__loader__' in globals():z del __loader__z# old_flags = sys.getdlopenflags()z old_dir = os.getcwd()z try:z( os.chdir(os.path.dirname(__file__))z$ sys.setdlopenflags(dl.RTLD_NOW)z3 spec = importlib.util.spec_from_file_location(z# __name__, __file__)z0 mod = importlib.util.module_from_spec(spec)z! spec.loader.exec_module(mod)z finally:z" sys.setdlopenflags(old_flags)z os.chdir(old_dir)z__bootstrap__()r')rrrrCrDrUrropenwriterAr*rErclose_compile_and_remove_stub)r6rr8rRfs r!r[zbuild_ext._write_stub_fileQs 3S^^YO rww~~i0I(IIJ J||Y$A GG .GJ-((*,''*:*:3>>*JK.:/CD2!BDEM=J;%BC0)/ : GGI   ) )) 4 r+c0ddlm}||gdd|j|jdj}|dkDr||g|d|jt j j|r#|jst j|yyy)Nr) byte_compileT)rhrrrf) distutils.utilrrrSrhrCrDrUunlink)r6rrrhs r!rz"build_ext._compile_and_remove_stubxsy/i[1D$,,O--m<EE a<  hdDLL  77>>) $T\\ IIi .: $r+N)F)"__name__ __module__ __qualname__r0bool__annotations__r1r4rr rrOr5rZrrnr?rrrrrrrrrrrrrrrr[rrr+r!r r Qs M4GT-,Y,5c?, G"0 000 4XeCHo%>42.# >K68 &KS$s)S$"x}$"LQT#YQ 9DcN9 ; 7%5#%5I%5N !# !r+r c R|j|j||||||||| | | | yr)linkSHARED_LIBRARY) r6objectsoutput_libnamerrrrrdebug extra_preargsextra_postargs build_temp target_langs r!rrs=               r+staticc |Jtjj|\}} tjj| \}}|j dj dr|dd}|j ||||| y)Nrr)rCrDr@rxrz startswithcreate_static_lib)r6rrrrrrrr r r r r rIrEr8s r!rrs{*!!!!ww}}^< H((2 #   % 0 0 7 |H w*e[Qr+) NNNNNrNNNN)/rCrrimportlib.machineryrimportlib.utilrritypingrrrr pathlibr distutils.command.build_extr _du_build_extdistutils.ccompilerr distutils.sysconfigr r distutilsrsetuptools.errorsrsetuptools.extensionrrCython.Distutils.build_extr3 __import__ ImportErrorrrr"r(r|r{rr>dlhasattrr*r.rrr+r!r#s@ 2C..B,B'3B%& z<%*   <<8IWW_  'J 77 I "q! q!h  4! BG !Rg JP    s$C,C9,C65C69DD