o 6aZH@sdZddlZddlmZddlZddlmZddlmZm Z m Z ddl m Z ddl mZddlmZmZmZmZmZmZdd lmZejZeeeD]Zeedd vrheedd feed dee<qKGd ddeZdS)zC Modified version of build_clib that handles fortran source files. N)glob) build_clib)DistutilsSetupErrorDistutilsErrorDistutilsFileError)log) newer_group)filter_sourcesget_lib_source_filesget_numpy_include_dirshas_cxx_sources has_f_sources is_sequence)new_ccompiler_opt)z build-clibz build-temp=c@sleZdZdZejgdZejgdZddZddZdd Z d d Z d d Z ddZ ddZ ddZdS)rz1build C/C++/F libraries used by Python extensions))z fcompiler=Nz!specify the Fortran compiler type)inplaceizBuild in-place)z parallel=jznumber of parallel jobs) warn-errorNz'turn all warnings into errors (-Werror))z cpu-baseline=Nz4specify a list of enabled baseline CPU optimizations)z cpu-dispatch=Nz.specify a list of dispatched CPU optimizations)disable-optimizationNz1disable CPU optimized code(dispatch,simd,fast...))rrrcCs8t|d|_d|_d|_d|_d|_d|_d|_dS)Nr) old_build_clibinitialize_options fcompilerrparallel warn_error cpu_baseline cpu_dispatchdisable_optimization)selfr D/usr/lib/python3/dist-packages/numpy/distutils/command/build_clib.pyr1s  zbuild_clib.initialize_optionsc Cs\|jrzt|j|_Wnty}ztd|d}~wwt||dddddddS)Nz)--parallel/-j argument must be an integerbuild)rr)rr)rr)rr)rr)rint ValueErrorrfinalize_optionsset_undefined_options)rer r r!r%<s  zbuild_clib.finalize_optionscC*|jD]\}}t|dgrdSqdSNsourcesTF) librariesr getrlib_name build_infor r r!have_f_sourcesK zbuild_clib.have_f_sourcescCr(r))r+r r,r-r r r!have_cxx_sourcesQr1zbuild_clib.have_cxx_sourcescCsN|jsdSg}|d|jD]\}}|dd}|r$||vr$||qddlm}||j|j|jd|_|jj |j | d|j rR|jjd|jj d|j}d|_|j|||_|j|jstjdd d d }tj|dj|}tjtj|jd }t|d r|jt|j||j|j|d|_dd} ddl} | | |j| rddl!m"} | |j#|j$|j|jd|v|jd|_%|j%dur|j% |j |j}d|_|j%|||_|j%nd|_%|&|j|j'r#|j j(D]'}|j)|j*} tj|j+| } tj|j,| }|-|j,t./| |qdSdS)N build_srclanguager) new_compiler)compilerdry_runforce)need_cxxz-Werrornumpy distutilsincludeznpy_cpu_dispatch_config.hzccompiler_opt_cache_clib.py compiler_opt)r6dispatch_hpathrr cache_pathcSs tdt|jdddS)Nz3 ########### CLIB COMPILER OPTIMIZATION ###########T)full)rinforeport)coptr r r!rBs zbuild_clib.run..report new_fcompilerf90r6verboser7r8 requiref90 c_compiler)0r+ run_commandr,appenddistutils.ccompilerr5r6r7r8 customize distributionr2r compiler_so customize_cmdshow_customizationrospathjoinget_finalized_commandr3abspath build_temphasattrr= cache_flushrrratexitregisterr0numpy.distutils.fcompilerrErrH _f_compilerbuild_librariesrinstalled_librarieslibrary_filenamenamer target_dirmkpathshutilcopy)r languagesr.r/lr5r+r>opt_cache_pathrBr[rElibnamesourcetargetr r r!runWs                 zbuild_clib.runcCs.||jg}|jD] }|t|q |SN)check_library_listr+extendr )r filenameslibr r r!get_source_filess  zbuild_clib.get_source_filescCs |D] \}}||||qdSrn)build_a_library)rr+r.r/r r r!r_s zbuild_clib.build_librariesc. s|j}|j}|d}|dust|std|t|}t|\}}} } | p0|dddk} g} |r:| d|rA| d| rI| dn| rP| d| |d<|j||j d } ||d g}|j }|j sv|j svtd d }|st|| d std|dStd||di}|dur|rtd|fddlm}||j|j|j|j | |jd}|dur|j}|d}||||| s| r|durtd||dur|dpg|_|dpg|_|d}|durg}|d}|durg}|dp g}|t |dpg}t!j"#| }| r*|$||jdkr6||7}g}g}g}g}g}|j s|%dj&}t!j"'ddd }t!j"'||}|||j(rbdn|}|f|d!f||f|d"ffD]\} }!| D]|!fd#d$ddD7}!qxqq|j )}n|d%g}"|rtd&|"|j j*||j+|||||j||#d'7}"|rtd(|"|j j*||j+|||||j|d)7}"|rtd*|"|j,||j+||||j||d+7}"|rtd,|-}#|#j,||j+||||j||d+}$|"|$| s| rg}g}%| r.|j.dur&t/d-}&||0||7}| rEtd.|%|j,| |j+|||j|d+7}%| r|jj.durt/d-D]H}'|'|&vr\qSt!j"'||'}(t!j"1|'t!j"1|(krrqSt!j"2|(r~t!3|(z |4|'|WqSt5yt6d/|'|fYqSw| rtd0|%|j,| |j+|||j|d+7}%ng}%|%r;|7|s;t!j"'|j |d1})t8|)d2}'|'9d3'd4d5|%DWdn 1swYt!j"'|j |d6})t8|)d2}'|'9d3'd7d5|"DWdn 1swYt!j"'|j ||j:}*t8|*d8}'Wdn 1s5wYn|"|%|j;|"||j |jd9|d:g}+|D]\},}-|,|+vre|+|-d:gqS|+rp|+|d:<dSdS);Nr*zfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenamesr4crFzc++f77source_languages) output_dirdependsz*Detected changes on compiler optimizationsTnewerz"skipping '%s' library (up-to-date)zbuilding '%s' library config_fczEusing additional config_fc from setup script for fortran compiler: %srrDrGz,s  z.build_clib.build_a_library..)NPY_DISABLE_OPTIMIZATIONrz#compiling C++ dispatch-able sources)rxsrc_dirr~rdebugextra_postargs ccompilerz!compiling C dispatch-able sources)rxrr~rrrzcompiling C sources)rxr~rrrzcompiling C++ sourcesz*.modz#compiling Fortran 90 module sourceszfailed to move %r to %rzcompiling Fortran sourcesz .fobjectsw cs|] }tj|VqdSrnrSrTrWrobjr r r! z-build_clib.build_a_library..z .cobjectscsrrnrrr r r!rrwb)rxrr+)copt_build_src_srcs_dstobjectsr cxx_objects f_objectsexisting_modulesftlistfn lib_fnameclib_librarieslnamebinfor rr!rts                                                     zbuild_clib.build_a_libraryN)__name__ __module__ __qualname__ descriptionr user_optionsboolean_optionsrr%r0r2rmrsr_rtr r r r!rs Z r)__doc__rSrredistutils.command.build_clibrrdistutils.errorsrrrnumpy.distutilsrdistutils.dep_utilrnumpy.distutils.misc_utilr r r r r rnumpy.distutils.ccompiler_optrr_lrangelen_ir r r r!s       &