2[c)@`s ddlmZmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZyddlmZWn!ek rddlmZnXeZgZdZe jeddlmZddlmZdd lm Z d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2g)Z!d3e"fd4YZ#d5Z$d6Z%d7Z&d8Z'e(d9Z)d:Z*e(d;Z+d<Z,d=Z-d>Z.d?e/d@Z0d?d?e/dAZ1dBZ2e2re3dCddDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdS Z4e(e(e5dTZ6ne(e(dUZ6dVZ7dWZ8dXZ9dYZ:dZZ;d[Z<d\Z=d]Z>d^Z?d_Z@d`ZAejBdaejCjDZEejBdbejCjDZFejBdcejCjDZGejBddejCjDZHdeZIdfZJdgZKdhZLdiZMdjZNdkZOdlZPdmZQdnZRdoZSdpZTdqZUdrZVdsZWdtZXduZYdvZZdwZ[dxZ\e5dyZ]dzZ^d{Z_dd|Z`d e"fd}YZaid~ZbdZcdZde(dZee(dZfdZge(e(e(dZhdZidZjdZkdZldS(i(tdivisiontabsolute_importtprint_functionN(tDistutilsError(tget_build_architecture(tlocalcC`sItdk rEx6tD]+}ytj|Wqtk r=qXqWndS(N(t_tmpdirstNonetshutiltrmtreetOSError(td((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytclean_up_temporary_directorys    (t get_exception(t basestring(tnpy_load_modulet Configurationtget_numpy_include_dirstdefault_config_dictt dict_appendt appendpathtgenerate_config_pytget_cmdtallpatht get_mathlibstterminal_has_colorstred_textt green_textt yellow_textt blue_textt cyan_textt cyg2win32tmingw32t all_stringst has_f_sourcesthas_cxx_sourcestfilter_sourcestget_dependenciestis_local_src_dirtget_ext_source_filestget_script_filestget_lib_source_filestget_data_filestdot_joint get_framet minrelpathtnjoint is_sequencet is_stringtas_listtgpathst get_languaget quote_argsRtget_infot get_pkg_infotget_num_build_jobstInstallableLibcB`seZdZdZRS(s 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. cC`s||_||_||_dS(N(tnamet build_infot target_dir(tselfR9R:R;((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt__init__Ls  (t__name__t __module__t__doc__R=(((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR86scC`sddlm}yttjd}Wntk rHtj}nXttj j d|}|}|d kr}|St |j ddd t |j ddd t |j ddd f}td|Dr|Std |DSd S( sG 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 checked and if that is unset it returns 1. Returns ------- out : int number of parallel jobs that can be run i(tget_distributiontNPY_NUM_BUILD_JOBStbuildtparallelt build_extt build_clibcs`s|]}|dkVqdS(N(R(t.0tx((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pys nscs`s!|]}|dk r|VqdS(N(R(RGRH((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pys qsN(tnumpy.distutils.coreRAtlentostsched_getaffinitytAttributeErrortmultiprocessingt cpu_counttinttenvirontgetRtgetattrtget_command_objtalltmax(RAROtenvjobstdisttcmdattr((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR7Rs    cC`sdt|}xQtt|D]=}||}d|kr|ddkrd|||cC`sy:td|j|j}tjjtjj|}Wntk rtd|j|j}t|t j |}t |drtjjtjj|j }qtjjd}nX|dk rt||}n|pdS(sReturn 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. t__file__R>t.N(tevalt f_globalstf_localsRKRbtdirnameRgt NameErrort __import__tsystmodulesthasattrRoRRn(tframeRkt caller_fileR t caller_nametmod((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytget_path_from_frames"   $ cG`sg}xO|D]G}t|r5|jt|q t|sGt|j|q W|}|smd}ntjj|}tjjdkr|j dtjj}nt |S(s2Join 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. ReR`( R/tappendR.R0RiRKRbRcRhtreplaceR-(Rbtpathstptjoined((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR.s   c C`s|dk r$tjj|d}n^t}xR|D]7}tjj|d}tjj|r4|}Pq4q4Wtd|ft|}g}d}xU|D]M}|j|r|t |j }|r|j |j dqqqW|j |S(s/Return the MATHLIB line from numpyconfig.h s_numpyconfig.hs1_numpyconfig.h not found in numpy include dirs %rs#define MATHLIBt,N(RRKRbRcRtexistsRtopent startswithRJtstriptextendRatclose( Rbt config_filetdirstfntfidtmathlibststlinetvalue((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs(        cC`st|s|Sd|kr |S|jtj}x<|rpy|jdd}Wntk rePnX||=q5Wd}xn|ry|jd|}Wntk rPnX||ddkr|d7}qz||=||d=d}qzW|sdStjj|S(s$Resolve `..` and '.' from path. Rpis..Re(R0RaRKRhtindext ValueErrorRc(RbtlR^tj((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR-s0         cC`sttj|S(s|sorts output of python glob for http://bugs.python.org/issue30461 to allow extensions to have reproducible build results(tsortedtglob(tfileglob((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt sorted_globscC`st|s$ttt|g}t| sItt|xv|D]n}t|rd|kszd|krt|}tt||}|r|j|q|r|j|q|r|j|nt d||fqt||}t j j |r%|j|qt j j |rG|j|n|r]|j|nt j j |st d||fqqPt|r|jt |||qP|j|qPWg|D]}t|^qS(Nt*t?s#could not resolve pattern in %r: %rsnon-existing path in %r: %r(R/RiRjttypeR0RR.RRtprintRKRbRt _fix_pathsR-(Rt local_pathtinclude_non_existingt new_pathstnRtp2tn2((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs<$    RecC`s(t|r|f}nt|||S(s:Apply glob to paths and prepend local_path if needed. (R0R(RRR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR2-s  c C`szttds1tjt_tjtjntjd|d|dtjd|\}}tj |d}||fS(Nttempdirtsuffixtprefixtdirttexttw( Ryt_tdatattempfiletmkdtempRRRtmkstempRKtfdopen(RRRRR9tfo((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmake_temp_file4s cC`stjdkr"dtjkr"dSttjdr tjjr yddl}|j|j ddkr|j ddkr|j ddk r|j ddk s|j d dk r|j d dk s|j d dk rd SWq t k rq XndS( Ntcygwint USE_COLORitisattytcolorstpairstsetftsetbtsetaftsetabtscpi( RwtplatformRKRQRytstdoutRtcursest setuptermttigetnumttigetstrRt Exception(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRAs" !   tblacktreditgreenityellowitblueitmagentaitcyanitwhiteitdefaulti cC`sg}|r|jdn|rTdtj|jd}|jt|n|rdtj|jd}|jt|n|rddj||fS|SdS(Nt1iii(is [%sm%st;(Rt _colour_codesRRtlowertstrRc(Rtfgtbgtboldtseqtfgcodetbgcode((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt colour_text_scC`s|S(N((RRR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRnscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt default_textqscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRsscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRuscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRwscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRyscC`s t|dS(NR(R(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR{scC`sGtjdkrC|jdrC|ddtjj|d}n|S(NRs /cygdrivei t:i (RwRRRKRbtnormcase(Rb((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs%cC`sTtjdkrPtjjdddkr.tStjjdddkrPtSntS(s0Return true when using mingw32 environment. twin32tOSTYPERetmsystMSYSTEMtMINGW32(RwRRKRQRRtTruetFalse(((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR s cC`sItjjd}|dkr?ttj|d|d!}nd}|S(sGReturn version of MSVC runtime library, as defined by __MSC_VER__ macrosMSC v.iii N(RwtversiontfindRPR(tmsc_postmsc_ver((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmsvc_runtime_versions  !cC`s6t}|r.|dkr#d|Sd|SndSdS(sFReturn name of MSVC runtime library if Python was built with MSVC >= 7ismsvcr%is vcruntime%iN(tmsvc_runtime_majorR(tver((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmsvc_runtime_librarys    cC`sCidd6dd6dd6dd6d d 6d d 6jtd }|S(sFReturn major version of MSVC runtime coded like get_build_msvc_versioniFiiGiiPixiZiidi@iilN(RRRR(tmajor((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs  s.*[.](cpp|cxx|cc)\Zs.*[.](f90|f95|f77|for|ftn|f)\Zs.*[.](f90|f95)\Zs\s*module\s*(?P[\w_]+)cC`sut|sgSg}t|d}x?|D]7}t|}|r,|jd}|j|q,q,W|j|S(sRReturn a list of Fortran f90 module names that given source file defines. trR9(t f90_ext_matchRtf90_module_name_matchtgroupRR(tsourceRxtfRtmR9((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt_get_f90_moduless    cC`s t|tS(N(t isinstanceR(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR0scC`s%x|D]}t|stSqWtS(s4Return True if all items in lst are string objects. (R0RR(tlsttitem((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR!s  cC`s7t|rtSyt|Wntk r2tSXtS(N(R0RRJRR(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR/s  cC`s"t|o!d|kp!d|kS(NRR(R0(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytis_glob_patternscC`s!t|rt|S|gSdS(N(R/R[(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR1s  cC`sXd}xK|D]C}t|tr t|r8d}PqPt|rPd}qPq q W|S(s2Determine language value (c,f77,f90) from sources tf90tf77N(RRRRtfortran_ext_match(tsourcestlanguageR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR3s   cC`s%x|D]}t|rtSqWtS(s.Return True if sources contains Fortran files (RRR(RR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR"s  cC`s%x|D]}t|rtSqWtS(s*Return True if sources contains C++ files (t cxx_ext_matchRR(RR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR#s  cC`sg}g}g}g}xu|D]m}t|rct|}|rS|j|q|j|qt|r|j|q|j|qW||||fS(stReturn four lists of filenames containing C, C++, Fortran, and Fortran 90 module sources, respectively. (RRRR(Rt c_sourcest cxx_sourcest f_sourcestfmodule_sourcesRRx((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR$s    cC`sCg}x6|D].}ttjj|d}|j|q W|S(Ns*.h(RRKRbRcR(tdirectory_listtheadersR thead((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt _get_headerss  cC`sag}xT|D]L}tjj|}|ddkr |d|kr |j|dq q W|S(NiRe(RKRbRaR(tlist_of_sourcestdirecsRR ((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt_get_directoriess   cC`sGd}|dj|7}|dj|7}|dj|d7}|S(sb Return commandline representation used to determine if a file needs to be recompiled s commandline: RZs (Rc(tcc_argstextra_postargstpp_optstcmdline((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt_commandline_dep_string%s cC`stt|S(N(RR(R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR%1scC`st|stStjj|}tjjtj|g}|t|jtj }|rz|d rz|d}n|r|ddkrtStj j |}tjj |S(s1Return true if directory is local directory. iiRC( R0RRKRbRgt commonprefixtgetcwdRJRaRhRctisdir(t directorytabs_dirtctnew_dir((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR&5s  c c`sidd6dd6dd6}tjd}xtj|dtD]r\}}}g|D]}||krV|^qV}||(x4|D],}|j|stjj||VqqWq@WdS(NitCVSs.svnRCs(?:[~#]|\.py[co]|\.o)$ttopdown(tretcompileRKtwalkRtsearchRbRc( ttop_pathtpruned_directoriestprune_file_pattdirpathtdirnamest filenamesR tprunedR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytgeneral_source_filesDs%% c c`sdddg}tjd}xtj|dtD]\}}}g|D]}||krJ|^qJ}||(x|D]}tjj||}t||} g} x^tj|D]M} tjj|| } tjj | r|j |  r| j | qqW| | fVqvWq4W|}t||} gtj|D]*} |j | s?tjj|| ^q?}g|D]} tjj | rv| ^qv} | | fVdS(sJReturn a directory name relative to top_path and files contained. Rs.svnRCs(?:[~#]|\.py[co]|\.o)$RN( RRRKRRRbRcRntlistdirtisfileRR( RRRRRR R R!tdpathtrpathtfilesRR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt general_source_directories_filesNs(%% "*+cC`sg}g|jD]}t|r|^q}|j||jt|x[|jD]P}t|r|jtt|qXtj j |rX|j |qXqXW|S(N( RR0RR%tdependsR&R[R"RKRbR$R(textR t_mRR ((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR'hs(  cC`s)g|D]}t|r|^q}|S(N(R0(tscriptsR+((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR(us%cC`sg}|djdg}g|D]}t|r#|^q#}|j||jt||djdg}xX|D]P}t|r|jtt|q~tjj |r~|j |q~q~W|S(NiRR)( RRR0RR%R&R[R"RKRbR$R(tlibR RR+R)R ((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR)ys%   cC`stjj}|jdd}|dkrB|jdd}n|stjjdsltjjdrud}qtjjdrd}qtjjd rd }qd |kr|jd |jd dd }qn|S(s;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. t EXT_SUFFIXtSORetlinuxt gnukfreebsds.sotdarwins.dylibtwins.dlltSOABIRpiN( t distutilst sysconfigtget_config_varsRRRRwRRR(t is_python_exttconfvarstso_ext((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytget_shared_lib_extensions     (cC`st|r|gS|d}g}x|D]}t|drEq*nt|rm|jtt|q*t|rtjj|r|j |qt d|q*t t |q*W|S(Nit__call__sNot existing data file:( R0RyR&RR[R"RKRbR$RRt TypeErrorRj(tdataRR R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR*s     cG`s&djg|D]}|r |^q S(NRp(Rc(R]R_((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR+scC`seytj|dSWnItk r`tjdj}x!t|dD]}|j}qIW|SXdS(s:Return frame object from call stack with given level. iiN(Rwt _getframeRMtexc_infottb_frameR\tf_back(tlevelRzt_((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR,s  c B`seZdddddddddd g Zd d gZd d gZgZd7d7d7d7dddZdZdZ dZ dZ dZ ddZ ddZd7d7ddZd7edZdZdZdZdZdZdZd Zd!Zd"Zd#Zd$Zd7d%Zd7d&Zd'Zd(Z d)Z!d*Z"d+Z#d,Z$d-Z%d.Z&d/Z'd0Z(d7d7d1Z)e*d2Z+e*d3Z,d4d5Z-d6Z.RS(8tpackagest ext_modulest data_filest include_dirst librariesRR,t py_modulestinstalled_librariest define_macrost package_dirtinstalled_pkg_configR9Rissetup.pyc K`sut|||_d |_t|}t|||_|d krZ|j}d|_n|d krr|j}n3tjj t |j|rt |j|}ntjj |pdst d|fn||_ ||_ tjj|jjd|_|j|_|j|_xB|jD]7} tj|j| g} t|| t| q*Wx<|jD]1} tj|j| i} t|| | qoW|j|j} |j|_x|jD]} | | krqn|| } t|| | t| tr"|jj| qt| trD|jj| q|jj| qWtjj t |dr|j!j|j||j"|j>> setup(**config.todict()) #doctest: +SKIP (t_optimize_data_filesRVRXR\RS(R<R RiRR_((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyttodictEs  cC`s|jdst|ndS(NRR(R_R(R<tmessage((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytinfoXs cC`stjjd|fdS(Ns Warning: %s(Rwtstderrtwrite(R<Rm((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytwarn\scK`sPxI|jD];\}}||jkr8||j|, ) * 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 Nsnot a string: %rRisNot a directory, skippingiscannot fill pattern %r with %rs,mismatch of pattern_list=%s and path_list=%s(!R/Rt add_data_dirR0R=RKRbtisabsRRRRRRaRhtreverseR[R\RJRRRnRRRRiRjRqRcRARGR(RT(R<t data_pathR RRt pattern_listtrlR^RbR&t path_listt target_listRRXRGtd1Rt target_path((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRsr8  &             8    &     cC`si}xU|jD]J\}}||kr8t||,) * 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'). iNiR<ReR(RJtadd_data_filesRiR/RR0R=RjRRyRKRbRRtRRRRaRhRtpopRRcRARGRT(R<R'RR tfilepatRRRbRRR^RRXRG((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRsfX                   &%   cC`sZ|j}|dk rFt|ds3g|_n|jj|n|jj|dS(sAdd 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. RLN(RARRyRLR(R<tmacrosRX((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytadd_define_macros7s    cG`si|j|}|j}|dk rU|jdkrBg|_n|jj|n|jj|dS(sAdd 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(RRARRHR(R<RRHRX((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytadd_include_dirsGs   cG`s&g}x|D]}t|rTg|j|D]}|j|j|f^q/q t|ttf s|t|dkrtt |ng|j|dD]}|j|d|f^qq W|j }|dk r|j dkrg|_ n|j j |n|j j |dS(sAdd 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. iiiN(R0RRR9RttupleR[RJR=RjRARRR(R<R'RRbRRX((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt add_headersWs  5(;   cO`s+|jdt}t|d|jd|S(sApply 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. RR(RRRR2R(R<RtkwsR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRys   cC`sMxF|jD]8}||}|dkr |j|}|||/bin/ directory. N(RRARR,R(R<R'R,RX((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt add_scriptss   cK`sx9|jD].}t||}|j|j|gq Wx9|jD].}t||}|j|j|iqFW|j|j|j}x|jD]}||kr-t||d}|r|||krqn|j d||||jddft |||||jj |q||jkrf|j d|t||||fq||kruqt d|qWdS(Ns"Inheriting attribute %r=%r from %rR9Rs*Ignoring attempt to set %r (from %r to %r)sDon't know about key=%r(RVRSRRRRXtupdateR\R]RRqRZRRnR(R<R^RsR_Ri((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs,  ! ! cC`sddlm}|j|j|j}dd d}|d|jd7}|jxC|D];}t||d}|r[|d |||f7}q[q[W|d 7}|S(Ni(tpformatts-----s-----s----->( tpprintRRVRXR\R9tsortRSR(R<RRiRRR_((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt__str__s  ! cC`sltd}|jd|_d|_tjjd}|rhtjjd|g}|tjd\d+)trevisionRtSVN_ASP_DOT_NET_HACKt_svntentriess.svnis\d+)"sdir[\n\r]+(?P\d+)N(RRKRtchdirt subprocesstPopenRtPIPERRtmatchtreadRRPRRwRRQRRR.RbR$RRR( R<RbRRtcwdRtsoutRRtfstr((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt_get_svn_revision)s>     $   c C`sd}d}tj}yetj|p*dtjdgdtdtjdddt}|j}t j d|j }Wnt k rnXtj||rt |jd}|St|d d }t|d d }tjj|rd} t|} | j j} | ji} xst|d D]b} | jd \}}|| krh|} nyt |}Wntk rq7nX|| |\d+)Rs.hgtbranchs branch.cacheRiN(RRKRRRRRRRRRRRRPRR.RbR$RRRtfileRaRRR(R<RbRRRRRt branch_fntbranch_cache_fntbranch0Rt revision0t branch_mapRtbranch1t revision1((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt_get_hg_revisionNsF          cC`s7t|dd}|dk r"|S|dkrZd|jjddddddg}n |g}|dkrdd |jjddd g}n |g}x"|D]}t|j|}tjj|rd}tjj tjj |d} t |j| } y(t dj | jd||} Wn3tk rft} |jt| d} nX| dkryqnx0|D](} t| | d}|dk rPqqW|dk rPqqqW|dk r||_|S|j|j}|dkr|j|j}n|dk r3t|}||_n|S(sTry 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. Rs__version__.pyRpis _version.pys version.pys__svn_version__.pys__hg_version__.pyt __version__t_versions.pyRyiiRDN(s.pyRyi(RSRR9RaR.RRKRbR$RRR+RRct ImportErrorR RqRRRR(R<t version_filetversion_variableRR't version_varsRRRnR9Rtversion_moduletmsgR_R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt get_versionys\         "              c`sxtjdjjtjjsBdkrFdSfd}jd|fdS(sAppends 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. s__svn_version__.pyNc`stjjsbt}jd|ftd}|jd||jnddl}jfd}|j |S(NsCreating %s (version=%r)Rs version = %r ic`s{rwytj||d|Wntk r8nXy'tj|d|d|dWqwtk rsqwXndS(Nsremoved R(RKtremoveR (RR(tdelete(s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytrm_files   ( RKRbR$RRnRRpRtatexittregister(RRRR(RRR<ttarget(s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytgenerate_svn_version_pys    Re(R.RRRKRbR$RR(R<RR((RRR<Rs8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmake_svn_version_pys c`sxtjdjjtjjsBdkrFdSfd}jd|fdS(sAppends 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. s__hg_version__.pyNc`stjjsbt}jd|ftd}|jd||jnddl}jfd}|j |S(NsCreating %s (version=%r)Rs version = %r ic`s{rwytj||d|Wntk r8nXy'tj|d|d|dWqwtk rsqwXndS(Nsremoved R(RKRR (RR(R(s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs   ( RKRbR$RRnRRpRRR(RRRR(RRR<R(s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytgenerate_hg_version_pys    Re(R.RRRKRbR$RR(R<RR((RRR<Rs8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmake_hg_version_pys t __config__cC`s |jj|j|tfdS(sGenerate package __config__.py file containing system_info information used during building the package. This file is installed to the package installation directory. N(RJRR9R(R<R9((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytmake_config_pyscG`sDddlm}m}i}x!|D]}||||q#W|S(sGet resources information. Return information (from system_info.get_info) for all of the names in the argument list in a single dictionary. i(R5R(t system_infoR5R(R<tnamesR5Rt info_dictR_((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR5s  N(/R>R?RURWR[tnumpy_include_dirsRR=RlRnRqRaRARxRRtRRRRkRRRRRRRRRRRRRRRRRRRRRRRRRRR5(((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRsh      [       ) ; ) y   "   g $  3 I       % +F + * cC`ss||krkddl}|jj}|dkrOddlm}|dn|j|}|||>> 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) i(t parse_flagsRRLtignored(RRR6tcflagstlibsRrR(RRRtpkg_infoRnRRh((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyR5ns-%cC`s_tjddkr"ddl}n ddl}y|jtSWntk rZtSt}nXdS(Nii(RwRtbuiltinst __builtin__t__NUMPY_SETUP__RRMR(RR((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pytis_bootstrappings  cC`sQddl}|jd||||||fddt|||}|jS(sqReturn a configuration dictionary for usage in configuration() function defined in file setup_.py. iNsXUse Configuration(%r,%r,top_path=%r) instead of deprecated default_config_dict(%r,%r,%r)t stackleveli(twarningsRqRRl(R9RdRR!R((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs   cK`sqxj|jD]\\}}||kr_||}t|trK||| 200: v = v[:60] + " ...\n... " + v[-60:] print(" %s = %s" % (k,v)) (tnumpy.distutils.system_infoRtdistutils.dir_utilR)RKRbRtRRpRRwtargvt saved_resultsRrR(RRR)RRR^((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyRs$    cC`s,|jdks%td|jn|jS(sdReturn version major and minor of compiler instance if it is MSVC, raise an exception otherwise.tmsvcs"Compiler instance is not msvc (%s)(t compiler_typeRt_MSVCCompiler__version(tcompiler((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyt msvc_version s(mt __future__RRRRKRRwRYRRRRRRNR5RRtdistutils.msvccompilerRt threadingRttlocalRtdummy_threadingRRR Rtnumpy.distutils.compatR t numpy.compatRRt__all__tobjectR8R7R4RRnRR~R.RR-RRRR2RRR^RRRRRRRRRRR RRRRtIRRRRRRR0R!R/RR1R3R"R#R$RRR R%R&R"R(R'R(R)R;R*R+R,RRRRR6R5RRRRRR2(((s8/tmp/pip-build-fiC0ax/numpy/numpy/distutils/misc_util.pyts                          !        %  !                       /   V  & <   4