o ~Re3@szddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z mZddlmZddlmZdd lmZz ddlmZed Wn eyUeZYnwed dd l mZd dZdZdZdZejdkrrdZnej dkrz ddl!Z!e"e!dZZWn eyYnwddZ#ddZ$GdddeZesej dkr    dddZ%dSdZ    dddZ%dS) NEXTENSION_SUFFIXES) build_ext) copy_file) new_compiler)customize_compilerget_config_var)DistutilsError)log)LibraryzCython.Compiler.MainLDSHARED) _config_varsc Csltjdkr0t}zdtd<dtd<dtd<t|Wtt|dStt|wt|dS)Ndarwinz0gcc -Wl,-x -dynamiclib -undefined dynamic_lookupr z -dynamiclibCCSHAREDz.dylibSO)sysplatform _CONFIG_VARScopyrclearupdate)compilertmpr/builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-2.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/command/build_ext.py_customize_compiler_for_shlibs    rFZsharedrTntRTLD_NOWcCs tr|SdS)N) have_rtld)srrrif_dl>s r!cCs.tD]}d|vr |S|dkr|SqdS)z;Return the file extension for an abi3-compliant Extension()z.abi3z.pydNr)suffixrrrget_abi3_suffixBsr#c@sveZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdddZdS)rcCs2|jd}|_t|||_|r|dSdS)z;Build extensions in build directory, then copy if --inplacerN)Zinplace _build_extruncopy_extensions_to_source)selfZ old_inplacerrrr%Ls   z build_ext.runc Cs|d}|jD]J}||j}||}|d}d|dd}||}tj |tj |}tj |j |} t | ||j |jd|jrR||pNtj|dqdS)Nbuild_py.)verbosedry_runT)get_finalized_command extensionsget_ext_fullnamenameget_ext_filenamesplitjoinZget_package_dirospathbasename build_librr+r, _needs_stub write_stubcurdir) r'r(extfullnamefilenamemodpathpackage package_dirZ dest_filenameZ src_filenamerrrr&Ts&       z#build_ext.copy_extensions_to_sourcecCstd}|rtjj|d|}n t||}td}||jvrk|j|}t |do.t }|rA|dt | }t }||}t |t rUtj|\}}|j|tStrk|jrktj|\}}tj|d|S|S)NZSETUPTOOLS_EXT_SUFFIXr) EXT_SUFFIXZpy_limited_apizdl-)r4getenvr5r3r2r$r1rext_mapgetattrr#len isinstancer splitextshlib_compilerlibrary_filenamelibtype use_stubs_links_to_dynamic)r'r<Zso_extr=r;Zuse_abi3fndrrrr1js&      zbuild_ext.get_ext_filenamecCs t|d|_g|_i|_dSN)r$initialize_optionsrHshlibsrCr'rrrrPs  zbuild_ext.initialize_optionscCs(t||jp g|_||jdd|jD|_|jr!||jD] }||j|_q$|jD]`}|j}||j |<||j | dd<|jrM| |pNd}|oXt oXt |t }||_||_||}|_tjtj|j|}|r||jvr|j||rt rtj|jvr|jtjq1dS)NcSsg|] }t|tr|qSr)rFr .0r;rrr s z.build_ext.finalize_options..r)r*F)r$finalize_optionsr.Zcheck_extensions_listrQsetup_shlib_compilerr/r0 _full_namerCr2links_to_dynamicrKrFr rLr8r1 _file_namer4r5dirnamer3r7 library_dirsappendr:runtime_library_dirs)r'r;r<Zltdnsr=libdirrrrrVs0       zbuild_ext.finalize_optionscCst|j|j|jd}|_t||jdur||j|jdur/|jD] \}}| ||q$|j dur?|j D]}| |q7|j durJ| |j |jdurU||j|jdur`||j|jdurk||jt||_dS)N)rr,force)rrr,rarHr include_dirsZset_include_dirsZdefineZ define_macroZundefZundefine_macro librariesZ set_librariesr\Zset_library_dirsZrpathZset_runtime_library_dirsZ link_objectsZset_link_objectslink_shared_object__get__)r'rr0valueZmacrorrrrWs*                zbuild_ext.setup_shlib_compilercCst|tr|jSt||SrO)rFr export_symbolsr$get_export_symbolsr'r;rrrrhs  zbuild_ext.get_export_symbolscCsl||j}z*t|tr|j|_t|||jr,|dj }| ||W||_dSW||_dS||_w)Nr() Z_convert_pyx_sources_to_langrrFr rHr$build_extensionr8r-r7r9)r'r;Z _compilercmdrrrrjs    zbuild_ext.build_extensioncsPtdd|jDd|jddddgtfdd|jDS) z?Return true if 'ext' links to a dynamic lib in the same packagecSsg|]}|jqSr)rX)rTlibrrrrUsz.build_ext.links_to_dynamic..r)Nr*rc3s|] }|vVqdSrOr)rTZlibnameZlibnamespkgrr z-build_ext.links_to_dynamic..)dictfromkeysrQr3rXr2anyrcrirrmrrYs zbuild_ext.links_to_dynamiccCst||SrO)r$ get_outputs_build_ext__get_stubs_outputsrRrrrrtszbuild_ext.get_outputscs6fddjD}t|}tdd|DS)Nc3s4|]}|jrtjjjg|jdRVqdS)r)N)r8r4r5r3r7rXr2rSrRrrros z0build_ext.__get_stubs_outputs..css|] \}}||VqdSrOr)rTbaseZfnextrrrrorp)r. itertoolsproduct!_build_ext__get_output_extensionslist)r'Z ns_ext_basespairsrrRrZ__get_stubs_outputss zbuild_ext.__get_stubs_outputsccs(dVdV|djrdVdSdS)N.pyz.pycr(z.pyo)r-optimizerRrrrZ__get_output_extensionss   z!build_ext.__get_output_extensionsFcCs8td|j|tjj|g|jdRd}|r&tj|r&t|d|j s`t |d}| dddd t d d tj |jd d dt ddddt ddddddt ddddg||rddlm}||gdd|j d |d!j}|dkr||g|d|j d tj|r|j st|dSdSdSdS)"Nz writing stub loader for %s to %sr)r|z 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__()rr) byte_compileT)r}rar, install_lib)r inforXr4r5r3r2existsr r,openwriter!r6rZclosedistutils.utilrr-r}unlink)r' output_dirr;compileZ stub_filefrr}rrrr9sl       zbuild_ext.write_stubN)F)__name__ __module__ __qualname__r%r&r1rPrVrWrhrjrYrtruryr9rrrrrKs   rc Cs(||j||||||||| | | | dSrO)linkZSHARED_LIBRARY) r'objectsoutput_libnamerrcr\r^rgdebug extra_preargsextra_postargs build_temp target_langrrrrd$s rdZstaticc Cs^|dusJtj|\}} tj| \}}|ddr$|dd}|||||| dS)Nxrl)r4r5r2rGrI startswithZcreate_static_lib)r'rrrrcr\r^rgrrrrrr=r6r;rrrrd3s   ) NNNNNrNNNN)&r4rrwimportlib.machineryrZdistutils.command.build_extrZ _du_build_extdistutils.file_utilrZdistutils.ccompilerrdistutils.sysconfigrrdistutils.errorsr distutilsr Zsetuptools.extensionr ZCython.Distutils.build_extr$ __import__ ImportErrorr rrrrKrJrr0dlhasattrr!r#rdrrrrs`               W