B { `­Mã)@sªddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z yddlmZWn ek rœddlmZYnXeƒZgZdd„Ze e¡ddlmZddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/g)ZGd0d1„d1ƒZd2d/„Zd3d+„Zd4d„Zd5d6„Zd–d7d8„Zd9d%„Z d—d:d„Z!d;d$„Z"dd?„Z$d˜dBd)„Z%d™dCdD„Z&dEd„Z'e'ƒrÈe(ddFdGdHdIdJdKdLdMdN Z)dšdPdQ„Z*n d›dRdQ„Z*dSdT„Z+dUd„Z,dVd„Z-dWd„Z.dXd„Z/dYd„Z0dZd„Z1d[d„Z2d\d]„Z3d^d_„Z4d`da„Z5e 6dbej7¡j8Z9e 6dcej7¡j8Z:e 6ddej7¡j8Z;e 6deej7¡j8Zdid„Z?djd&„Z@dkdl„ZAdmd(„ZBdnd*„ZCdod„ZDdpd„ZEdqd„ZFdrds„ZGdtdu„ZHdvdw„ZIdxd„ZJdyd„ZKdzd{„ZLd|d}„ZMd~d„ZNdd„ZOd€d „ZPdœdd‚„ZQdƒd!„ZRd„d"„ZSdd…d#„ZTGd†d„dƒZUifd‡d „ZVdˆd„ZWd‰dŠ„ZXdžd‹d.„ZYdŸdŒd-„ZZddŽ„Z[d dd „Z\dd „Z]d‘d „Z^d’d „Z_d“d”„Z`d•d,„ZadS)¡éN)ÚDistutilsError)Úlocalc Cs>tdk r:x0tD](}yt |¡Wqtk r4YqXqWdS)N)Ú_tmpdirsÚshutilÚrmtreeÚOSError)Úd©r ú=/tmp/pip-unpacked-wheel-4iou4664/numpy/distutils/misc_util.pyÚclean_up_temporary_directorys  r )Únpy_load_moduleÚ ConfigurationÚget_numpy_include_dirsÚdefault_config_dictÚ dict_appendÚ appendpathÚgenerate_config_pyÚget_cmdÚallpathÚ get_mathlibsÚterminal_has_colorsÚred_textÚ green_textÚ yellow_textÚ blue_textÚ cyan_textÚ cyg2win32Úmingw32Ú all_stringsÚ has_f_sourcesÚhas_cxx_sourcesÚfilter_sourcesÚget_dependenciesÚis_local_src_dirÚget_ext_source_filesÚget_script_filesÚget_lib_source_filesÚget_data_filesÚdot_joinÚ get_frameÚ minrelpathÚnjoinÚ is_sequenceÚ is_stringÚas_listÚgpathsÚ get_languageÚ quote_argsÚget_build_architectureÚget_infoÚ get_pkg_infoÚget_num_build_jobsc@seZdZdZdd„ZdS)ÚInstallableLibaÏ Container to hold information on an installable library. Parameters ---------- name : str Name of the installed library. build_info : dict Dictionary holding build information. target_dir : str Absolute path specifying where to install the library. See Also -------- Configuration.add_installed_library Notes ----- The three parameters are stored as attributes with the same names. cCs||_||_||_dS)N)ÚnameÚ build_infoÚ target_dir)Úselfr7r8r9r r r Ú__init__HszInstallableLib.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r;r r r r r62sr6cCsÊddlm}ytt 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|]}|dkVqdS)Nr )Ú.0Úxr r r ú msz%get_num_build_jobs..css|]}|dk r|VqdS)Nr )rFrGr r r rHps)Únumpy.distutils.corer@ÚlenÚosÚsched_getaffinityÚAttributeErrorÚmultiprocessingÚ cpu_countÚminÚintÚenvironÚgetÚgetattrÚget_command_objÚallÚmax)r@rOZenvjobsÚdistZcmdattrr r r r5Ns   cCsJt|ƒ}x|D]6}| |¡rr|t|ƒd…  ¡}|rr|  |  d¡¡qrWWdQRX|S)z/Return the MATHLIB line from numpyconfig.h Nz_numpyconfig.hz1_numpyconfig.h not found in numpy include dirs %rz#define MATHLIBú,) rKrarbrÚexistsrÚopenÚ startswithrJÚstripÚextendr`) raÚ config_fileÚdirsÚfnÚfidZmathlibsÚsÚlineÚvaluer r r rÈs&      cCsÔt|ƒs |Sd|kr|S| tj¡}x6|rZy| dd¡}Wntk rPPYnX||=q&Wd}x^|r¾y| d|¡}Wntk rŒPYnX||ddkr¨|d7}qb||=||d=d}qbW|sÈdStj |¡S)z$Resolve `..` and '.' from path. rnrdz..rc)r-r`rKrgÚindexÚ ValueErrorrb)raÚlr]Újr r r r*ã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’cCsPt|ƒsttt|ƒƒƒ‚g}t|ƒr0tt|ƒƒ‚x|D]}t|ƒrd|ksXd|kr®t|ƒ}tt||ƒƒ}|r~| |¡n.|rŽ| |¡n|rœ| |¡t d||fƒnft||ƒ}t j   |¡rÐ| |¡nDt j   |¡rè| |¡n|rö| |¡t j   |¡s>t d||fƒq8t|ƒr4| t |||ƒ¡q8| |¡q8Wdd„|DƒS)NÚ*ú?z#could not resolve pattern in %r: %rznon-existing path in %r: %rcSsg|] }t|ƒ‘qSr )r*)rFr~r r r ú (sz_fix_paths..)r,rhriÚtyper-r’r+r„r{ÚprintrKrar€Ú _fix_paths)r}Ú local_pathÚinclude_non_existingZ new_pathsÚnr~Úp2Zn2r r r r˜s<           r˜rcTcCst|ƒr|f}t|||ƒS)z:Apply glob to paths and prepend local_path if needed. )r-r˜)r}r™ršr r r r/*scCsLttdƒs t ¡t_t tj¡tj||tj|d\}}t  |d¡}||fS)NÚtempdir)ÚsuffixÚprefixÚdirÚtextÚw) rwÚ_tdataÚtempfileÚmkdtemprrr{ÚmkstemprKÚfdopen)ržrŸr¡rˆr7Úfor r r Úmake_temp_file1s     r©cCsÂtjdkrdtjkrdSttjdƒr¾tj ¡r¾yzddl}| ¡|  d¡dkr¦|  d¡dkr¦|  d¡dk rx|  d¡dk s¢|  d ¡dk r”|  d ¡dk s¢|  d ¡dk r¦d SWnt k r¼YnXdS) NÚcygwinZ USE_COLORrÚisattyÚcolorsÚpairsZsetfZsetbZsetafZsetabZscprd) ruÚplatformrKrRrwÚstdoutr«ÚcursesZ setuptermZtigetnumZtigetstrÚ Exception)r°r r r r>s" rdééééééé ) 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_codesrSÚlowerÚstrrb)r‰ÚfgÚbgZboldÚseqZfgcodeZbgcoder r r Ú colour_text\s rÉcCs|S)Nr )r‰rÆrÇr r r rÉkscCs t|dƒS)Nr¾)rÉ)r‰r r r Ú default_textnsrÊcCs t|dƒS)Nr¹)rÉ)r‰r r r rpscCs t|dƒS)Nrº)rÉ)r‰r r r rrscCs t|dƒS)Nr»)rÉ)r‰r r r rtscCs t|dƒS)Nr½)rÉ)r‰r r r rvscCs t|dƒS)Nr¼)rÉ)r‰r r r rxscCs8tjdkr4| d¡r4|ddtj |dd…¡}|S)Nrªz /cygdriveé ú:é )rur®r‚rKraÚnormcase)rar r r r}s cCs:tjdkr6tj dd¡dkr dStj dd¡dkr6dSdS) z0Return true when using mingw32 environment. Úwin32ZOSTYPErcZmsysTZMSYSTEMZMINGW32F)rur®rKrRrSr r r r r‚s  cCs8tj d¡}|dkr0ttj|d|d…ƒ}nd}|S)zGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrozMSC v.éÿÿÿÿr¶rËN)ruÚversionÚfindrQ)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)rSrÓ)Úmajorr r r rÕ s rÕz.*[.](cpp|cxx|cc)\Zz.*[.](f90|f95|f77|for|ftn|f)\Zz.*[.](f90|f95)\Zz\s*module\s*(?P[\w_]+)c CsXt|ƒs gSg}t|dƒ4}x,|D]$}t|ƒ}|r"| d¡}| |¡q"WWdQRX|S)zRReturn a list of Fortran f90 module names that given source file defines. Úrr7N)Ú f90_ext_matchrÚf90_module_name_matchÚgroupr{)ÚsourcervÚfrŠÚmr7r r r Ú_get_f90_modules²s   råcCs t|tƒS)N)Ú isinstancerÅ)r‰r r r r-ÂscCsx|D]}t|ƒsdSqWdS)z4Return True if all items in lst are string objects. FT)r-)ÚlstÚitemr r r rÅs cCs2t|ƒr dSy t|ƒWntk r,dSXdS)NFT)r-rJr±)rÈr r r r,Ìs cCst|ƒod|kpd|kS)Nr“r”)r-)r‰r r r Úis_glob_patternÕsrécCst|ƒrt|ƒS|gSdS)N)r,rZ)rÈr r r r.ØscCs<d}x2|D]*}t|tƒr t|ƒr(d}Pq t|ƒr d}q W|S)z2Determine language value (c,f77,f90) from sources NÚf90Úf77)rærÅrßÚfortran_ext_match)ÚsourcesÚlanguagerâr r r r0Þs  cCsx|D]}t|ƒrdSqWdS)z.Return True if sources contains Fortran files TF)rì)rírâr r r rës cCsx|D]}t|ƒrdSqWdS)z*Return True if sources contains C++ files TF)Ú cxx_ext_match)rírâr r r r òs cCstg}g}g}g}xV|D]N}t|ƒrFt|ƒ}|r:| |¡qd| |¡qt|ƒrZ| |¡q| |¡qW||||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ârvr r r r!ùs    cCs2g}x(|D] }ttj |d¡ƒ}| |¡q W|S)Nz*.h)r’rKrarbr„)Zdirectory_listÚheadersrÚheadr r r Ú _get_headerss  ròcCsHg}x>|D]6}tj |¡}|ddkr |d|kr | |d¡q W|S)Nrrc)rKrar`r{)Zlist_of_sourcesZdirecsrãrr r r Ú_get_directoriess   rócCs6d}|d |¡7}|d |¡7}|d |¡d7}|S)zb Return commandline representation used to determine if a file needs to be recompiled z commandline: rYÚ )rb)Zcc_argsZextra_postargsZpp_optsZcmdliner r r Ú_commandline_dep_string!s rõcCs tt|ƒƒS)N)ròró)rír r r r"-scCsˆt|ƒs dStj |¡}tj t ¡|g¡}|t|ƒd… tj¡}|r\|ds\|dd…}|rp|ddkrpdStj  |¡}tj  |¡S)z1Return true if directory is local directory. FNrrdrB) r-rKrarfÚ commonprefixÚgetcwdrJr`rgrbÚisdir)Ú directoryZabs_dirÚcZnew_dirr r r r#1s    c#s~ddddœ‰t d¡}xbtj|ddD]P\}}}‡fdd„|Dƒ}||dd…<x&|D]}| |¡sTtj ||¡VqTWq&WdS)Nrd)ÚCVSz.svnrBz(?:[~#]|\.py[co]|\.o)$T)Útopdowncsg|]}|ˆkr|‘qSr r )rFr)Úpruned_directoriesr r r•Dsz(general_source_files..)ÚreÚcompilerKÚwalkÚsearchrarb)Útop_pathÚprune_file_patÚdirpathÚdirnamesÚ filenamesÚprunedrãr )rýr Úgeneral_source_files@s     rc #s dddg‰t d¡‰x°tj|ddD]ž\}}}‡fdd„|Dƒ}||d d …<xt|D]l}tj ||¡‰tˆ|ƒ}g}x@t ˆ¡D]2}tj ˆ|¡} tj | ¡r~ˆ  | ¡s~|  | ¡q~W||fVqRWq$W|‰tˆ|ƒ}‡‡fd d„t ˆ¡Dƒ}d d„|Dƒ}||fVd S) zJReturn a directory name relative to top_path and files contained. rûz.svnrBz(?:[~#]|\.py[co]|\.o)$T)rücsg|]}|ˆkr|‘qSr r )rFr)rýr r r•Qsz4general_source_directories_files..Ncs$g|]}ˆ |¡stj ˆ|¡‘qSr )rrKrarb)rFrã)Údpathrr r r•^scSsg|]}tj |¡r|‘qSr )rKraÚisfile)rFrãr r r r•`s) rþrÿrKrrarbrlÚlistdirr rr{) rrrrrrÚrpathÚfilesrãr‡r )r rrýr Ú general_source_directories_filesJs&      rcCsrg}dd„|jDƒ}| |¡| t|ƒ¡x@|jD]6}t|ƒrT| tt|ƒƒ¡q4tj  |¡r4|  |¡q4W|S)NcSsg|]}t|ƒr|‘qSr )r-)rFÚ_mr r r r•gsz(get_ext_source_files..) rír„r"Údependsr#rZrrKrar r{)Úextrrírr r r r$ds   cCsdd„|Dƒ}|S)NcSsg|]}t|ƒr|‘qSr )r-)rFrr r r r•rsz$get_script_files..r )Úscriptsr r r r%qscCsŽg}|d dg¡}dd„|Dƒ}| |¡| t|ƒ¡|d dg¡}x>|D]6}t|ƒrp| tt|ƒƒ¡qPtj |¡rP|  |¡qPW|S)NrdrícSsg|]}t|ƒr|‘qSr )r-)rFrr r r r•xsz(get_lib_source_files..r) rSr„r"r#rZrrKrar r{)Úlibrrírrr r r r&us   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ÚSOrcÚlinuxZ gnukfreebsdz.soÚdarwinz.dylibÚwinz.dllÚSOABIrnrd)Ú distutilsÚ sysconfigÚget_config_varsrSrur®r‚r|)Z is_python_extZconfvarsZso_extr r r Úget_shared_lib_extensionƒs       rcCsŒt|ƒr|gS|d}g}xl|D]d}t|dƒr0q t|ƒrL| tt|ƒƒ¡q t|ƒrxtj |¡rl|  |¡q„t d|ƒq t t |ƒƒ‚q W|S)NrdÚ__call__zNot existing data file:) r-rwr#r„rZrrKrar r{r—Ú TypeErrorri)Údatarírr‰r r r r'²s     cGsd dd„|Dƒ¡S)NrncSsg|] }|r|‘qSr r )rFr^r r r r•Æszdot_join..)rb)r\r r r r(ÅscCsRyt |d¡Stk rLt ¡dj}xt|dƒD] }|j}q:W|SXdS)z:Return frame object from call stack with given level. rdr²N)ruÚ _getframerMÚexc_infoÚtb_framer[Úf_back)ÚlevelrxÚ_r r r r)Ès c @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_configr7rÑNrdú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…|_x0|jD]&} t | | g¡¡} t|| t| ƒƒqÒWx.|jD]$} t | | i¡¡} t|| | ƒqW|j|j} |jdd…|_xt| ¡D]h} | | krdqR|| } t|| | ƒt| tƒr’|j | ¡n&t| tƒr¬|j | ¡n |j | ¡qRWtj t |dƒ¡rì|j  |j¡||j!|j<tddddd|_"d} xht#dd ƒD]Z}y t|ƒ}Wnt k r6PYnXyt$d |j%|j&ƒ} PWnt'k rdYnXqWt| |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. Nrcrnz%r is not a directoryz __init__.pyF)Úignore_setup_xxx_pyÚassume_default_configurationÚdelegate_options_to_subpackagesÚquietrdr³r:r4)+r(r7rÑr)rzr™rKrarør+rrÚ package_pathrbr`Úpath_in_packageÚ _list_keysÚ list_keysÚ _dict_keysÚ dict_keysÚcopyrSÚsetattrr.Ú _extra_keysÚ extra_keysÚkeysrærZr{Údictr€r'r/Úoptionsr[rorprqrsÚ __class__Ú set_optionsÚ setup_name)r:Ú package_nameÚ parent_namerr6Ú caller_levelrEÚattrsZ caller_framer›ÚvÚ known_keysr^Zcaller_instancer]rãr r r r;àsv               zConfiguration.__init__cCsF| ¡i}|j|j|j}x"|D]}t||ƒ}|r$|||<q$W|S)zâ Return a dictionary compatible with the keyword arguments of distutils setup function. Examples -------- >>> setup(**config.todict()) #doctest: +SKIP )Ú_optimize_data_filesr9r;r?rT)r:rrKr›r^r r r ÚtodictAs    zConfiguration.todictcCs|jdst|ƒdS)Nr5)rBr—)r:Úmessager r r ÚinfoTs zConfiguration.infocCstj d|f¡dS)Nz Warning: %s )ruÚstderrÚwrite)r:rNr r r ÚwarnXszConfiguration.warncKs<x6| ¡D]*\}}||jkr(||j|<q td|ƒ‚q WdS)zå Configure Configuration instance. The following options are available: - ignore_setup_xxx_py - assume_default_configuration - delegate_options_to_subpackages - quiet zUnknown option: N)ÚitemsrBr)r:rBÚkeyr‹r r r rD[s   zConfiguration.set_optionscCsddlm}|ƒS)z2Return the distutils distribution object for self.r)r@)rIr@)r:r@r r r r@ls zConfiguration.get_distributionc Cs¦| d¡}t|jg|ƒ}dd„t|ƒDƒ}g}xp|D]h}tj t|dƒ¡sNq6d| tj¡kr`q6d | tj¡t |ƒ d…¡} |j | ||dd} |  | ¡q6W|S)NrncSsg|]}tj |¡r|‘qSr )rKrarø)rFrr r r r•vsz:Configuration._wildcard_get_subpackage..z __init__.pyrBrd)rGrH) r`r+r™r’rKrar rgrbrJÚget_subpackager„) r:Úsubpackage_namerGrHrŽÚsubpackage_pathr†Ú config_listrr›rúr r r Ú_wildcard_get_subpackageqs    z&Configuration._wildcard_get_subpackagec Cstj dtj |¡¡zðtj tj |¡¡d}t|j||ƒ}t d  |  d¡¡|dƒ}t |dƒs’|j dsx| d|¡t|||j||dd } nFt|g|  d¡dd …Ž} | f} |jjjdkrÎ| |jf} |j| Ž} | jt||ƒkr| d t||ƒ| jf¡Wdtjd=X| S) Nrr&rn)z.pyÚUrdÚ configurationr3zCAssuming default configuration (%s does not define configuration())rd)rHrÐz*Subpackage %r configuration returned as %r)ruraÚinsertrKrrÚsplitextÚbasenamer(r7r rbr`rwrBrRr rr[Ú__code__Ú co_argcount) r:Úsetup_pyrVrWrGrHrEr›Z setup_moduleÚconfigZpnr\r r r Ú _get_configuration_from_setup_py„s0     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 specifiedrnr“rd)rHrÐrr2z setup_%s.pyr3zEAssuming default configuration (%s/{setup_%s,setup}.py was not found))rrKrar^r`rYrhrir+r™r}rErBr rRrrr rrc)r:rVrWrGrHrŽrarbr r r rU¦sH         zConfiguration.get_subpackageFc Cs¶|r d}n|j}|j|||dd}|s0| d¡xb|D]Z}|}t|tƒrP| ¡}t|tƒsjttt |ƒƒƒ‚|  d|  d¡|jf¡|j f|Žq6W|  ¡}|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²)rGrHz0No configuration returned, assuming unavailable.z Appending %s configuration to %sr7zTdistutils distribution has been initialized, it may be too late to add a subpackage )r7rUrRrær rMrArhrir–rOrSrr@) r:rVrWÚ standalonerGrXrbrrXr 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 |ƒr0t ˆƒrt ˆƒ  tj ¡}|  ¡ttt|ƒdƒƒ}|  ¡x|D]}||sà||=qàWx2|D]}tj |¡std|ƒqþt|ˆjƒ}|  tj ¡}|  ¡g} d }x‚|D]z} t | ƒrˆ|t|ƒkrxtd ˆ|fƒ‚|  ||¡n4| ||ks²tt| |||ˆ||fƒƒ‚|  | ¡|d7}qLW||d…rꈠd ||f¡|   ¡ˆ tj  | ¡|f¡qþWnx|D]}ˆ ˆ|f¡qWdSt ˆƒrFttˆƒƒ‚ˆ ¡} | dk rl| jdk rl| j} nˆj} xJ|D]B}x:tt|ƒƒD]*\} }tj ˆjˆ| ¡}|  ||f¡qŠWqxWdS) 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_dir)rFr~)rr:r r r•Ksz.Configuration.add_data_dir..znot a string: %rF)ršrdzNot a directory, skippingrzcannot fill pattern %r with %rz,mismatch of pattern_list=%s and path_list=%s)r,r-rrKraÚisabsrfr^r}rérr`rgÚreverserZr[rJrør—rlr™rr{rhrirRrbr@r)rr7)r:Z data_pathr}Ú pattern_listZrlr]rar Ú path_listÚ target_listr‰rXr)Úd1rãÚ target_pathr )rr:r rfsr8            *    zConfiguration.add_data_dircCsfi}x@|jD]6\}}||kr&tƒ||<x|D]}|| |¡q,Wq Wdd„| ¡Dƒ|jdd…<dS)NcSsg|]\}}|t|ƒf‘qSr )rZ)rFr~r r r r r•Žsz6Configuration._optimize_data_files..)r)ÚsetÚaddrS)r:Z data_dictr~r rãr r r rL‡s  z"Configuration._optimize_data_filescGs8t|ƒdkr(x|D]}| |¡qWdSt|ƒdks8t‚t|dƒrR|d\}}nd}t|ƒrd|}nPt|ƒr¤t|ƒdkr‚|d}q´x|D]}| ||f¡qˆWdSnttt|ƒƒƒ‚|dkrüt|dƒrÌd}nt j   |¡rÞd}n t j   |¡}| ||f¡dS|j |dd}t|ƒrÔt|ƒrÂ| t j¡}| ¡xœ|D]„}| t j¡}| ¡| ¡g} d} x:|D]2} t| ƒrŒ|  || ¡| d7} n |  | ¡qfW|  ¡| t j | ¡|f¡q8Wn| ||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'). rdNrrrcF)rš)rJÚadd_data_filesrhr,r-rrir–rwrKrargrrr}rér`rgrhÚpopr{rbr@r)r7)r:r rãrZfilepatr}rirarjrkr]r‰rXr)r r r rpsfX                 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. Nr.)r@rwr.r„)r:ÚmacrosrXr r r Úadd_define_macros)s  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}r@r*r„)r:r}r*rXr r r Úadd_include_dirs9s  zConfiguration.add_include_dirscs¸g‰xt|D]l‰tˆƒr2‡‡fdd„ˆ ˆ¡Dƒq tˆttfƒrLtˆƒdkrXttˆƒƒ‚‡‡fdd„ˆ ˆd¡Dƒq Wˆ ¡}|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{r7)rFr~)rðr:r r r•^sz-Configuration.add_headers..r²csg|]}ˆ ˆd|f¡‘qS)r)r{)rFr~)rðrar r r•bsrdN) r-r}ræÚtuplerZrJrrir@rðr„)r:r rXr )rðrar:r Ú add_headersIs  " 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š)rSr/r™)r:r}Úkwsršr r r r}ks zConfiguration.pathscCs8x2| ¡D]&}||}|dkr | |¡}|||<q WdS)N)rírr*Ú library_dirsZ module_dirsÚ extra_objects)r@r})r:ÚkwÚkrJZnew_vr r r Ú_fix_paths_dictzs  zConfiguration._fix_paths_dictcKsît |¡}t|j|ƒ|d<||d<d|krx|d}|d=t|tƒrH|g}x.|D]&}t|tƒshtt|ƒƒ‚t|f|ŽqNW| |¡|  dg¡}g}g|d<xæ|D]Þ} t| t ƒr¼| | d¡d| krt|   dd¡\} } t j  t|j| ƒ¡} t j  | ¡rt|jd| dd } t| tƒr|  ¡} xTd d „|   dg¡DƒD]:} |   d d¡d }|| kr4|  dd¡t|f| ŽPq4Wq | | ¡q W||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. r7ríÚ extra_infor+rdú@Nr²)rHcSsg|] }|d‘qS)rr )rFrŽr r r r•Òsz/Configuration.add_extension..Z__OF__rr.)Ú ExtensionzTdistutils distribution has been initialized, it may be too late to add an extension )r<r(r7rærArhrirr|rSrur`rKrarfr+r™rørUr rMrqr{r.rIrr(r@rR)r:r7rírzZext_argsr}rOr+ZlibnamesZlibnameÚlnameZlpathrúrŽZllnamerrrXr r r Ú add_extension‚sX0                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_libraryr@rR)r:r7rír8rXr 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írN)r<r|r+r{)r:r7ríÚ install_dirr8r r r r‚ 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)rKrarbr6r‚r-r{r6)r:r7rír„r8r r r Úadd_installed_librarys ,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)rKrarbr6r7r0r{)r:Útemplater„Z subst_dictr r r Úadd_npy_pkg_configPs_  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}r@rr„)r:r rrXr r r Ú add_scripts»s  zConfiguration.add_scriptsc Ks(x*|jD] }t||ƒ}| | |g¡¡qWx*|jD] }t||ƒ}| | |i¡¡q4W|j|j|j}x¸| ¡D]¬}||krÜt||dƒ}|rž|||kržqt| d|||| dd¡f¡t ||||ƒ|j  |¡qt||jkr|  d|t||ƒ||f¡qt||krqtt d|ƒ‚qtWdS)Nz"Inheriting attribute %r=%r from %rr7r”z*Ignoring attempt to set %r (from %r to %r)zDon't know about key=%r) r9rTr„rSr;Úupdater?r@rRr=r{rOr)r:rArTr^rKr r r rËs,       zConfiguration.dict_appendcCszddlm}|j|j|j}d}|d|jd7}| ¡x0|D](}t||dƒ}|rB|d|||ƒf7}qBW|d7}|S)Nr)Úpformatz<----- zConfiguration of z: z%s = %s z----->)ÚpprintrŠr9r;r?r7ÚsortrT)r:rŠrKr‰r{r^r r r Ú__str__äs   zConfiguration.__str__cCsJtdƒ}| ¡d|_d|_tj d¡}|rFtj d|g¡}|tjd<|S)zF Returns the numpy.distutils config command instance. rbrÚPATHrn) rÚensure_finalizedZ dump_sourceZnoisyrKrRrSÚpathseprb)r:ÚcmdÚold_pathrar r r Úget_config_cmdñs  zConfiguration.get_config_cmdcCstdƒ}| ¡|jS)zh Return a path to a temporary directory where temporary files should be placed. rB)rrÚ build_temp)r:r‘r r r Úget_build_temp_dirÿsz 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). z/ subroutine simple end rë)Úlang)r“Ú try_compile)r:Úsimple_fortran_subroutineÚ config_cmdÚflagr r r Ú have_f77cszConfiguration.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) z/ subroutine simple end rê)r–)r“r—)r:r˜r™ršr r r Ú have_f90cszConfiguration.have_f90ccCsft|ƒr$|\}}t||j|jdn>ddlm}t||ƒsFtt|ƒƒ‚|j  |j¡|j  |j¡dS)zEAppend libraries, include_dirs to extension or library item. )r+r*r)rN) r,rr+r*rIrrærhrir„)r:ZextlibZlib_namer8rr r r Ú append_to.s  zConfiguration.append_toc Csúytjdg|d}Wntjtfk r.Yn Xt d|¡}|rNt| d¡ƒStj dkrtt j   dd¡rtt |dd ƒ}n t |d d ƒ}t j |¡röt|ƒ}| ¡}WdQRX|dd …d krØt d |¡}|röt| d¡ƒSnt d|¡}|röt| d¡ƒSdS)z+Return path's SVN revision number. Z svnversion)Úcwds(?P\d+)ÚrevisionrÏZSVN_ASP_DOT_NET_HACKNZ_svnÚentriesz.svnrµz\d+)"zdir[\n\r]+(?P\d+))Ú subprocessÚ check_outputÚCalledProcessErrorrrþÚmatchrQrárur®rKrRrSr+rar rÚreadr)r:raÚoutputrär rãZfstrr r r Ú_get_svn_revision<s*      zConfiguration._get_svn_revisionc Csytjdddg|d}Wntjtfk r2Yn Xt d|¡}|rRt| d¡ƒSt|ddƒ}t|dd ƒ}t j   |¡r d }t |ƒ}|  ¡ ¡}Wd QRXi} x^t|d ƒD]P} |  ¡d d …\} } | |krÐ| }y t| ƒ} Wntk ròw¬YnX| | | <q¬W|  |¡Sd S) z1Return path's Mercurial revision number. ÚhgZidentifyz--num)ržs(?P\d+)rŸz.hgÚbranchz branch.cacheNrÞr²)r¡r¢r£rrþr¤rQrár+rKrar rr¥rƒÚfiler`rrS) r:rar¦räZ branch_fnZbranch_cache_fnZbranch0rãZ revision0Z branch_maprŠZbranch1Z revision1r r r Ú_get_hg_revisionYs4       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}xÞ|D]Ö}t|j|ƒ}tj |¡rvd }tj tj  |¡¡d } t |j| ƒ} yt d  |  d¡¡||ƒ} Wn6t k r } z| t| ƒ¡d} Wdd} ~ XYnX| dkrqvx&|D]} t| | dƒ}|dk r Pq W|dk rvPqvW|dk rd||_|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__.pyrnrÐz _version.pyz version.pyz__svn_version__.pyz__hg_version__.pyÚ __version__Ú_version)z.pyrZrdrr&)rTr7r`r+r™rKrar r]r^r(r rbÚ ImportErrorrRrÅrÑr§r«)r:Z version_fileZversion_variablerÑr Z version_varsrãr‡rOr7r›Zversion_moduleÚer^rŸr r r Ú get_version~sZ               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. z__svn_version__.pyNc sltj ˆ¡sJtˆƒ}ˆ dˆ|f¡tˆdƒ}| d|¡WdQRXˆˆjf‡fdd„ }t |¡ˆS)NzCreating %s (version=%r)r¢z version = %r cspˆrlyt |¡|d|ƒWntk r2YnXy"t |d¡|d|dƒWntk rjYnXdS)Nzremoved rú)rKÚremover)rãr~)Údeleter r Úrm_fileßs zSConfiguration.make_svn_version_py..generate_svn_version_py..rm_file) rKrar rÅrOrrQÚatexitÚregister)rÑrãr³)r²rŸr:Útargetr r Úgenerate_svn_version_pyØs   zBConfiguration.make_svn_version_py..generate_svn_version_pyrc)r+r™r§rKrar rp)r:r²r·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. z__hg_version__.pyNc sltj ˆ¡sJtˆƒ}ˆ dˆ|f¡tˆdƒ}| d|¡WdQRXˆˆjf‡fdd„ }t |¡ˆS)NzCreating %s (version=%r)r¢z version = %r cspˆrlyt |¡|d|ƒWntk r2YnXy"t |d¡|d|dƒWntk rjYnXdS)Nzremoved rú)rKr±r)rãr~)r²r r r³s zQConfiguration.make_hg_version_py..generate_hg_version_py..rm_file) rKrar rÅrOrrQr´rµ)rÑrãr³)r²rŸr:r¶r r Úgenerate_hg_version_pys   z@Configuration.make_hg_version_py..generate_hg_version_pyrc)r+r™r«rKrar rp)r:r²r¹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)r,r{r7r)r:r7r r r Úmake_config_pyszConfiguration.make_config_pycGs6ddlm}m}i}x|D]}||f||ƒŽqW|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. rd)r3r)Ú system_infor3r)r:Únamesr3rZ info_dictr^r r r r3s  zConfiguration.get_info)NNNNrdr1)rd)rd)NNrd)NF)N)N)NN)T)T)r»)-r<r=r>r8r:r>Únumpy_include_dirsr;rMrOrRrDr@rYrcrUrerfrLrprsrtrvr}r|rrƒr‚r…r‡rˆrrr“r•r›rœrr§r«r°r¸rºr¼r3r r r r r Ösj [   ; )y "g$ 3 k  % E ) ( cCsN||krFddl}|jj}|dkr4ddlm}|dƒ‚| |¡}|||<||S)Nr)ÚDistutilsInternalErrorz+setup distribution instance not initialized)Údistutils.coreÚcoreÚ_setup_distributionÚdistutils.errorsrÀrU)ZcmdnameÚ_cacherrXrÀr‘r r r r+s  cCs(tjdd…}|s$ddl}| ¡g}|S)Nr)r r¿ÚnumpyZ get_include)r*rÆr r r r7s  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Ârznpy-pkg-config)rÆrKrRrSrarbrrrm)rÆrr r r Úget_npy_pkg_dir@s   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 r r4Us  cCsjddlm}t||ƒ}|| ¡ƒ}x*|| ¡ƒ ¡D]\}}|| |¡q4W|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_flagsrrr.Zignored)rÉrËr4ÚcflagsZlibsrSr„)rÊr†rËÚpkg_inforOr{rJr r r r3{s-    cCs,ddl}y |jdStk r&dSXdS)NrTF)ÚbuiltinsZ__NUMPY_SETUP__rM)rÎr r r Úis_bootstrapping·s rÏcCs: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)ÚwarningsrRr rM)r7rGr™rÑrúr r r rÃs  cKsVxP| ¡D]D\}}||krF||}t|tƒr6|||<qN|| |¡q |||<q WdS)N)rSrærÅr„)rrwr{rJÚovr r r rÑ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)Nr_rcrrd) rKrargr|rgÚ splitdriverfrörbrJrrÚnormpathr+)rŸraÚdriveZ absprefixZ pathdriverÚsubpathr r r rÜs" ** c Cs¼ddlm}ddlm}|tj |¡ƒt|dƒ€}| dtj  t j d¡¡| d¡| d¡| t   d¡¡x(|j ¡D]\}}| d ||f¡q€W| t   d ¡¡Wd QRX|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(): """ Show libraries in the system on which NumPy was built. Print information about various resources (libraries, library directories, include directories, etc.) in the system on which NumPy was built. See Also -------- get_include : Returns the directory containing NumPy C header files. Notes ----- Classes specifying the information to be printed are defined in the `numpy.distutils.system_info` module. Information may include: * ``language``: language used to write the libraries (mostly C or f77) * ``libraries``: names of libraries found in the system * ``library_dirs``: directories containing the libraries * ``include_dirs``: directories containing library header files * ``src_dirs``: directories containing library source files * ``define_macros``: preprocessor macros used by ``distutils.setup`` Examples -------- >>> np.show_config() blas_opt_info: language = c define_macros = [('HAVE_CBLAS', None)] libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] """ 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)) N)Znumpy.distutils.system_infor½Údistutils.dir_utilr×rKrarrrrQr^ruÚargvÚtextwrapÚdedentZ saved_resultsrS)r¶r½r×rãr{r]r r r rñs      5cCs|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_typerZ_MSVCCompiler__version)Úcompilerr r r Ú msvc_versionK s  rÞcCsddlm}|ƒS)Nr)r2)Zdistutils.msvccompilerr2)r2r r r r2S s )N)N)rcT)rcrcT)NNF)NN)F)r)N)N)NNN)brKrþrur<r‘r´r¤r¡rrNrÚrrÄrÚ threadingrZtlocalr®Zdummy_threadingr£rr rµZ numpy.compatr Ú__all__r6r5r1rrlrzr+rr*r’r˜r/r©rrArÃrÉrÊrrrrrrrrÓr×rÕrÿÚIr¤rïrìrßràrår-rr,rér.r0rr r!ròrórõr"r#rrr$r%r&rr'r(r)r rrrÇr4r3rÏrrrrrÞr2r r r r Úsä     $   %               / _   & <  Z