U ã€C^Kã)@sÚddlmZmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZzddlmZWn ek r°ddlmZYnXeƒZgZdd„Ze  e¡ddlmZddlmZdd lmZd d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2g)Z Gd3d4„d4e!ƒZ"d5d2„Z#d6d.„Z$d7d„Z%d8d9„Z&d™d:d;„Z'dd'„Z*d?d@„Z+dAdB„Z,d›dEd,„Z-dœdFdG„Z.dHd„Z/e/ƒröe0ddIdJdKdLdMdNdOdPdQ Z1ddSdT„Z2n dždUdT„Z2dVdW„Z3dXd„Z4dYd„Z5dZd„Z6d[d„Z7d\d„Z8d]d„Z9d^d„Z:d_d`„Z;dadb„Zdeej?¡j@ZAe >dfej?¡j@ZBe >dgej?¡j@ZCe >dhej?¡j@ZDdidj„ZEdkd*„ZFdld„ZGdmd)„ZHdndo„ZIdpd+„ZJdqd-„ZKdrd„ZLdsd„ZMdtd„ZNdudv„ZOdwdx„ZPdydz„ZQd{d„ZRd|d „ZSd}d~„ZTdd€„ZUdd!„ZVd‚d"„ZWdƒd#„ZXdŸd„d…„ZYd†d$„ZZd‡d%„Z[d dˆd&„Z\Gd‰d „d e!ƒZ]ifdŠd„Z^d‹d „Z_dŒd„Z`d¡dŽd1„Zad¢dd0„Zbdd‘„Zcd£d’d „Zdd“d „Zed”d„Zfd•d„Zgd–d—„Zhd˜d/„ZidS)¤é)ÚdivisionÚabsolute_importÚprint_functionN)ÚDistutilsError)Úlocalc Cs:tdk r6tD](}zt |¡Wq tk r2Yq Xq dS©N)Ú_tmpdirsÚshutilÚrmtreeÚOSError)Úd©r úr?r r rÚ__init__LszInstallableLib.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rAr r r rr<6sr<cCsÊddlm}ztt d¡ƒ}Wntk r:t ¡}YnXt|dƒ}t tj   d|¡ƒ}|ƒ}|dkrj|St |  d¡ddƒt |  d¡ddƒt |  d ¡ddƒf}td d „|Dƒƒr´|Std d „|DƒƒSdS) aÁ Get number of parallel build jobs set by the --parallel command line argument of setup.py If the command did not receive a setting the environment variable NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of processors on the system, with a maximum of 8 (to prevent overloading the system if there a lot of CPUs). Returns ------- out : int number of parallel jobs that can be run r©Úget_distributionéZNPY_NUM_BUILD_JOBSNÚbuildÚparallelÚ build_extÚ build_clibcss|]}|dkVqdSrr ©Ú.0Úxr r rÚ qsz%get_num_build_jobs..css|]}|dk r|VqdSrr rMr r rrPts)Únumpy.distutils.corerGÚlenÚosÚsched_getaffinityÚAttributeErrorÚmultiprocessingÚ cpu_countÚminÚintÚenvironÚgetÚgetattrÚget_command_objÚallÚmax)rGrWZenvjobsÚdistZcmdattrr r rr;Rs"  þcCsFt|ƒ}tt|ƒƒD],}||}d|kr|ddkrd|||<q|S)Nú rz"'z"%s")ÚlistÚrangerR)ÚargsÚiÚar r rr7vs cCs| d¡}tjj|ŽS)zDConvert a /-separated pathname to one using the OS's path separator.ú/)ÚsplitrSÚpathÚjoin)r=Zsplittedr r rr€s cCs tj tj |¡¡}tj tj |¡¡}t|ƒt|ƒkr<|S||krHdS||dt|ƒ…krœ|t|ƒtjfksˆtt||t|ƒfƒƒ‚|t|ƒdd…}|S)z$Return path relative to parent_path.ÚNé)rSriÚrealpathÚabspathrRÚsepÚAssertionErrorÚrepr)riÚ parent_pathÚpdZapathr r rÚrel_path…s,rtcCs¨z(td|j|jƒ}tj tj |¡¡}Wndtk rŒtd|j|jƒ}t|ƒt j |}t |dƒr|tj tj |j ¡¡}n tj d¡}YnX|dk r t ||ƒ}|p¦dS)z¥Return path of the module given a frame object from the call stack. Returned path is relative to parent_path when given, otherwise it is absolute path. Ú__file__rBÚ.N)ÚevalÚ f_globalsÚf_localsrSriÚdirnamernÚ NameErrorÚ __import__ÚsysÚmodulesÚhasattrrurt)ÚframerrZ caller_filer Z caller_nameÚmodr r rÚget_path_from_frame“s   r‚cGszg}|D]2}t|ƒr$| t|Ž¡qt|ƒs0t‚| |¡q|}|sJd}n tjj|Ž}tjjdkrr|  dtjj¡}t |ƒS)a2Join two or more pathname components + - convert a /-separated pathname to one using the OS's path separator. - resolve `..` and `.` from path. Either passing n arguments as in njoin('a','b'), or a sequence of n names as in njoin(['a','b']) is handled, or a mixture of such arguments. rkrg) r2Úappendr1r3rprSrirjroÚreplacer0)riÚpathsÚpZjoinedr r rr1²s    c Cs´|dk rtj |d¡}n@tƒ}|D]&}tj |d¡}tj |¡r"|}qXq"td|fƒ‚t|ƒJ}g}d}|D]6}| |¡rn|t|ƒd…  ¡}|rn|  |  d¡¡qnW5QRX|S)z/Return the MATHLIB line from numpyconfig.h Nz_numpyconfig.hz1_numpyconfig.h not found in numpy include dirs %rz#define MATHLIBú,) rSrirjrÚexistsrÚopenÚ startswithrRÚstripÚextendrh) riÚ config_fileÚdirsÚfnÚfidZmathlibsÚsÚlineÚvaluer r rrÍs( ÿ  cCsÐt|ƒs |Sd|kr|S| tj¡}|rZz| dd¡}Wntk rPYqZYnX||=q$d}|r¼z| d|¡}Wntk rŠYq¼YnX||ddkr¦|d7}q^||=||d=d}q^|sÄdStj |¡S)z$Resolve `..` and '.' from path. rvrlz..rk)r3rhrSroÚindexÚ ValueErrorrj)riÚlreÚjr r rr0ès0    cCstt |¡ƒS)z}sorts output of python glob for https://bugs.python.org/issue30461 to allow extensions to have reproducible build results)ÚsortedÚglob)Zfileglobr r rÚ sorted_globsršcCsJt|ƒsttt|ƒƒƒ‚g}t|ƒr0tt|ƒƒ‚|D]}t|ƒrd|ksTd|krªt|ƒ}tt||ƒƒ}|rz| |¡n.|rŠ| |¡n|r˜| |¡t d||fƒnft||ƒ}t j   |¡rÌ| |¡nDt j   |¡rä| |¡n|rò| |¡t j   |¡s:t d||fƒq4t|ƒr0| t |||ƒ¡q4| |¡q4dd„|DƒS)NÚ*ú?z#could not resolve pattern in %r: %rznon-existing path in %r: %rcSsg|] }t|ƒ‘qSr )r0©rNr†r r rÚ -sz_fix_paths..)r2rprqÚtyper3ršr1rŒrƒÚprintrSrirˆÚ _fix_paths)r…Ú local_pathÚinclude_non_existingZ new_pathsÚnr†Úp2Zn2r r rr¡ s@     ÿ      ÿ  r¡rkTcCst|ƒr|f}t|||ƒS)z:Apply glob to paths and prepend local_path if needed. )r3r¡)r…r¢r£r r rr5/scCsLttdƒs t ¡t_t tj¡tj||tj|d\}}t  |d¡}||fS)NÚtempdir)ÚsuffixÚprefixÚdirÚtextÚw) rÚ_tdataÚtempfileÚmkdtempr¦rrƒÚmkstemprSÚfdopen)r§r¨rªrr=Úfor r rÚmake_temp_file6s   ý  r²cCsÄtjdkrdtjkrdSttjdƒrÀtj ¡rÀz|ddl}| ¡|  d¡dkr¨|  d¡dkr¨|  d¡dk rx|  d¡dk s¢|  d ¡dk r”|  d ¡dk s¢|  d ¡dk r¨Wd SWnt k r¾YnXdS) NÚcygwinZ USE_COLORrÚisattyÚcolorsÚpairsZsetfZsetbZsetafZsetabZscprl) r}ÚplatformrSrZrÚstdoutr´ÚcursesZ setuptermZtigetnumZtigetstrÚ Exception)r¹r r rrCs.  ÿ þ ý ü û ú rlééééééé ) ZblackÚredÚgreenÚyellowÚblueZmagentaÚcyanZwhiteÚdefaultFcCs|g}|r| d¡|r8dt | ¡d¡}| t|ƒ¡|r^dt | ¡d¡}| t|ƒ¡|rtdd |¡|fS|SdS)NÚ1éré(rÀz [%sm%sú;)rƒÚ _colour_codesr[ÚlowerÚstrrj)r‘ÚfgÚbgZboldÚseqZfgcodeZbgcoder r rÚ colour_textas rÒcCs|Srr )r‘rÏrÐr r rrÒpscCs t|dƒS)NrÇ©rÒ©r‘r r rÚ default_textssrÕcCs t|dƒS)NrÂrÓrÔr r rruscCs t|dƒS)NrÃrÓrÔr r rrwscCs t|dƒS)NrÄrÓrÔr r rryscCs t|dƒS)NrÆrÓrÔr r rr!{scCs t|dƒS)NrÅrÓrÔr r rr }scCs8tjdkr4| d¡r4|ddtj |dd…¡}|S)Nr³z /cygdriveé ú:é )r}r·rŠrSriÚnormcase)rir r rr"‚s cCs:tjdkr6tj dd¡dkr dStj dd¡dkr6dSdS) z0Return true when using mingw32 environment. Úwin32ZOSTYPErkZmsysTZMSYSTEMZMINGW32F)r}r·rSrZr[r r r rr#‡s  cCs8tj d¡}|dkr0ttj|d|d…ƒ}nd}|S)zGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrozMSC v.éÿÿÿÿr¿rÖN)r}ÚversionÚfindrY)Zmsc_posZmsc_verr r rÚmsvc_runtime_version‘s  rÞcCs,tƒ}|r$|dkrd|Sd|SndSdS)zFReturn name of MSVC runtime library if Python was built with MSVC >= 7éŒzmsvcr%iz vcruntime%iN)Úmsvc_runtime_major)Úverr r rÚmsvc_runtime_libraryšs  râcCs dddddddœ tƒd¡}|S) zFReturn major version of MSVC runtime coded like get_build_msvc_versionéFéGéPéZédrß)iiixiÜi@ilN)r[rÞ)Úmajorr r rrà¥sûúràz.*[.](cpp|cxx|cc)\Zz.*[.](f90|f95|f77|for|ftn|f)\Zz.*[.](f90|f95)\Zz\s*module\s*(?P[\w_]+)c CsTt|ƒs gSg}t|dƒ0}|D]$}t|ƒ}|r | d¡}| |¡q W5QRX|S)zRReturn a list of Fortran f90 module names that given source file defines. Úrr=)Ú f90_ext_matchr‰Úf90_module_name_matchÚgrouprƒ)Úsourcer~Úfr’Úmr=r r rÚ_get_f90_modules·s  rðcCs t|tƒSr)Ú isinstancerrÔr r rr3ÇscCs|D]}t|ƒsdSqdS)z4Return True if all items in lst are string objects. FT©r3)ÚlstÚitemr r rr$ÊscCs4t|ƒr dSz t|ƒWntk r.YdSXdS)NFT)r3rRrº©rÑr r rr2Ñs cCst|ƒod|kpd|kS)Nr›rœròrÔr r rÚis_glob_patternÚsröcCst|ƒrt|ƒS|gSdSr)r2rbrõr r rr4ÝscCs:d}|D],}t|tƒrt|ƒr(d}q6qt|ƒrd}q|S)z2Determine language value (c,f77,f90) from sources NÚf90Úf77)rñrÎrêÚfortran_ext_match)ÚsourcesÚlanguagerír r rr6ãs cCs|D]}t|ƒrdSqdS)z.Return True if sources contains Fortran files TF)rù©rúrír r rr%ðscCs|D]}t|ƒrdSqdS)z*Return True if sources contains C++ files TF)Ú cxx_ext_matchrür r rr&÷scCspg}g}g}g}|D]N}t|ƒrDt|ƒ}|r8| |¡qb| |¡qt|ƒrX| |¡q| |¡q||||fS)ztReturn four lists of filenames containing C, C++, Fortran, and Fortran 90 module sources, respectively. )rùrðrƒrý)rúZ c_sourcesZ cxx_sourcesZ f_sourcesZfmodule_sourcesrír~r r rr'þs    cCs.g}|D] }ttj |d¡ƒ}| |¡q|S)Nz*.h)ršrSrirjrŒ)Zdirectory_listÚheadersr Úheadr r rÚ _get_headerss  rcCsDg}|D]6}tj |¡}|ddkr|d|kr| |d¡q|S)Nrrk)rSrirhrƒ)Zlist_of_sourcesZdirecsrîr r r rÚ_get_directoriess  rcCs6d}|d |¡7}|d |¡7}|d |¡d7}|S)zb Return commandline representation used to determine if a file needs to be recompiled z commandline: raÚ ©rj)Zcc_argsZextra_postargsZpp_optsZcmdliner r rÚ_commandline_dep_string&s rcCs tt|ƒƒSr)rr)rúr r rr(2scCsˆt|ƒs dStj |¡}tj t ¡|g¡}|t|ƒd… tj¡}|r\|ds\|dd…}|rp|ddkrpdStj  |¡}tj  |¡S)z1Return true if directory is local directory. FNrrlrI) r3rSrirnÚ commonprefixÚgetcwdrRrhrorjÚisdir)Ú directoryZabs_dirÚcZnew_dirr r rr)6s    c#svddddœ‰t d¡}tj|ddD]L\}}}‡fdd„|Dƒ}||dd…<|D]}| |¡sPtj ||¡VqPq$dS)Nrl)ÚCVSú.svnrIú(?:[~#]|\.py[co]|\.o)$T©Útopdowncsg|]}|ˆkr|‘qSr r ©rNr ©Úpruned_directoriesr rržIsz(general_source_files..)ÚreÚcompilerSÚwalkÚsearchrirj)Útop_pathÚprune_file_patÚdirpathÚdirnamesÚ filenamesÚprunedrîr rrÚgeneral_source_filesEs    rc #sþdddg‰t d¡‰tj|ddD]–\}}}‡fdd„|Dƒ}||d d …<|D]h}tj ||¡‰tˆ|ƒ}g}t ˆ¡D]2}tj ˆ|¡} tj | ¡rxˆ  | ¡sx|  | ¡qx||fVqNq"|‰tˆ|ƒ}‡‡fd d„t ˆ¡Dƒ}d d„|Dƒ}||fVd S) zJReturn a directory name relative to top_path and files contained. r r rIr Tr csg|]}|ˆkr|‘qSr r rrr rržVsz4general_source_directories_files..Ncs$g|]}ˆ |¡stj ˆ|¡‘qSr )rrSrirj©rNrî)Údpathrr rržcs ÿcSsg|]}tj |¡r|‘qSr )rSriÚisfilerr r rržes ) rrrSrrirjrtÚlistdirrrrƒ) rrrrrr ÚrpathÚfilesrîrr )rrrrÚ general_source_directories_filesOs&      r#cCsng}dd„|jDƒ}| |¡| t|ƒ¡|jD]6}t|ƒrR| tt|ƒƒ¡q2tj  |¡r2|  |¡q2|S)NcSsg|]}t|ƒr|‘qSr rò©rNÚ_mr r rržlsz(get_ext_source_files..) rúrŒr(Údependsr)rbrrSrirrƒ)Úextrrúr r r rr*is    cCsdd„|Dƒ}|S)NcSsg|]}t|ƒr|‘qSr ròr$r r rržwsz$get_script_files..r )Úscriptsr r rr+vscCsŠg}|d dg¡}dd„|Dƒ}| |¡| t|ƒ¡|d dg¡}|D]6}t|ƒrn| tt|ƒƒ¡qNtj |¡rN|  |¡qN|S)NrlrúcSsg|]}t|ƒr|‘qSr ròr$r r rrž}sz(get_lib_source_files..r&) r[rŒr(r)rbrrSrirrƒ)Úlibrrúr&r r r rr,zs   cCs”tj ¡}| dd¡}|dkr*| dd¡}|stj d¡sFtj d¡rLd}nDtj d¡r^d }n2tj d ¡rpd }n d |kr| d | d ¡dd¡}|S)a;Return the correct file extension for shared libraries. Parameters ---------- is_python_ext : bool, optional Whether the shared library is a Python extension. Default is False. Returns ------- so_ext : str The shared library extension. Notes ----- For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X, and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on POSIX systems according to PEP 3149. For Python 3.2 this is implemented on Linux, but not on OS X. Ú EXT_SUFFIXNÚSOrkÚlinuxZ gnukfreebsdz.soÚdarwinz.dylibÚwinz.dllÚSOABIrvrl)Ú distutilsÚ sysconfigÚget_config_varsr[r}r·rŠr„)Z is_python_extZconfvarsZso_extr r rÚget_shared_lib_extensionˆs      ÿ  r3cCsˆt|ƒr|gS|d}g}|D]d}t|dƒr.qt|ƒrJ| tt|ƒƒ¡qt|ƒrvtj |¡rj|  |¡q‚t d|ƒqt t |ƒƒ‚q|S)NrlÚ__call__zNot existing data file:) r3rr)rŒrbrrSrirrƒr Ú TypeErrorrq)Údatarúrr‘r r rr-·s    cGsd dd„|Dƒ¡S)NrvcSsg|] }|r|‘qSr r )rNrfr r rržËszdot_join..r©rdr r rr.ÊscCsTzt |d¡WStk rNt ¡dj}t|dƒD] }|j}q:|YSXdS)z:Return frame object from call stack with given level. rlr»N)r}Ú _getframerUÚexc_infoÚtb_framercÚf_back)Úlevelr€Ú_r r rr/Ísc @s~eZdZddddddddd d g Zd d gZd dgZgZdadd„Zdd„Zdd„Z dd„Z dd„Z dd„Z dbdd„Z dcd d!„Zddd"d#„Zded%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Zdfd=d>„Zdgd?d@„ZdAdB„ZdCdD„ZdEdF„Z dGdH„Z!dIdJ„Z"dKdL„Z#dMdN„Z$dOdP„Z%dQdR„Z&dSdT„Z'dhdUdV„Z(didXdY„Z)djdZd[„Z*dkd]d^„Z+d_d`„Z,dS)lrÚpackagesÚ ext_modulesÚ data_filesÚ include_dirsÚ librariesrþr(Ú py_modulesÚinstalled_librariesÚ define_macrosÚ package_dirÚinstalled_pkg_configr=rÜNrlúsetup.pyc Ks˜t||ƒ|_d|_t|ƒ}t||ƒ|_|dkr:|j}d|_|dkrJ|j}n tj t |j|ƒ¡rjt |j|ƒ}tj |pvd¡sˆt d|fƒ‚||_ ||_ tjj |j d¡Ž|_|jdd…|_|jdd…|_|jD]&} t | | g¡¡} t|| t| ƒƒqÐ|jD]"} t | | i¡¡} t|| | ƒqþ|j|j} |jdd…|_| ¡D]h} | | krXqF|| } t|| | ƒt| tƒr†|j | ¡n&t| tƒr |j | ¡n |j | ¡qFtj t |dƒ¡rÞ|j  |j¡||j!|j<tddddd|_"d} t#dd ƒD]f}z t|ƒ}Wnt k r,YqfYnXzt$d |j%|j&ƒ} WqfWnt'k r`YnXqþt| |j(ƒrŽ| j"d rŽ|j)f| j"Ž||_*dS) a˜Construct configuration instance of a package. package_name -- name of the package Ex.: 'distutils' parent_name -- name of the parent package Ex.: 'numpy' top_path -- directory of the toplevel package Ex.: the directory where the numpy package source sits package_path -- directory of package. Will be computed by magic from the directory of the caller module if not specified Ex.: the directory where numpy.distutils is caller_level -- frame level to caller namespace, internal parameter. Nrkrvz%r is not a directoryú __init__.pyF)Úignore_setup_xxx_pyÚassume_default_configurationÚdelegate_options_to_subpackagesÚquietrlr¼r@rL)+r.r=rÜr/r‚r¢rSrirr1r•rÚ package_pathrjrhÚpath_in_packageÚ _list_keysÚ list_keysÚ _dict_keysÚ dict_keysÚcopyr[Úsetattrr4Ú _extra_keysÚ extra_keysÚkeysrñrbrƒÚdictrˆr>rFÚoptionsrcrwrxryr{Ú __class__Ú set_optionsÚ setup_name)r@Ú package_nameÚ parent_namerrNÚ caller_levelr]ÚattrsZ caller_framer¤ÚvÚ known_keysrfZcaller_instancererîr r rrAåsx            ü    zConfiguration.__init__cCsB| ¡i}|j|j|j}|D]}t||ƒ}|r"|||<q"|S)zâ Return a dictionary compatible with the keyword arguments of distutils setup function. Examples -------- >>> setup(**config.todict()) #doctest: +SKIP )Ú_optimize_data_filesrQrSrWr\)r@r rcr¤rfr r rÚtodictFs   zConfiguration.todictcCs|jdst|ƒdS)NrM)rZr ©r@Úmessager r rÚinfoYs zConfiguration.infocCstj d|f¡dS)Nz Warning: %s )r}ÚstderrÚwriterfr r rÚwarn]szConfiguration.warncKs8| ¡D]*\}}||jkr&||j|<qtd|ƒ‚qdS)zå Configure Configuration instance. The following options are available: - ignore_setup_xxx_py - assume_default_configuration - delegate_options_to_subpackages - quiet zUnknown option: N)ÚitemsrZr•)r@rZÚkeyr“r r rr\`s   zConfiguration.set_optionscCsddlm}|ƒS)z2Return the distutils distribution object for self.rrF)rQrG)r@rGr r rrGqs zConfiguration.get_distributionc Cs¢| d¡}t|jg|ƒ}dd„t|ƒDƒ}g}|D]h}tj t|dƒ¡sLq4d| tj¡kr^q4d | tj¡t |ƒ d…¡} |j | ||dd} |  | ¡q4|S)NrvcSsg|]}tj |¡r|‘qSr )rSrirr$r r rrž{s z:Configuration._wildcard_get_subpackage..rIrIrl©r_r`) rhr1r¢ršrSrirrorjrRÚget_subpackagerŒ) r@Úsubpackage_namer_r`r–Úsubpackage_pathrŽÚ config_listr r¤r r r rÚ_wildcard_get_subpackagevs   þ z&Configuration._wildcard_get_subpackagec s:tj dtj |¡¡ztj tj |¡¡d}tˆj||ƒ}t d  |  d¡¡|dƒ‰t ˆdƒs”ˆj dszˆ dˆ¡t||ˆj||dd }nht|g|  d¡dd …Ž} | f} ‡‡fd d „} ‡‡fd d„} tjddkrê| | ƒ} n| | ƒ} ˆj| Ž}|jt||ƒkr(ˆ dt||ƒ|jf¡W5tjd=X|S)Nrr=rv©z.pyÚUrlÚ configurationrKzCAssuming default configuration (%s does not define configuration())rl©r`rÛcsˆjjjdkr|ˆjf}|S©Nrl©rvÚ__code__Ú co_argcountrr7©r@Z setup_moduler rÚ fix_args_py2¡s zDConfiguration._get_configuration_from_setup_py..fix_args_py2csˆjjjdkr|ˆjf}|Srxryr7r|r rÚ fix_args_py3¥s zDConfiguration._get_configuration_from_setup_py..fix_args_py3r¼z*Subpackage %r configuration returned as %r)r}riÚinsertrSrzÚsplitextÚbasenamer.r=rrjrhrrZrkrrÚ version_inforv) r@Úsetup_pyrprqr_r`r]r¤ÚconfigZpnrdr}r~r r|rÚ _get_configuration_from_setup_py‰s@þ  þþ  ÿ  z.Configuration._get_configuration_from_setup_pycCsV|dkr$|dkrtdƒ‚tj |¡}| d¡}|dkrRd|krR|j|||ddSd|ksltt|||fƒƒ‚|dkr†t|j g|ƒ}n&t|g|dd…ƒ}|  |g¡d}t||j ƒ}|j d sÜtj  |¡sÜt|d |ƒ}tj  |¡s*|j d s| d tj |¡|f¡t|||j||dd}n|j|||||dd}|rN|gSgSdS) aReturn list of subpackage configurations. Parameters ---------- subpackage_name : str or None Name of the subpackage to get the configuration. '*' in subpackage_name is handled as a wildcard. subpackage_path : str If None, then the path is assumed to be the local path plus the subpackage_name. If a setup.py file is not found in the subpackage_path, then a default configuration is used. parent_name : str Parent name. Nz;either subpackage_name or subpackage_path must be specifiedrvr›rlrwrÛrrJz setup_%s.pyrKzEAssuming default configuration (%s/{setup_%s,setup}.py was not found))r•rSrirrhrsrprqr1r¢r…r]rZrrkrzrrr…)r@rprqr_r`r–rƒr„r r rroµsVÿ  þ   ÿ þþûzConfiguration.get_subpackageFc Cs²|r d}n|j}|j|||dd}|s0| d¡|D]Z}|}t|tƒrN| ¡}t|tƒshttt |ƒƒƒ‚|  d|  d¡|jf¡|j f|Žq4|  ¡}|dk r®| d|¡dS)aAdd a sub-package to the current Configuration instance. This is useful in a setup.py script for adding sub-packages to a package. Parameters ---------- subpackage_name : str name of the subpackage subpackage_path : str if given, the subpackage path such as the subpackage is in subpackage_path / subpackage_name. If None,the subpackage is assumed to be located in the local path / subpackage_name. standalone : bool Nr»rnz0No configuration returned, assuming unavailable.z Appending %s configuration to %sr=zTdistutils distribution has been initialized, it may be too late to add a subpackage )r=rorkrñrrerYrprqrŸrhr[rrG) r@rprqÚ standaloner_rrr„r r`r r rÚadd_subpackageòs.þ  ÿÿzConfiguration.add_subpackagec s¨t|ƒr|\‰}nd‰t|ƒr6‡‡fdd„|DƒdSt|ƒsLtd|fƒ‚ˆdkr„tj |¡rvˆ tj |¡|f¡Sˆ ||f¡Sˆj|dd}t |ƒrt ˆƒrt ˆƒ  tj ¡}|  ¡ttt|ƒdƒƒ}|  ¡|D]}||sÞ||=qÞ|D]}tj |¡std|ƒqöt|ˆjƒ}|  tj ¡}|  ¡g} d }|D]z} t | ƒr~|t|ƒkrntd ˆ|fƒ‚|  ||¡n4| ||ks¨tt| |||ˆ||fƒƒ‚|  | ¡|d7}qB||d…rÞˆ d ||f¡|   ¡ˆ tj  | ¡|f¡qön|D]}ˆ ˆ|f¡qdSt ˆƒr4ttˆƒƒ‚ˆ ¡} | dk rZ| jdk rZ| j} nˆj} |D]>}tt|ƒƒD]*\} }tj ˆjˆ| ¡}|  ||f¡qtqddS) a†Recursively add files under data_path to data_files list. Recursively add files under data_path to the list of data_files to be installed (and distributed). The data_path can be either a relative path-name, or an absolute path-name, or a 2-tuple where the first argument shows where in the install directory the data directory should be installed to. Parameters ---------- data_path : seq or str Argument can be either * 2-sequence (, ) * path to data directory where python datadir suffix defaults to package dir. Notes ----- Rules for installation paths:: foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar (gun, foo/bar) -> parent/gun foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun (gun/*, foo/*) -> parent/gun/a, parent/gun/b /foo/bar -> (bar, /foo/bar) -> parent/bar (gun, /foo/bar) -> parent/gun (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar Examples -------- For example suppose the source directory contains fun/foo.dat and fun/bar/car.dat: >>> self.add_data_dir('fun') #doctest: +SKIP >>> self.add_data_dir(('sun', 'fun')) #doctest: +SKIP >>> self.add_data_dir(('gun', '/full/path/to/fun'))#doctest: +SKIP Will install data-files to the locations:: / fun/ foo.dat bar/ car.dat sun/ foo.dat bar/ car.dat gun/ foo.dat car.dat Ncsg|]}ˆ ˆ|f¡‘qSr )Ú add_data_dirr©r r@r rržZsz.Configuration.add_data_dir..znot a string: %rF©r£rlzNot a directory, skippingrzcannot fill pattern %r with %rz,mismatch of pattern_list=%s and path_list=%s)r2r3r5rSriÚisabsrˆrr…rörrhroÚreverserbrcrRrr rtr¢r•rƒrprqrkrjrGr@r#rO)r@Z data_pathr…Ú pattern_listZrlrerir!Ú path_listÚ target_listr‘r`r@Zd1rîÚ target_pathr r‰rrˆsv8         ÿ*  ÿzConfiguration.add_data_dircCs^i}|jD]2\}}||kr$tƒ||<|D]}|| |¡q(q dd„| ¡Dƒ|jdd…<dS)NcSsg|]\}}|t|ƒf‘qSr )rb)rNr†r"r r rržsz6Configuration._optimize_data_files..)r@ÚsetÚaddrl)r@Z data_dictr†r"rîr r rrd–s z"Configuration._optimize_data_filescGs(t|ƒdkr$|D]}| |¡qdSt|ƒdks4t‚t|dƒrN|d\}}nd}t|ƒr`|}nLt|ƒrœt|ƒdkr~|d}q¬|D]}| ||f¡q‚dSnttt|ƒƒƒ‚|dkrôt|dƒrÄd}nt j   |¡rÖd}n t j   |¡}| ||f¡dS|j |dd}t|ƒrÄt|ƒr²| t j¡}| ¡|D]€}| t j¡}| ¡| ¡g} d} |D]2} t| ƒr€|  || ¡| d7} n |  | ¡qZ|  ¡| t j | ¡|f¡q.n| ||f¡dSt|ƒrÞtt||fƒƒ‚| ¡} | dk r| jdk r| j} n|j} |  t j  |j|¡|f¡dS)aéAdd data files to configuration data_files. Parameters ---------- files : sequence Argument(s) can be either * 2-sequence (,) * paths to data files where python datadir prefix defaults to package dir. Notes ----- The form of each element of the files sequence is very flexible allowing many combinations of where to get the files from the package and where they should ultimately be installed on the system. The most basic usage is for an element of the files argument sequence to be a simple filename. This will cause that file from the local path to be installed to the installation path of the self.name package (package path). The file argument can also be a relative path in which case the entire relative path will be installed into the package directory. Finally, the file can be an absolute path name in which case the file will be found at the absolute path name but installed to the package path. This basic behavior can be augmented by passing a 2-tuple in as the file argument. The first element of the tuple should specify the relative path (under the package install directory) where the remaining sequence of files should be installed to (it has nothing to do with the file-names in the source distribution). The second element of the tuple is the sequence of files that should be installed. The files in this sequence can be filenames, relative paths, or absolute paths. For absolute paths the file will be installed in the top-level package installation directory (regardless of the first argument). Filenames and relative path names will be installed in the package install directory under the path name given as the first element of the tuple. Rules for installation paths: #. file.txt -> (., file.txt)-> parent/file.txt #. foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt #. /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt #. ``*``.txt -> parent/a.txt, parent/b.txt #. foo/``*``.txt`` -> parent/foo/a.txt, parent/foo/b.txt #. ``*/*.txt`` -> (``*``, ``*``/``*``.txt) -> parent/c/a.txt, parent/d/b.txt #. (sun, file.txt) -> parent/sun/file.txt #. (sun, bar/file.txt) -> parent/sun/file.txt #. (sun, /foo/bar/file.txt) -> parent/sun/file.txt #. (sun, ``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt #. (sun, bar/``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt #. (sun/``*``, ``*``/``*``.txt) -> parent/sun/c/a.txt, parent/d/b.txt An additional feature is that the path to a data-file can actually be a function that takes no arguments and returns the actual path(s) to the data-files. This is useful when the data files are generated while building the package. Examples -------- Add files to the list of data_files to be included with the package. >>> self.add_data_files('foo.dat', ... ('fun', ['gun.dat', 'nun/pun.dat', '/tmp/sun.dat']), ... 'bar/cat.dat', ... '/full/path/to/can.dat') #doctest: +SKIP will install these data files to:: / foo.dat fun/ gun.dat nun/ pun.dat sun.dat bar/ car.dat can.dat where is the package (or sub-package) directory such as '/usr/lib/python2.4/site-packages/mypackage' ('C: \Python2.4 \Lib \site-packages \mypackage') or '/usr/lib/python2.4/site- packages/mypackage/mysubpackage' ('C: \Python2.4 \Lib \site-packages \mypackage \mysubpackage'). rlNrr4rkFrŠ)rRÚadd_data_filesrpr2r3r5rqrŸrrSrir‹rzr…rörhrorŒÚpoprƒrjrGr@rO)r@r"rîr Zfilepatr…rrirŽrrer‘r`r@r r rr“ŸsfX              zConfiguration.add_data_filescCs>| ¡}|dk r.t|dƒs g|_|j |¡n |j |¡dS)zðAdd define macros to configuration Add the given sequence of macro name and value duples to the beginning of the define_macros list This list will be visible to all extension modules of the current package. NrE)rGrrErŒ)r@Úmacrosr`r r rÚadd_define_macros8s  zConfiguration.add_define_macroscGsH| |¡}| ¡}|dk r8|jdkr*g|_|j |¡n |j |¡dS)zçAdd paths to configuration include directories. Add the given sequence of paths to the beginning of the include_dirs list. This list will be visible to all extension modules of the current package. N)r…rGrArŒ)r@r…rAr`r r rÚadd_include_dirsHs  zConfiguration.add_include_dirscs´g‰|D]l‰tˆƒr0‡‡fdd„ˆ ˆ¡DƒqtˆttfƒrJtˆƒdkrVttˆƒƒ‚‡‡fdd„ˆ ˆd¡Dƒqˆ ¡}|dk r¤|j dkr–g|_ |j   ˆ¡n ˆj   ˆ¡dS)aÃAdd installable headers to configuration. Add the given sequence of files to the beginning of the headers list. By default, headers will be installed under // directory. If an item of files is a tuple, then its first argument specifies the actual installation location relative to the path. Parameters ---------- files : str or seq Argument(s) can be either: * 2-sequence (,) * path(s) to header file(s) where python includedir suffix will default to package name. csg|]}ˆ ˆj|f¡‘qSr )rƒr=r)rþr@r rržmsz-Configuration.add_headers..r»csg|]}ˆ ˆd|f¡‘qS©r)rƒr)rþrir rržqsrlN) r3r…rñÚtuplerbrRr5rqrGrþrŒ)r@r"r`r )rþrir@rÚ add_headersXs   zConfiguration.add_headerscOs| dd¡}t||j|dS)a«Apply glob to paths and prepend local_path if needed. Applies glob.glob(...) to each path in the sequence (if needed) and pre-pends the local_path if needed. Because this is called on all source lists, this allows wildcard characters to be specified in lists of sources for extension modules and libraries and scripts and allows path-names be relative to the source directory. r£T)r¢r£)r[r5r¢)r@r…Úkwsr£r r rr…zs þzConfiguration.pathscCs4| ¡D]&}||}|dkr| |¡}|||<qdS)N)rúr&rAÚ library_dirsZ module_dirsÚ extra_objects)rXr…)r@ÚkwÚkrbZnew_vr r rÚ_fix_paths_dict‰s   zConfiguration._fix_paths_dictcKsät |¡}t|j|ƒ|d<||d<d|krt|d}|d=t|tƒrH|g}|D]&}t|tƒsftt|ƒƒ‚t|f|ŽqL| |¡|  dg¡}g}g|d<|D]Ü} t| t ƒr¶| | d¡d| krl|   dd¡\} } t j  t|j| ƒ¡} t j  | ¡rl|jd| dd } t| tƒr|  ¡} d d „|   dg¡DƒD]<} |   d d¡d }|| kr,|  dd¡t|f| Žqšq,qš| | ¡qš||d|d<|j|  dg¡|d<d dlm}|f|Ž}|j |¡| ¡}|dk rà| d|¡|S)a»Add extension to configuration. Create and add an Extension instance to the ext_modules list. This method also takes the following optional keyword arguments that are passed on to the Extension constructor. Parameters ---------- name : str name of the extension sources : seq list of the sources. The list of sources may contain functions (called source generators) which must take an extension instance and a build directory as inputs and return a source file or list of source files or None. If None is returned then no sources are generated. If the Extension instance has no sources after processing all source generators, then no extension module is built. include_dirs : define_macros : undef_macros : library_dirs : libraries : runtime_library_dirs : extra_objects : extra_compile_args : extra_link_args : extra_f77_compile_args : extra_f90_compile_args : export_symbols : swig_opts : depends : The depends list contains paths to files or directories that the sources of the extension module depend on. If any path in the depends list is newer than the extension module, then the module will be rebuilt. language : f2py_options : module_dirs : extra_info : dict or list dict or list of dict of keywords to be appended to keywords. Notes ----- The self.paths(...) method is applied to all lists that may contain paths. r=rúÚ extra_inforBrlú@Nr»rwcSsg|] }|d‘qSr˜r )rNr–r r rržász/Configuration.add_extension..Z__OF__rrE©Ú ExtensionzTdistutils distribution has been initialized, it may be too late to add an extension )rTr.r=rñrYrprqrr r[r™rhrSrirnr1r¢rrorrer”rƒrErQr¤r?rGrk)r@r=rúržZext_argsr¡rhrBZlibnamesZlibnameÚlnameZlpathr r–Zllnamer¤r'r`r r rÚ add_extension‘s^0      ÿ     ÿ    ÿzConfiguration.add_extensioncKs2| ||d|¡| ¡}|dk r.| d|¡dS)aÒ Add library to configuration. Parameters ---------- name : str Name of the extension. sources : sequence List of the sources. The list of sources may contain functions (called source generators) which must take an extension instance and a build directory as inputs and return a source file or list of source files or None. If None is returned then no sources are generated. If the Extension instance has no sources after processing all source generators, then no extension module is built. build_info : dict, optional The following keys are allowed: * depends * macros * include_dirs * extra_compiler_args * extra_f77_compile_args * extra_f90_compile_args * f2py_options * language NzQdistutils distribution has been initialized, it may be too late to add a library )Ú _add_libraryrGrk)r@r=rúr>r`r r rÚ add_libraryøs ÿzConfiguration.add_librarycCs@t |¡}||d<d|kr"g|d<| |¡|j ||f¡dS)z\Common implementation for add_library and add_installed_library. Do not use directlyrúr&N)rTr rBrƒ©r@r=rúÚ install_dirr>r r rr§s   zConfiguration._add_librarycCs@|si}tj |j|¡}| ||||¡|j t|||ƒ¡dS)aQ Similar to add_library, but the specified library is installed. Most C libraries used with `distutils` are only used to build python extensions, but libraries built through this method will be installed so that they can be reused by third-party packages. Parameters ---------- name : str Name of the installed library. sources : sequence List of the library's source files. See `add_library` for details. install_dir : str Path to install the library, relative to the current sub-package. build_info : dict, optional The following keys are allowed: * depends * macros * include_dirs * extra_compiler_args * extra_f77_compile_args * extra_f90_compile_args * f2py_options * language Returns ------- None See Also -------- add_library, add_npy_pkg_config, get_info Notes ----- The best way to encode the options required to link against the specified C libraries is to use a "libname.ini" file, and use `get_info` to retrieve the required options (see `add_npy_pkg_config` for more information). N)rSrirjrNr§rDrƒr<r©r r rÚadd_installed_library,s ,z#Configuration.add_installed_librarycCsZ|dkr i}tj |j|¡}|j|jkrB|j|j |||f¡n|||fg|j|j<dS)a Generate and install a npy-pkg config file from a template. The config file generated from `template` is installed in the given install directory, using `subst_dict` for variable substitution. Parameters ---------- template : str The path of the template, relatively to the current package path. install_dir : str Where to install the npy-pkg config file, relatively to the current package path. subst_dict : dict, optional If given, any string of the form ``@key@`` will be replaced by ``subst_dict[key]`` in the template file when installed. The install prefix is always available through the variable ``@prefix@``, since the install prefix is not easy to get reliably from setup.py. See also -------- add_installed_library, get_info Notes ----- This works for both standard installs and in-place builds, i.e. the ``@prefix@`` refer to the source directory for in-place builds. Examples -------- :: config.add_npy_pkg_config('foo.ini.in', 'lib', {'foo': bar}) Assuming the foo.ini.in file has the following content:: [meta] Name=@foo@ Version=1.0 Description=dummy description [default] Cflags=-I@prefix@/include Libs= The generated file will have the following content:: [meta] Name=bar Version=1.0 Description=dummy description [default] Cflags=-Iprefix_dir/include Libs= and will be installed as foo.ini in the 'lib' subpath. When cross-compiling with numpy distutils, it might be necessary to use modified npy-pkg-config files. Using the default/generated files will link with the host libraries (i.e. libnpymath.a). For cross-compilation you of-course need to link with target libraries, while using the host Python installation. You can copy out the numpy/core/lib/npy-pkg-config directory, add a pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment variable to point to the directory with the modified npy-pkg-config files. Example npymath.ini modified for cross-compilation:: [meta] Name=npymath Description=Portable, core math library implementing C99 standard Version=0.1 [variables] pkgname=numpy.core pkgdir=/build/arm-linux-gnueabi/sysroot/usr/lib/python3.7/site-packages/numpy/core prefix=${pkgdir} libdir=${prefix}/lib includedir=${prefix}/include [default] Libs=-L${libdir} -lnpymath Cflags=-I${includedir} Requires=mlib [msvc] Libs=/LIBPATH:${libdir} npymath.lib Cflags=/INCLUDE:${includedir} Requires=mlib N)rSrirjrNr=rGrƒ)r@ÚtemplaterªZ subst_dictr r rÚadd_npy_pkg_config_s_ ÿÿz Configuration.add_npy_pkg_configcGsH| |¡}| ¡}|dk r8|jdkr*g|_|j |¡n |j |¡dS)zµAdd scripts to configuration. Add the sequence of files to the beginning of the scripts list. Scripts will be installed under the /bin/ directory. N)r…rGr(rŒ)r@r"r(r`r r rÚ add_scriptsÊs  zConfiguration.add_scriptsc Ks|jD] }t||ƒ}| | |g¡¡q|jD] }t||ƒ}| | |i¡¡q.|j|j|j}| ¡D]ª}||krÒt||dƒ}|r”|||kr”qj| d|||| dd¡f¡t ||||ƒ|j  |¡qj||jkrü|  d|t||ƒ||f¡qj||krqjt d|ƒ‚qjdS)Nz"Inheriting attribute %r=%r from %rr=rœz*Ignoring attempt to set %r (from %r to %r)zDon't know about key=%r) rQr\rŒr[rSÚupdaterWrXrkrUrƒrhr•)r@rYrmrfrcr r rrÚs0      ÿ ÿ zConfiguration.dict_appendcCsvddlm}|j|j|j}d}|d|jd7}| ¡|D](}t||dƒ}|r@|d|||ƒf7}q@|d7}|S)Nr)Úpformatz<----- zConfiguration of z: z%s = %s z----->)Úpprintr°rQrSrWr=Úsortr\)r@r°rcr‘rŸrfr r rÚ__str__ós  zConfiguration.__str__cCsJtdƒ}| ¡d|_d|_tj d¡}|rFtj d|g¡}|tjd<|S)zF Returns the numpy.distutils config command instance. r„rÚPATHrv) rÚensure_finalizedZ dump_sourceZnoisyrSrZr[Úpathseprj)r@ÚcmdÚold_pathrir r rÚget_config_cmds  zConfiguration.get_config_cmdcCstdƒ}| ¡|jS)zh Return a path to a temporary directory where temporary files should be placed. rI)rrµÚ build_temp)r@r·r r rÚget_build_temp_dirsz Configuration.get_build_temp_dircCsd}| ¡}|j|dd}|S)aSCheck for availability of Fortran 77 compiler. Use it inside source generating function to ensure that setup distribution instance has been initialized. Notes ----- True if a Fortran 77 compiler is available (because a simple Fortran 77 code was able to be compiled successfully). ú/ subroutine simple end rø©Úlang©r¹Z try_compile©r@Zsimple_fortran_subroutineZ config_cmdÚflagr r rÚ have_f77cs zConfiguration.have_f77ccCsd}| ¡}|j|dd}|S)aRCheck for availability of Fortran 90 compiler. Use it inside source generating function to ensure that setup distribution instance has been initialized. Notes ----- True if a Fortran 90 compiler is available (because a simple Fortran 90 code was able to be compiled successfully) r¼r÷r½r¿rÀr r rÚ have_f90c*s zConfiguration.have_f90ccCsft|ƒr$|\}}t||j|jdn>ddlm}t||ƒsFtt|ƒƒ‚|j  |j¡|j  |j¡dS)zEAppend libraries, include_dirs to extension or library item. )rBrArr£N) r2rrBrArQr¤rñrprqrŒ)r@ZextlibZlib_namer>r¤r r rÚ append_to=sþ zConfiguration.append_toc Csüztjdgd|d}Wntjtfk r0Yn Xt d|¡}|rPt| d¡ƒStj dkrvt j   dd¡rvt |d d ƒ}n t |d d ƒ}t j |¡røt|ƒ}| ¡}W5QRX|dd …d krÚt d|¡}|røt| d¡ƒSnt d|¡}|røt| d¡ƒSdS)z+Return path's SVN revision number. Z svnversionT©ÚshellÚcwdó(?P\d+)ÚrevisionrÚZSVN_ASP_DOT_NET_HACKNZ_svnÚentriesr r¾z\d+)"zdir[\n\r]+(?P\d+))Ú subprocessÚ check_outputÚCalledProcessErrorr rÚmatchrYrìr}r·rSrZr[r1rirr‰Úreadr)r@riÚoutputrïrÊrîZfstrr r rÚ_get_svn_revisionKs2ÿ       zConfiguration._get_svn_revisionc Cs ztjdgd|d}Wntjtfk r0Yn Xt d|¡}|rPt| d¡ƒSt|ddƒ}t|ddƒ}t j   |¡rd }t |ƒ}|  ¡ ¡}W5QRXi} t|d ƒD]R} |  ¡d d …\} } | |krÌ| }z t| ƒ} Wntk rðYq¨YnX| | | <q¨|  |¡Sd S) z1Return path's Mercurial revision number. zhg identify --numTrÅrÈrÉz.hgÚbranchz branch.cacheNrér»)rËrÌrÍr rrÎrYrìr1rSrirr‰rÏr‹Úfilerhr•r[) r@rirÐrïZ branch_fnZbranch_cache_fnZbranch0rîZ revision0Z branch_mapr’Zbranch1Z revision1r r rÚ_get_hg_revisionis:ÿ         zConfiguration._get_hg_revisionc Csšt|ddƒ}|dk r|S|dkr@d|j d¡ddddd g}n|g}|dkrjdd |j d¡dd g}n|g}|D]Ò}t|j|ƒ}tj |¡rtd }tj tj  |¡¡d } t |j| ƒ} zt d  |  d¡¡||ƒ} Wn.t k rtƒ} | t| ƒ¡d} YnX| dkrqt|D]"} t| | dƒ}|dk rq8q|dk rtqHqt|dk r\||_|S| |j¡}|dkr~| |j¡}|dk r–t|ƒ}||_|S)a¹Try to get version string of a package. Return a version string of the current package or None if the version information could not be detected. Notes ----- This method scans files named __version__.py, _version.py, version.py, and __svn_version__.py for string variables version, __version__, and _version, until a version number is found. rÜNz__version__.pyrvrÛz _version.pyz version.pyú__svn_version__.pyú__hg_version__.pyÚ __version__Ú_versionrtrr=)r\r=rhr1r¢rSrirr€rr.rrjÚ ImportErrorrrkrÎrÜrÑrÔ)r@Z version_fileZversion_variablerÜr"Z version_varsrîrrhr=r¤Zversion_moduleÚmsgrfrÉr r rÚ get_versionŽsd üþ   ÿ          zConfiguration.get_versionTcsVtˆjdƒ‰ˆ ˆj¡‰tj ˆ¡s,ˆdkr0dS‡‡‡‡fdd„}ˆ d|ƒf¡dS)aAppends a data function to the data_files list that will generate __svn_version__.py file to the current package directory. Generate package __svn_version__.py file from SVN revision number, it will be removed after python exits but will be available when sdist, etc commands are executed. Notes ----- If __svn_version__.py existed before, nothing is done. This is intended for working with source directories that are in an SVN repository. rÕNc sltj ˆ¡sJtˆƒ}ˆ dˆ|f¡tˆdƒ}| d|¡W5QRXˆˆjf‡fdd„ }t |¡ˆS)NúCreating %s (version=%r)r«ú version = %r cspˆrlzt |¡|d|ƒWntk r2YnXz"t |d¡|d|dƒWntk rjYnXdS©Nzremoved r ©rSÚremover ©rîr†©Údeleter rÚrm_fileðs zSConfiguration.make_svn_version_py..generate_svn_version_py..rm_file© rSrirrÎrhr‰rjÚatexitÚregister©rÜrîrä©rãrÉr@Útargetr rÚgenerate_svn_version_pyés   zBConfiguration.make_svn_version_py..generate_svn_version_pyrk)r1r¢rÑrSrirr“)r@rãrër rérÚmake_svn_version_pyÔs   z!Configuration.make_svn_version_pycsVtˆjdƒ‰ˆ ˆj¡‰tj ˆ¡s,ˆdkr0dS‡‡‡‡fdd„}ˆ d|ƒf¡dS)aAppends a data function to the data_files list that will generate __hg_version__.py file to the current package directory. Generate package __hg_version__.py file from Mercurial revision, it will be removed after python exits but will be available when sdist, etc commands are executed. Notes ----- If __hg_version__.py existed before, nothing is done. This is intended for working with source directories that are in an Mercurial repository. rÖNc sltj ˆ¡sJtˆƒ}ˆ dˆ|f¡tˆdƒ}| d|¡W5QRXˆˆjf‡fdd„ }t |¡ˆS)NrÜr«rÝcspˆrlzt |¡|d|ƒWntk r2YnXz"t |d¡|d|dƒWntk rjYnXdSrÞrßrárâr rräs zQConfiguration.make_hg_version_py..generate_hg_version_py..rm_filerårèrér rÚgenerate_hg_version_pys   z@Configuration.make_hg_version_py..generate_hg_version_pyrk)r1r¢rÔrSrirr“)r@rãrír rérÚmake_hg_version_pyýs   z Configuration.make_hg_version_pyÚ __config__cCs|j |j|tf¡dS)zÉGenerate package __config__.py file containing system_info information used during building the package. This file is installed to the package installation directory. N)rCrƒr=r)r@r=r r rÚmake_config_py%szConfiguration.make_config_pycGs2ddlm}m}i}|D]}||f||ƒŽq|S)z¥Get resources information. Return information (from system_info.get_info) for all of the names in the argument list in a single dictionary. rl)r9r)Ú system_infor9r)r@Únamesr9rZ info_dictrfr r rr9/s zConfiguration.get_info)NNNNrlrH)rl)rl)NNrl)NF)N)N)NN)T)T)rï)-rBrCrDrPrRrVÚnumpy_include_dirsrArerhrkr\rGrsr…ror‡rˆrdr“r–r—ršr…r r¦r¨r§r«r­r®rr³r¹r»rÂrÃrÄrÑrÔrÛrìrîrðr9r r r rrÛs~þú aþ ü -ý >þ +y "g$ 3 k  % F ) ( cCsN||krFddl}|jj}|dkr4ddlm}|dƒ‚| |¡}|||<||S)Nr)ÚDistutilsInternalErrorz+setup distribution instance not initialized)Údistutils.coreÚcoreÚ_setup_distributionÚdistutils.errorsrôr])ZcmdnameÚ_cacher0r`rôr·r r rr<s ÿ cCs(tjdd…}|s$ddl}| ¡g}|S)Nr)rróÚnumpyZ get_include)rArúr r rrHs  cCs@ddl}tj d¡}|dk r |Stj tj |j¡ddd¡}|S)a³Return the path where to find the npy-pkg-config directory. If the NPY_PKG_CONFIG_PATH environment variable is set, the value of that is returned. Otherwise, a path inside the location of the numpy module is returned. The NPY_PKG_CONFIG_PATH can be useful when cross-compiling, maintaining customized npy-pkg-config .ini files for the cross-compilation environment, and using them when cross-compiling. rNZNPY_PKG_CONFIG_PATHrör)znpy-pkg-config)rúrSrZr[rirjrzru)rúr r r rÚget_npy_pkg_dirQs  ÿrûcCs0ddlm}|r| tƒ¡ntƒg}|||ƒS)aø Return library info for the given package. Parameters ---------- pkgname : str Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini). dirs : sequence, optional If given, should be a sequence of additional directories where to look for npy-pkg-config files. Those directories are searched prior to the NumPy directory. Returns ------- pkginfo : class instance The `LibraryInfo` instance containing the build information. Raises ------ PkgNotFound If the package is not found. See Also -------- Configuration.add_npy_pkg_config, Configuration.add_installed_library, get_info r)Ú read_config)Únumpy.distutils.npy_pkg_configrürƒrû)ÚpkgnamerŽrür r rr:fs  cCsfddlm}t||ƒ}|| ¡ƒ}|| ¡ƒ ¡D]\}}|| |¡q2|d|d<|d=|d=|S)a9 Return an info dict for a given C library. The info dict contains the necessary options to use the C library. Parameters ---------- pkgname : str Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini). dirs : sequence, optional If given, should be a sequence of additional directories where to look for npy-pkg-config files. Those directories are searched prior to the NumPy directory. Returns ------- info : dict The dictionary with build information. Raises ------ PkgNotFound If the package is not found. See Also -------- Configuration.add_npy_pkg_config, Configuration.add_installed_library, get_pkg_info Examples -------- To get the necessary information for the npymath library from NumPy: >>> npymath_info = np.distutils.misc_util.get_info('npymath') >>> npymath_info #doctest: +SKIP {'define_macros': [], 'libraries': ['npymath'], 'library_dirs': ['.../numpy/core/lib'], 'include_dirs': ['.../numpy/core/include']} This info dict can then be used as input to a `Configuration` instance:: config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info) r)Ú parse_flagsr•rEZignored)rýrÿr:ÚcflagsZlibsrlrŒ)rþrŽrÿÚpkg_inforhrŸrbr r rr9Œs-    cCsHtjddkrddl}nddl}z |jWdStk rBYdSXdS)Nrr¼TF)r}r‚ÚbuiltinsÚ __builtin__Z__NUMPY_SETUP__rU)rr r rÚis_bootstrappingÈs rcCs:ddl}|jd||||||fddt|||ƒ}| ¡S)zqReturn a configuration dictionary for usage in configuration() function defined in file setup_.py. rNzXUse Configuration(%r,%r,top_path=%r) instead of deprecated default_config_dict(%r,%r,%r)r»)Ú stacklevel)Úwarningsrkrre)r=r_r¢rr r r rr×sÿþü cKsR| ¡D]D\}}||krD||}t|tƒr4|||<qL|| |¡q|||<qdSr)rlrñrÎrŒ)r r›rŸrbÚovr r rrås  cCs,tjjdkr,| dtjj¡}| dtjj¡}d}tj |¡rtj |¡d}tj tj |¡¡d}tj |¡\}}tj ||g¡}tj |dt |ƒ…|t |ƒd…¡|ksÚtj |dt |ƒ…|t |ƒd…¡|krætj  |¡}|t |ƒd…}tj |¡r|dd…}n|}tj  t |||ƒ¡S)Nrgrkrrl) rSriror„r‹Ú splitdrivernrrjrRrzÚnormpathr1)r¨riÚdriveZ absprefixZ pathdriver Úsubpathr r rrðs$ *(ÿ c Cs¸ddlm}ddlm}|tj |¡ƒt|dƒ|}| dtj  t j d¡¡| d¡| d¡| t   d¡¡|j ¡D]\}}| d ||f¡q~| t   d ¡¡W5QRX|S) zÅGenerate config.py file containing system_info information used during building the package. Usage: config['py_modules'].append((packagename, '__config__',generate_config_py)) r)rñ)Úmkpathr«z'# This file is generated by numpy's %s zH# It contains system_info results at the time of building this package. z__all__ = ["get_info","show"] aË import os import sys extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs') if sys.platform == 'win32' and os.path.isdir(extra_dll_dir): if sys.version_info >= (3, 8): os.add_dll_directory(extra_dll_dir) else: os.environ.setdefault('PATH', '') os.environ['PATH'] += os.pathsep + extra_dll_dir z%s=%r a¹ def get_info(name): g = globals() return g.get(name, g.get(name + "_info", {})) def show(): for name,info_dict in globals().items(): if name[0] == "_" or type(info_dict) is not type({}): continue print(name + ":") if not info_dict: print(" NOT AVAILABLE") for k,v in info_dict.items(): v = str(v) if k == "sources" and len(v) > 200: v = v[:60] + " ...\n... " + v[-60:] print(" %s = %s" % (k,v)) )Znumpy.distutils.system_inforñÚdistutils.dir_utilr rSrirzr‰rjrr}ÚargvÚtextwrapÚdedentZ saved_resultsrl)rêrñr rîrŸrer r rr s     cCs|jdkstd|jƒ‚|jS)zdReturn version major and minor of compiler instance if it is MSVC, raise an exception otherwise.Zmsvcz"Compiler instance is not msvc (%s))Ú compiler_typer•Z_MSVCCompiler__version)Úcompilerr r rÚ msvc_version: s  ÿrcCsddlm}|ƒS)Nr©r8)Zdistutils.msvccompilerr8rr r rr8B s )N)N)rkT)rkrkT)NNF)NN)F)r)N)N)NNN)jÚ __future__rrrrSrr}rTr™rær­rËr rVrr0rørÚ threadingrZtlocalrÙZdummy_threadingr¬rrrçZnumpy.distutils.compatrZ numpy.compatrrÚ__all__Úobjectr<r;r7rrtr‚r1rr0ršr¡r5r²rrYrÌrÒrÕrrrr!r r"r#rÞrâràrÚIrÎrýrùrêrërðr3r$r2rör4r6r%r&r'rrrr(r)rr#r*r+r,r3r-r.r/rrrrûr:r9rrrrrrr8r r r rÚs,     õ $   %   ÿ            / k   & <  5