o 6˜¿a¼Tã @sHddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZddlZddlmZeƒZgZdd„Ze e¡gd¢ZGdd„dƒZd d „Zd d „Zd d„Zdd„Zdœdd„Zdd„Zdœdd„Zdd„Z dd„Z!dd„Z"ddd „Z#džd!d"„Z$d#d$„Z%e%ƒr§e&dd%d&d'd(d)d*d+d,d- Z'dŸd/d0„Z(nd d1d0„Z(d2d3„Z)d4d5„Z*d6d7„Z+d8d9„Z,d:d;„Z-dd?„Z/d@dA„Z0dBdC„Z1dDdE„Z2dFdG„Z3e 4dHej5¡j6Z7e 4dIej5¡j6Z8e 4dJej5¡j6Z9e 4dKej5¡j6Z:dLdM„Z;dNdO„ZdTdU„Z?dVdW„Z@dXdY„ZAdZd[„ZBd\d]„ZCd^d_„ZDd`da„ZEdbdc„ZFddde„ZGdfdg„ZHdhdi„ZIdjdk„ZJdldm„ZKdndo„ZLdpdq„ZMdrds„ZNd¡dtdu„ZOdvdw„ZPdxdy„ZQd¢dzd{„ZRGd|d}„d}ƒZSifd~d„ZTd€d„ZUd‚dƒ„ZVdœd„d…„ZWdœd†d‡„ZXdˆd‰„ZYd£dŠd‹„ZZdŒd„Z[dŽd„Z\dd‘„Z]d’d“„Z^d”d•„Z_d–d—hZ`d˜d™„Zadšd›„ZbdS)¤éN)Úlocal)ÚDistutilsErrorc Cs:tdurtD]}zt |¡WqtyYqwdSdS©N)Ú_tmpdirsÚshutilÚrmtreeÚOSError)Úd©r ú;/usr/lib/python3/dist-packages/numpy/distutils/misc_util.pyÚclean_up_temporary_directorys ÿür )+Ú 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_jobsÚsanitize_cxx_flagsÚexec_mod_from_locationc@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||_||_||_dSr)ÚnameÚ build_infoÚ target_dir)Úselfr9r:r;r r r Ú__init__Es zInstallableLib.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r=r r r r r8/s r8cCsÄddlm}z tt d¡ƒ}Wn tyt ¡}Ynwt|dƒ}t tj   d|¡ƒ}|ƒ}|dur4|St |  d¡ddƒt |  d¡ddƒt |  d ¡ddƒf}td d „|DƒƒrY|Std d „|DƒƒS) 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éÚNPY_NUM_BUILD_JOBSNÚbuildÚparallelÚ build_extÚ build_clibcss|]}|duVqdSrr ©Ú.0Úxr r r Ú js€z%get_num_build_jobs..css|] }|dur|VqdSrr rJr r r rMms€)Únumpy.distutils.corerCÚlenÚosÚsched_getaffinityÚAttributeErrorÚmultiprocessingÚ cpu_countÚminÚintÚenvironÚgetÚgetattrÚget_command_objÚallÚmax)rCrTÚenvjobsÚdistÚcmdattrr r r r5Ks$   ÿ þr5cCsFt|ƒ}tt|ƒƒD]}||}d|vr |ddvr d|||<q |S)Nú rz"'z"%s")ÚlistÚrangerO)ÚargsÚiÚar r r r1os €r1cCs| d¡}tjj|ŽS)zDConvert a /-separated pathname to one using the OS's path separator.ú/)ÚsplitrPÚpathÚjoin)r9Úsplittedr r r rys  rcCs tj tj |¡¡}tj tj |¡¡}t|ƒt|ƒkr|S||kr$dS||dt|ƒ…krN|t|ƒtjfvsDJt||t|ƒfƒƒ‚|t|ƒdd…}|S)z$Return path relative to parent_path.ÚNé)rPrhÚrealpathÚabspathrOÚsepÚrepr)rhÚ parent_pathÚpdÚapathr r r Úrel_path~s,rtcCs¦ztd|j|jƒ}tj tj |¡¡}Wn1tyEtd|j|jƒ}t|ƒt j |}t |dƒr=tj tj |j ¡¡}ntj d¡}Ynw|durOt ||ƒ}|pRdS)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__r>Ú.N)ÚevalÚ f_globalsÚf_localsrPrhÚdirnamernÚ NameErrorÚ __import__ÚsysÚmodulesÚhasattrrurt)ÚframerqÚ caller_filer Ú caller_nameÚmodr r r Úget_path_from_frameŒs    €ô r„cGszg}|D]}t|ƒr| t|Ž¡qt|ƒsJ‚| |¡q|}|s%d}ntjj|Ž}tjjdkr9| 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. rkrf) r,Úappendr+r-rPrhriroÚreplacer*)rhÚpathsÚpÚjoinedr r r r+ªs    r+c CsÊ|dur tj |d¡}n tƒ}|D]}tj |d¡}tj |¡r$|}nqtd|fƒ‚t|ƒ+}g}d}|D]}| |¡rR|t|ƒd…  ¡}|rR|  |  d¡¡q7Wdƒ|S1s^wY|S)z/Return the MATHLIB line from numpyconfig.h Nz_numpyconfig.hz1_numpyconfig.h not found in numpy include dirs %rz#define MATHLIBú,) rPrhrirÚexistsrÚopenÚ startswithrOÚstripÚextendrg) rhÚ config_fileÚdirsÚfnÚfidÚmathlibsÚsÚlineÚvaluer r r rÅs4 þÿ  €ü ýørcCsÈt|ƒs|Sd|vr |S| tj¡}|r+z| dd¡}Wn ty%Ynw||=|sd}|rZz| d|¡}Wn ty@Ynw||ddkrN|d7}n ||=||d=d}|s/|s^dStj |¡S)z$Resolve `..` and '.' from path. rvrlz..rk)r-rgrProÚindexÚ ValueErrorri)rhÚlrdÚjr r r r*às8  ÿû ÿ ÷  r*cCstt |¡ƒS)z}sorts output of python glob for https://bugs.python.org/issue30461 to allow extensions to have reproducible build results)ÚsortedÚglob)Úfileglobr r r Ú sorted_globýsrŸcCsBt|ƒs Jtt|ƒƒƒ‚g}t|ƒrJt|ƒƒ‚|D]}t|ƒr†d|vs(d|vrSt|ƒ}tt||ƒƒ}|r;| |¡q|rC| |¡q|rJ| |¡td||fƒqt||ƒ}t j   |¡rd| |¡qt j   |¡rp| |¡n|rw| |¡t j   |¡s…td||fƒqt|ƒr”| t |||ƒ¡q| |¡qdd„|DƒS)NÚ*ú?z#could not resolve pattern in %r: %rznon-existing path in %r: %rcSsg|]}t|ƒ‘qSr )r*©rKrˆr r r Ú %óz_fix_paths..) r,rpÚtyper-rŸr+rr…ÚprintrPrhr‹Ú _fix_paths)r‡Ú local_pathÚinclude_non_existingÚ new_pathsÚnrˆÚp2Ún2r r r r§sB   ÿ       ÿ€ r§rkTcCst|ƒr|f}t|||ƒS)z:Apply glob to paths and prepend local_path if needed. )r-r§)r‡r¨r©r r r r/'s r/cCsLttdƒst ¡t_t tj¡tj||tj|d\}}t  |d¡}||fS)NÚtempdir)ÚsuffixÚprefixÚdirÚtextÚw) rÚ_tdataÚtempfileÚmkdtempr®rr…ÚmkstemprPÚfdopen)r¯r°r²r“r9Úfor r r Úmake_temp_file.s    ý rºcCsÒtjdkr dtjvr dSttjdƒrgtj ¡rgzEddl}| ¡|  d¡dkrT|  d¡dkrW|  d¡dur<|  d¡dusQ|  d ¡durJ|  d ¡dusQ|  d ¡durZWd SWdSWdSWdSt yfYdSwdS) NÚcygwinÚ USE_COLORrÚisattyÚcolorsÚpairsÚsetfÚsetbÚsetafÚsetabÚscprl) r}ÚplatformrPrWrÚstdoutr½ÚcursesÚ setuptermÚtigetnumÚtigetstrÚ Exception)rÇr r r r;s2 ù ÷ ü þþrrlééééééé ) ÚblackÚredÚgreenÚyellowÚblueÚmagentaÚcyanÚwhiteÚdefaultFcCsxg}|r | d¡|rdt | ¡d¡}| t|ƒ¡|r/dt | ¡d¡}| t|ƒ¡|r:dd |¡|fS|S)NÚ1éré(rÑz [%sm%sú;)r…Ú _colour_codesrXÚlowerÚstrri)r•ÚfgÚbgÚboldÚseqÚfgcodeÚbgcoder r r Ú colour_textYs récCs|Srr )r•rãrär r r réhscCó t|dƒS)NrÛ©ré©r•r r r Ú default_textkó rícCrê)NrÔrërìr r r rmrîrcCrê)NrÕrërìr r r rorîrcCrê)NrÖrërìr r r rqrîrcCrê)NrÙrërìr r r rsrîrcCrê)Nr×rërìr r r rurîrcCs8tjdkr| d¡r|ddtj |dd…¡}|S)Nr»z /cygdriveé ú:é )r}rÅrrPrhÚnormcase)rhr r r rzs rcCs:tjdkrtj dd¡dkrdStj dd¡dkrdSdS) z0Return true when using mingw32 environment. Úwin32ÚOSTYPErkÚmsysTÚMSYSTEMÚMINGW32F)r}rÅrPrWrXr r r r rs rcCs:tj d¡}|dkrttj|d|d…ƒ}|Sd}|S)zGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrozMSC v.éÿÿÿÿrÐrïN)r}ÚversionÚfindrV)Úmsc_posÚmsc_verr r r Úmsvc_runtime_version‰s ÿrýcCs&tƒ}|r|dkr d|Sd|SdS)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 rcCs dddddddœ tƒd¡}|S) zFReturn major version of MSVC runtime coded like get_build_msvc_versionéFéGéPéZédrþ)iiixiÜi@ilN)rXrý)Ú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_]+)cCsjt|ƒsgSg}t|dƒ}|D]}t|ƒ}|r"| d¡}| |¡qWdƒ|S1s.wY|S)zRReturn a list of Fortran f90 module names that given source file defines. Úrr9N)Ú f90_ext_matchrŒÚf90_module_name_matchÚgroupr…)Úsourcer~Úfr–Úmr9r r r Ú_get_f90_modules¯s   €ü ÿùrcCs t|tƒSr)Ú isinstancerârìr r r r-¿rîr-cCs|D] }t|ƒs dSqdS)z4Return True if all items in lst are string objects. FT©r-)ÚlstÚitemr r r rÂó ÿrcCs0t|ƒrdSzt|ƒWdStyYdSw)NFT)r-rOrË©rær r r r,És  þÿr,cCst|ƒo d|vp d|vS)Nr r¡rrìr r r Úis_glob_patternÒsrcCst|ƒrt|ƒS|gSr)r,rarr r r r.Õsr.cCs:d}|D]}t|tƒrt|ƒrd}|St|ƒrd}q|S)z2Determine language value (c,f77,f90) from sources NÚf90Úf77)rrâr Úfortran_ext_match)ÚsourcesÚlanguager r r r r0Ûs þ€r0cCó|D] }t|ƒr dSqdS)z.Return True if sources contains Fortran files TF)r©rr r r r rèrrcCr)z*Return True if sources contains C++ files TF)Ú cxx_ext_matchrr r r r ïrr cCspg}g}g}g}|D]'}t|ƒr"t|ƒ}|r| |¡q | |¡q t|ƒr,| |¡q | |¡q ||||fS)ztReturn four lists of filenames containing C, C++, Fortran, and Fortran 90 module sources, respectively. )rrr…r)rÚ c_sourcesÚ cxx_sourcesÚ f_sourcesÚfmodule_sourcesr r~r r r r!ös     r!cCs.g}|D]}ttj |d¡ƒ}| |¡q|S)Nz*.h)rŸrPrhrir)Údirectory_listÚheadersr Úheadr r r Ú _get_headers s  r&cCsDg}|D]}tj |¡}|ddkr|d|vr| |d¡q|S)Nrrk)rPrhrgr…)Úlist_of_sourcesÚdirecsr r r 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: r`Ú ©ri)Úcc_argsÚextra_postargsÚpp_optsÚcmdliner r r Ú_commandline_dep_strings r0cCs tt|ƒƒSr)r&r))rr r r r"*s r"cCsˆt|ƒsdStj |¡}tj t ¡|g¡}|t|ƒd… tj¡}|r.|ds.|dd…}|r8|ddkr8dStj  |¡}tj  |¡S)z1Return true if directory is local directory. FNrrlrF) r-rPrhrnÚ commonprefixÚgetcwdrOrgroriÚisdir)Ú directoryÚabs_dirÚcÚnew_dirr r r r#.s     r#c#sxddddœ‰t d¡}tj|ddD]&\}}}‡fdd„|Dƒ}||dd…<|D]}| |¡s8tj ||¡Vq)qdS)Nrl©ÚCVSú.svnrFú(?:[~#]|\.py[co]|\.o)$T©Útopdowncóg|]}|ˆvr|‘qSr r ©rKr ©Úpruned_directoriesr r r£Aóz(general_source_files..)ÚreÚcompilerPÚwalkÚsearchrhri)Útop_pathÚprune_file_patÚdirpathÚdirnamesÚ filenamesÚprunedr r r@r Úgeneral_source_files=s€    €þýrMc #sþgd¢‰t d¡‰tj|ddD]K\}}}‡fdd„|Dƒ}||dd…<|D]4}tj ||¡‰tˆ|ƒ}g}t ˆ¡D]}tj ˆ|¡} tj | ¡rUˆ  | ¡sU|  | ¡q<||fVq'q|‰tˆ|ƒ}‡‡fdd„t ˆ¡Dƒ}d d„|Dƒ}||fVdS) zJReturn a directory name relative to top_path and files contained. r8r;Tr<cr>r r r?r@r r r£NrBz4general_source_directories_files..Ncs$g|]}ˆ |¡stj ˆ|¡‘qSr )rFrPrhri©rKr )ÚdpathrHr r r£[sÿcSóg|] }tj |¡r|‘qSr )rPrhÚisfilerNr r r r£]ó) rCrDrPrErhrirtÚlistdirrQrFr…) rGrIrJrKrLr ÚrpathÚfilesr r’r )rOrHrAr Ú general_source_directories_filesGs,€    € ø rVcCsng}dd„|jDƒ}| |¡| t|ƒ¡|jD]}t|ƒr)| tt|ƒƒ¡qtj  |¡r4|  |¡q|S)NcSóg|]}t|ƒr|‘qSr r©rKÚ_mr r r r£drBz(get_ext_source_files..) rrr"Údependsr#rarMrPrhrQr…)ÚextrKrr r r r r$as    €r$cCsdd„|Dƒ}|S)NcSrWr rrXr r r r£orBz$get_script_files..r )Úscriptsr r r r%nsr%cCsŠg}|d dg¡}dd„|Dƒ}| |¡| t|ƒ¡|d dg¡}|D]}t|ƒr7| tt|ƒƒ¡q'tj |¡rB|  |¡q'|S)NrlrcSrWr rrXr r r r£urBz(get_lib_source_files..rZ) rXrr"r#rarMrPrhrQr…)ÚlibrKrrZr r r r r&rs   €r&cCsštj ¡}| dd¡}|dur| dd¡}|sKtj d¡s#tj d¡r'd}|Stj d¡r1d }|Stj d ¡r;d }|Sd |vrK| 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ÚlinuxÚ gnukfreebsdz.soÚdarwinz.dylibÚwinz.dllÚSOABIrvrl)Ú distutilsÚ sysconfigÚget_config_varsrXr}rÅrr†)Ú is_python_extÚconfvarsÚso_extr r r Úget_shared_lib_extension€s&     ÿ õ ÷ürkcCs†t|ƒr|gS|d}g}|D]1}t|dƒrqt|ƒr%| tt|ƒƒ¡qt|ƒr;tj |¡r5|  |¡qt d|ƒqt t |ƒƒ‚|S)NrlÚ__call__zNot existing data file:) r-rr#rrarMrPrhrQr…r¦Ú TypeErrorrp)ÚdatarrKr•r r r r'¯s     r'cGsd dd„|Dƒ¡S)NrvcSsg|]}|r|‘qSr r )rKrer r r r£Ãr¤zdot_join..r+)rcr r r r(Âsr(cCsNzt |d¡WSty&t ¡dj}t|dƒD]}|j}q|YSw)z:Return frame object from call stack with given level. rlrÌ)r}Ú _getframerRÚexc_infoÚtb_framerbÚf_back)Úlevelr€Ú_r r r r)Ås ür)c@sˆeZdZgd¢ZddgZddgZgZ      dXd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dYdd„Z dYdd„Z   dZdd„Z  d[dd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd\d4d5„Zd\d6d7„Zd8d9„Zd:d;„Zdd?„Z!d@dA„Z"dBdC„Z#dDdE„Z$dFdG„Z%dHdI„Z&dJdK„Z'd]dLdM„Z(d^dOdP„Z)d^dQdR„Z*d_dTdU„Z+dVdW„Z,dS)`r ) ÚpackagesÚ ext_modulesÚ data_filesÚ include_dirsÚ librariesr$r\Ú py_modulesÚinstalled_librariesÚ define_macrosÚ package_dirÚinstalled_pkg_configr9rùNrlúsetup.pyc Ks|t||ƒ|_d|_t|ƒ}t||ƒ|_|dur|j}d|_|dur%|j}ntj t |j|ƒ¡r5t |j|ƒ}tj |p;d¡sDt d|fƒ‚||_ ||_ tjj |j d¡Ž|_|jdd…|_|jdd…|_|jD]} t | | g¡¡} t|| t| ƒƒqh|jD]} t | | i¡¡} t|| | ƒq|j|j} |jdd…|_| ¡D]/} | | vrªq£|| } t|| | ƒt| tƒrÀ|j | ¡q£t| tƒrÌ|j | ¡q£|j | ¡q£tj t |dƒ¡ré|j  |j¡||j!|j<tddddd|_"d} t#dd ƒD])}zt|ƒ}Wn t y Ynwz t$d |j%|j&ƒ} Wn t'y"Yqùwt| |j(ƒr9| j"d r9|j)d i| 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<rƒr )+r(r9rùr)r„r¨rPrhr3r+r™rGÚ package_pathrirgÚpath_in_packageÚ _list_keysÚ list_keysÚ _dict_keysÚ dict_keysÚcopyrXÚsetattrr.Ú _extra_keysÚ extra_keysÚkeysrrar…Údictr‹rur}Úoptionsrbrwrxryr{Ú __class__Ú set_optionsÚ setup_name)r<Ú package_nameÚ parent_namerGr…Ú caller_levelr”ÚattrsÚ caller_framer«ÚvÚ known_keysreÚcaller_instancerdr r r r r=Ýs|           ü ÿÿ  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_filesrˆrŠrŽrY)r<r r›r«rer r r Útodict>s  €zConfiguration.todictcCs|jds t|ƒdSdS)Nr„)r‘r¦©r<Úmessager r r ÚinfoQs  ÿzConfiguration.infocCstj d|f¡dS)Nz Warning: %s )r}ÚstderrÚwriterŸr r r ÚwarnUszConfiguration.warncKs6| ¡D]\}}||jvr||j|<qtd|ƒ‚dS)zå Configure Configuration instance. The following options are available: - ignore_setup_xxx_py - assume_default_configuration - delegate_options_to_subpackages - quiet zUnknown option: N)Úitemsr‘r™)r<r‘Úkeyr—r r r r“Xs    üzConfiguration.set_optionscCsddlm}|ƒS)z2Return the distutils distribution object for self.rrB)rNrC)r<rCr r r rCis zConfiguration.get_distributionc Cs¢| d¡}t|jg|ƒ}dd„t|ƒDƒ}g}|D]4}tj t|dƒ¡s&qd| tj¡vr/qd | tj¡t |ƒ d…¡} |j | ||dd} |  | ¡q|S)NrvcSrPr )rPrhr3rXr r r r£srRz:Configuration._wildcard_get_subpackage..r€rFrl©r–r—) rgr+r¨rŸrPrhrQrorirOÚget_subpackager) r<Úsubpackage_namer–r—ršÚsubpackage_pathr‘Ú config_listr r«r6r r r Ú_wildcard_get_subpackagens  þ z&Configuration._wildcard_get_subpackagec Cs&tj dtj |¡¡z‚tj tj |¡¡d}t|j||ƒ}t d  |  d¡¡|ƒ}t |dƒsH|j ds;| d|¡t|||j||dd} n#t|g|  d¡dd …Ž} | f} |jjjdkrf| |jf} |j| Ž} | jt||ƒkr‡| d t||ƒ| jf¡Wtjd=| SWtjd=| Stjd=w) NrrtrvÚ configurationr‚zCAssuming default configuration (%s does not define configuration())rl©r—røz*Subpackage %r configuration returned as %r)r}rhÚinsertrPrzÚsplitextÚbasenamer(r9r7rirgrr‘r¤r rGr­Ú__code__Ú co_argcount) r<Úsetup_pyr©rªr–r—r”r«Ú setup_moduleÚconfigÚpnrcr r r Ú _get_configuration_from_setup_pys>ÿ  þþ  ÿû ÿz.Configuration._get_configuration_from_setup_pycCsL|dur|dur tdƒ‚tj |¡}| d¡}|dur)d|vr)|j|||ddSd|vs6Jt|||fƒƒ‚|durCt|jg|ƒ}nt|g|dd…ƒ}|  |g¡d}t||j ƒ}|j d sntj  |¡snt|d |ƒ}tj  |¡s“|j d s†|  d tj |¡|f¡t|||j||dd}n |j|||||dd}|r¤|gSgS) 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 rlr®rørrz setup_%s.pyr‚zEAssuming default configuration (%s/{setup_%s,setup}.py was not found))r™rPrhr±rgr¬rpr+r¨r‡r”r‘rQr¤rzr rGr¸)r<r©rªr–r—ršr´r¶r r r r¨¢sTÿ  þ   ÿ  þþûzConfiguration.get_subpackageFc Csº|rd}n|j}|j|||dd}|s| d¡|D]/}|}t|tƒr'| ¡}t|tƒs4Jtt|ƒƒƒ‚|  d|  d¡|jf¡|j di|¤Žq|  ¡}|dur[| d|¡dSdS) 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Ìr§z0No configuration returned, assuming unavailable.z Appending %s configuration to %sr9zTdistutils distribution has been initialized, it may be too late to add a subpackage r ) r9r¨r¤rr ržrrpr¥r¡rXrrC) r<r©rªÚ standaloner–r«r¶r r^r r r Úadd_subpackageßs0þ  ÿ ÿÿzConfiguration.add_subpackagec s˜t|ƒr |\‰}nd‰t|ƒr‡‡fdd„|DƒdSt|ƒs&td|fƒ‚ˆdurBtj |¡r;ˆ tj |¡|f¡Sˆ ||f¡Sˆj|dd}t |ƒrt ˆƒrùt ˆƒ  tj ¡}|  ¡ttt|ƒdƒƒ}|  ¡|D] }||sw||=qn|D]|}tj |¡sˆtd|ƒqzt|ˆjƒ}|  tj ¡}|  ¡g} d }|D]9} t | ƒrº|t|ƒkr²td ˆ|fƒ‚|  ||¡n| ||ksÎJt| |||ˆ||fƒƒ‚|  | ¡|d7}qž||d…r爠d ||f¡|   ¡ˆ tj  | ¡|f¡qzdS|D] }ˆ ˆ|f¡qûdSt ˆƒrJtˆƒƒ‚ˆ ¡} | dur%| jdur%| j} nˆj} |D]}tt|ƒƒD]\} }tj ˆjˆ| ¡}|  ||f¡q2q*dS) 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 r r£Gsz.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)r,r-rmrPrhÚisabsr»r±r‡rrrgroÚreverserarbrOr3r¦rtr¨r™r…rpr¤rirCrwrVr†)r<Ú data_pathr‡Ú pattern_listÚrlrdrhrTÚ path_listÚ target_listr•r^rwÚd1r Ú target_pathr r¼r r» s|8   €     ÿ(   ÿþþÿzConfiguration.add_data_dircCs^i}|jD]\}}||vrtƒ||<|D] }|| |¡qqdd„| ¡Dƒ|jdd…<dS)NcSsg|] \}}|t|ƒf‘qSr )ra)rKrˆrUr r r r£ŠrRz6Configuration._optimize_data_files..)rwÚsetÚaddr¥)r<Ú data_dictrˆrUr r r r rƒs ÿ z"Configuration._optimize_data_filescGst|ƒdkr|D]}| |¡qdSt|ƒdksJ‚t|dƒr'|d\}}nd}t|ƒr0|}n%t|ƒrMt|ƒdkr?|d}n|D] }| ||f¡qAdSttt|ƒƒƒ‚|duryt|dƒrad}ntj   |¡rjd}ntj   |¡}| ||f¡dS|j |dd}t |ƒrÝt |ƒrÔ| tj¡}| ¡|D]=}| tj¡}| ¡| ¡g} d} |D]} t | ƒr¼|  || ¡| d7} qª|  | ¡qª|  ¡| tj | ¡|f¡q”dS| ||f¡dSt |ƒréJt||fƒƒ‚| ¡} | durú| jdurú| j} n|j} |  tj  |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'). rlNrrlrkFr½)rOÚadd_data_filesr,r-rmrpr¥rrPrhr¾rzr‡rrgror¿Úpopr…rirCrwr†)r<rUr r Úfilepatr‡rÁrhrÃrÄrdr•r^rwr r r rÊŒsh X           ÿzConfiguration.add_data_filescCs@| ¡}|durt|dƒsg|_|j |¡dS|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|)rCrr|r)r<Úmacrosr^r r r Úadd_define_macros%s  zConfiguration.add_define_macroscGóJ| |¡}| ¡}|dur|jdurg|_|j |¡dS|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‡rCrxr)r<r‡rxr^r r r Úadd_include_dirs5ó  zConfiguration.add_include_dirscs¶g‰|D]6‰tˆƒr‡‡fdd„ˆ ˆ¡Dƒqtˆttfƒr%tˆƒdkr+ttˆƒƒ‚‡‡fdd„ˆ ˆd¡Dƒqˆ ¡}|durS|j durKg|_ |j   ˆ¡dSˆ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…r9r¢)r$r<r r r£ZrRz-Configuration.add_headers..rÌcsg|] }ˆ ˆd|f¡‘qS©r)r…r¢)r$rhr r r£^srlN) r-r‡rÚtuplerarOrmrprCr$r)r<rUr^r )r$rhr<r Ú add_headersEs   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©)rXr/r¨)r<r‡Úkwsr©r r r r‡gs þzConfiguration.pathscCs4| ¡D]}||}|dvr| |¡}|||<qdS)N)rrZrxÚ library_dirsÚ module_dirsÚ extra_objects)rr‡)r<ÚkwÚkršÚnew_vr r r Ú_fix_paths_dictvs  €ûzConfiguration._fix_paths_dictcKsät |¡}t|j|ƒ|d<||d<d|vr<|d}|d=t|tƒr$|g}|D]}t|tƒs3Jt|ƒƒ‚t|fi|¤Žq&| |¡| dg¡}g}g|d<|D]k} t| t ƒr]| | d¡d| vrµ|   dd¡\} } t j   t|j| ƒ¡} t j  | ¡rµ|jd| dd } t| tƒrŠ|  ¡} d d „|  dg¡DƒD]} |   d d¡d }|| kr³|  dd¡t|fi| ¤Žnq•qO| | ¡qO||d|d<|j| dg¡|d<d dlm}|di|¤Ž}|j |¡| ¡}|durð| 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. r9rÚ extra_inforyrlú@NrÌr®cSsg|]}|d‘qSrÒr )rKršr r r r£Îr¤z/Configuration.add_extension..Ú__OF__rr|©Ú ExtensionzTdistutils distribution has been initialized, it may be too late to add an extension r )r‹r(r9rrrprrÜrXrÓrgrPrhrnr+r¨r3r¨r ržrËr…r|rNrárvrCr¤)r<r9rrÙÚext_argsrÝr¡ryÚlibnamesÚlibnameÚlnameÚlpathr6ršÚllnamerár[r^r r r Ú add_extension~s` 0     ÿ  ý ÿ  ÿzConfiguration.add_extensioncKs6| ||d|¡| ¡}|dur| d|¡dSdS)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_libraryrCr¤)r<r9rr:r^r r r Ú add_libraryås ÿÿzConfiguration.add_librarycCs@t |¡}||d<d|vrg|d<| |¡|j ||f¡dS)z\Common implementation for add_library and add_installed_library. Do not use directlyrrZN)r‹rÜryr…©r<r9rÚ install_dirr:r 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)rPrhrir…rér{r…r8rër r r Úadd_installed_librarys ,z#Configuration.add_installed_librarycCs\|duri}tj |j|¡}|j|jvr"|j|j |||f¡dS|||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)rPrhrir…r9r~r…)r<ÚtemplaterìÚ subst_dictr r r Úadd_npy_pkg_configLs_  ÿÿz Configuration.add_npy_pkg_configcGrÏ)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‡rCr\r)r<rUr\r^r r r Ú add_scripts·rÑzConfiguration.add_scriptsc Ks|jD]}t||ƒ}| | |g¡¡q|jD]}t||ƒ}| | |i¡¡q|j|j|j}| ¡D]S}||vrit||dƒ}|rJ|||krJq5| d|||| dd¡f¡t ||||ƒ|j  |¡q5||jvr~|  d|t||ƒ||f¡q5||vrƒq5t d|ƒ‚dS)Nz"Inheriting attribute %r=%r from %rr9r¡z*Ignoring attempt to set %r (from %r to %r)zDon't know about key=%r) rˆrYrrXrŠÚupdaterŽrr¤rŒr…r¡r™)r<rr¦rer›r r r rÇs0      ÿ ÿ ñzConfiguration.dict_appendcCsvddlm}|j|j|j}d}|d|jd7}| ¡|D]}t||dƒ}|r4|d|||ƒf7}q |d7}|S)Nr)Úpformatz<----- zConfiguration of z: z%s = %s z----->)ÚpprintrórˆrŠrŽr9ÚsortrY)r<rór›r•rÚrer r r Ú__str__às  €zConfiguration.__str__cCsJtdƒ}| ¡d|_d|_tj d¡}|r#tj d|g¡}|tjd<|S)zF Returns the numpy.distutils config command instance. r¶rÚPATHrv) rÚensure_finalizedÚ dump_sourceÚnoisyrPrWrXÚpathsepri)r<ÚcmdÚold_pathrhr 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. rF)rrøÚ build_temp)r<rür r r Úget_build_temp_dirûsz Configuration.get_build_temp_dircCód}| ¡}|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þÚ try_compile©r<Úsimple_fortran_subroutineÚ config_cmdÚflagr r r Ú have_f77có zConfiguration.have_f77ccCr)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) rrrrrr r r Ú have_f90cr zConfiguration.have_f90ccCsht|ƒr|\}}t||j|jddSddlm}t||ƒs$Jt|ƒƒ‚|j |j¡|j |j¡dS)zEAppend libraries, include_dirs to extension or library item. )ryrxrràN) r,rryrxrNrárrpr)r<ÚextlibÚlib_namer:rár r r Ú append_to*s þ zConfiguration.append_toc Csz tjdg|d}Wn tjtfyYnwt d|¡}|r&t| d¡ƒStj dkr9t j   dd¡r9t |dd ƒ}nt |d d ƒ}t j |¡r…t|ƒ }| ¡}Wdƒn1sXwY|dd …d krvt d |¡}|rtt| d¡ƒSdSt d|¡}|r…t| d¡ƒSdS)z+Return path's SVN revision number. Ú svnversion©Úcwdó(?P\d+)ÚrevisionróÚSVN_ASP_DOT_NET_HACKNÚ_svnÚentriesr:rÏz\d+)"zdir[\n\r]+(?P\d+))Ú subprocessÚ check_outputÚCalledProcessErrorrrCÚmatchrVr r}rÅrPrWrXr+rhrQrŒÚreadrF)r<rhÚoutputrrr Úfstrr r r Ú_get_svn_revision8s0ÿ     ÿ  ýzConfiguration._get_svn_revisionc Cs8z tjgd¢|d}Wn tjtfyYnwt d|¡}|r't| d¡ƒSt|ddƒ}t|ddƒ}t j   |¡ršd}t |ƒ}|  ¡ ¡}Wdƒn1sPwYi} t |d ƒ1}|D]&} |  ¡dd …\} } | |krq| }zt| ƒ} Wn ty€Yq_w| | | <q_Wdƒn1swY|  |¡SdS) z1Return path's Mercurial revision number. )ÚhgÚidentifyz--numrrrz.hgÚbranchz branch.cacheNrrÌ)rrrrrCrrVr r+rPrhrQrŒrrŽrgr™rX) r<rhrrÚ branch_fnÚbranch_cache_fnÚbranch0r Ú revision0Ú branch_mapr–Úbranch1Ú revision1r r r Ú_get_hg_revisionUsB ÿÿ     ÿ   ÿ øÿ zConfiguration._get_hg_revisionc Cs´t|ddƒ}|dur |S|dur d|j d¡ddddd g}n|g}|dur5dd |j d¡dd g}n|g}|D]y}t|j|ƒ}tj |¡r³d }tj tj  |¡¡d } t |j| ƒ} z t d  |  d¡¡|ƒ} Wnt y„} z| t| ƒ¡d} WYd} ~ nd} ~ ww| durŠq:|D]} t| | dƒ}|duršnqŒz|  ¡d}Wn ty¬Ynw|dur³nq:|dur½||_|S| |j¡}|durÍ| |j¡}|durØ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__Ú_version)z.pyÚUrlrrt)rYr9rgr+r¨rPrhrQr°r±r(r7riÚ ImportErrorr¤râÚ get_versionsrRrùr r+)r<Ú version_fileÚversion_variablerùrUÚ version_varsr r’r¡r9r«Úversion_moduleÚererr r r Ú get_version{sr üþ   ÿ€þ ÿ ÿ€  zConfiguration.get_versionTcóVtˆjdƒ‰ˆ ˆj¡‰tj ˆ¡sˆdurdS‡‡‡‡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ó€tj ˆ¡s/tˆƒ}ˆ dˆ|f¡tˆdƒ}| d|¡Wdƒn1s*wYˆˆjf‡fdd„ }t |¡ˆS)NúCreating %s (version=%r)r³ú version = %r cópˆr6z t |¡|d|ƒWn tyYnwzt |d¡|d|dƒWdSty5YdSwdS©Nzremoved r6©rPÚremover©r rˆ©Údeleter r Úrm_fileãó &üzSConfiguration.make_svn_version_py..generate_svn_version_py..rm_file© rPrhrQrâr¡rŒr£ÚatexitÚregister©rùr rD©rCrr<Útargetr r Úgenerate_svn_version_pyÜó  ÿ zBConfiguration.make_svn_version_py..generate_svn_version_pyrk)r+r¨r rPrhrQrÊ)r<rCrLr rJr Úmake_svn_version_pyÇs  z!Configuration.make_svn_version_pycr9)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-Ncr:)Nr;r³r<cr=r>r?rArBr r rD rEzQConfiguration.make_hg_version_py..generate_hg_version_py..rm_filerFrIrJr r Úgenerate_hg_version_pyrMz@Configuration.make_hg_version_py..generate_hg_version_pyrk)r+r¨r+rPrhrQrÊ)r<rCrOr rJr Ú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)rzr…r9r)r<r9r r r Úmake_config_pyszConfiguration.make_config_pycGs6ddlm}m}i}|D] }||fi||ƒ¤Ž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)r3r)Ú system_infor3r)r<Únamesr3rÚ info_dictrer r r r3"s zConfiguration.get_info)NNNNrlr)rl)NNrl)NFr©NN)T)rQ)-r>r?r@r‡r‰rÚnumpy_include_dirsr=ržr¡r¤r“rCr¬r¸r¨rºr»rrÊrÎrÐrÔr‡rÜrèrêrérírðrñrrörþrr r rr r+r8rNrPrRr3r r r r r Ósr úa þ ü" ý> þ+y "g$  3k   & L ) ( r cCsN||vr#ddl}|jj}|durddlm}|dƒ‚| |¡}|||<||S)Nr)ÚDistutilsInternalErrorz+setup distribution instance not initialized)Údistutils.coreÚcoreÚ_setup_distributionÚdistutils.errorsrXrZ)ÚcmdnameÚ_cacherer^rXrür r r r/s ÿ rcCs(tjdd…}|sddl}| ¡g}|S)Nr)r rWÚnumpyÚ get_include)rxr_r r r r;s  rcCsDtj d¡}|dur |Stj d¡}tj 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. ÚNPY_PKG_CONFIG_PATHNr_rZr]znpy-pkg-config) rPrWrXÚ importlibÚutilÚ find_specrhrirzÚorigin)r Úspecr r r Úget_npy_pkg_dirDs  ÿrgcCs0ddlm}|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_configrhr…rg)Úpkgnamer‘rhr r r r4Xs  r4cCsfddlm}t||ƒ}|| ¡ƒ}|| ¡ƒ ¡D] \}}|| |¡q|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Ír|Úignored)rirkr4ÚcflagsÚlibsr¥r)rjr‘rkÚpkg_infor¡rÚršr r r r3~s -   r3cCs*ddl}z|jWdStyYdSw)NrTF)ÚbuiltinsÚ__NUMPY_SETUP__rR)rpr r r Úis_bootstrappingºs ÿrrcCs: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)Úwarningsr¤r rž)r9r–r¨rtr6r r r rÆsÿþü rcKsR| ¡D]"\}}||vr"||}t|tƒr|||<q|| |¡q|||<qdSr)r¥rrâr)r rÕrÚršÚovr r r rÔs   ørcCs(tjjdkr| dtjj¡}| dtjj¡}d}tj |¡r‡tj |¡d}tj tj |¡¡d}tj |¡\}}tj ||g¡}tj |dt |ƒ…|t |ƒd…¡|ksltj |dt |ƒ…|t |ƒd…¡|krrtj  |¡}|t |ƒd…}tj |¡r†|dd…}n|}tj  t |||ƒ¡S)Nrfrkrrl) rPrhror†r¾Ú splitdrivernr1rirOrzÚnormpathr+)r°rhÚdriveÚ absprefixÚ pathdriver Úsubpathr r r rßs$  **   €rcCsÎddlm}ddlm}|tj |¡ƒt|dƒD}| dtj  t j d¡¡| d¡| d¡| t   d¡¡|j ¡D] \}}| d ||f¡q?| t   d ¡¡Wd ƒ|S1s`wY|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)rS)Ú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`` * ``baseline``: minimum CPU features required * ``found``: dispatched features supported in the system * ``not found``: dispatched features that are not supported in the system Examples -------- >>> import numpy as np >>> np.show_config() blas_opt_info: language = c define_macros = [('HAVE_CBLAS', None)] libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] """ from numpy.core._multiarray_umath import ( __cpu_features__, __cpu_baseline__, __cpu_dispatch__ ) 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)) features_found, features_not_found = [], [] for feature in __cpu_dispatch__: if __cpu_features__[feature]: features_found.append(feature) else: features_not_found.append(feature) print("Supported SIMD extensions in this NumPy install:") print(" baseline = %s" % (','.join(__cpu_baseline__))) print(" found = %s" % (','.join(features_found))) print(" not found = %s" % (','.join(features_not_found))) N)Únumpy.distutils.system_inforSÚdistutils.dir_utilr|rPrhrzrŒr£r±r}ÚargvÚtextwrapÚdedentÚ saved_resultsr¥)rKrSr|r rÚrdr r r rôs      éccrcCs|jdks td|jƒ‚|jS)zdReturn version major and minor of compiler instance if it is MSVC, raise an exception otherwise.Úmsvcz"Compiler instance is not msvc (%s))Ú compiler_typer™Ú_MSVCCompiler__version)Úcompilerr r r Ú msvc_versionc s ÿr‡cCsddlm}|ƒS)Nr©r2)Údistutils.msvccompilerr2rˆr r r r2k s r2z%-Werror=implicit-function-declarationz-std=c99cCsdd„|DƒS)z= Some flags are valid for C but not C++. Prune them. cSsg|]}|tvr|‘qSr )Ú_cxx_ignore_flags)rKr r r r r£y rBz&sanitize_cxx_flags..r )Úcxxflagsr r r r6u sr6cCs*tj ||¡}tj |¡}|j |¡|S)z° Use importlib machinery to import a module `modname` from the file `modfile`. Depending on the `spec.loader`, the module may not be registered in sys.modules. )rbrcÚspec_from_file_locationÚmodule_from_specÚloaderÚ exec_module)ÚmodnameÚmodfilerfÚfoor r r r7| s  r7r)rkT)rkrkT)NNFrV)FrÒ)NNN)crPrCr}r‹rrGrµrrrSr€Úimportlib.utilrbÚ threadingrÚtlocalrer\rr´rr rHÚ__all__r8r5r1rrtr„r+rr*rŸr§r/rºrrràrérírrrrrrrrýrrÿrDÚIrrrr r rr-rr,rr.r0rr r!r&r)r0r"r#rMrVr$r%r&rkr'r(r)r rrrgr4r3rrrrrrr‡r2rŠr6r7r r r r ÚsÒ   $    %    ÿ            /  f   &<  o