system_info.py 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975
  1. #!/usr/bin/env python
  2. """
  3. This file defines a set of system_info classes for getting
  4. information about various resources (libraries, library directories,
  5. include directories, etc.) in the system. Currently, the following
  6. classes are available:
  7. atlas_info
  8. atlas_threads_info
  9. atlas_blas_info
  10. atlas_blas_threads_info
  11. lapack_atlas_info
  12. lapack_atlas_threads_info
  13. atlas_3_10_info
  14. atlas_3_10_threads_info
  15. atlas_3_10_blas_info,
  16. atlas_3_10_blas_threads_info,
  17. lapack_atlas_3_10_info
  18. lapack_atlas_3_10_threads_info
  19. flame_info
  20. blas_info
  21. lapack_info
  22. openblas_info
  23. openblas64__info
  24. openblas_ilp64_info
  25. blis_info
  26. blas_opt_info # usage recommended
  27. lapack_opt_info # usage recommended
  28. blas_ilp64_opt_info # usage recommended (general ILP64 BLAS)
  29. lapack_ilp64_opt_info # usage recommended (general ILP64 LAPACK)
  30. blas_ilp64_plain_opt_info # usage recommended (general ILP64 BLAS, no symbol suffix)
  31. lapack_ilp64_plain_opt_info # usage recommended (general ILP64 LAPACK, no symbol suffix)
  32. blas64__opt_info # usage recommended (general ILP64 BLAS, 64_ symbol suffix)
  33. lapack64__opt_info # usage recommended (general ILP64 LAPACK, 64_ symbol suffix)
  34. fftw_info,dfftw_info,sfftw_info
  35. fftw_threads_info,dfftw_threads_info,sfftw_threads_info
  36. djbfft_info
  37. x11_info
  38. lapack_src_info
  39. blas_src_info
  40. numpy_info
  41. numarray_info
  42. numpy_info
  43. boost_python_info
  44. agg2_info
  45. wx_info
  46. gdk_pixbuf_xlib_2_info
  47. gdk_pixbuf_2_info
  48. gdk_x11_2_info
  49. gtkp_x11_2_info
  50. gtkp_2_info
  51. xft_info
  52. freetype2_info
  53. umfpack_info
  54. Usage:
  55. info_dict = get_info(<name>)
  56. where <name> is a string 'atlas','x11','fftw','lapack','blas',
  57. 'lapack_src', 'blas_src', etc. For a complete list of allowed names,
  58. see the definition of get_info() function below.
  59. Returned info_dict is a dictionary which is compatible with
  60. distutils.setup keyword arguments. If info_dict == {}, then the
  61. asked resource is not available (system_info could not find it).
  62. Several *_info classes specify an environment variable to specify
  63. the locations of software. When setting the corresponding environment
  64. variable to 'None' then the software will be ignored, even when it
  65. is available in system.
  66. Global parameters:
  67. system_info.search_static_first - search static libraries (.a)
  68. in precedence to shared ones (.so, .sl) if enabled.
  69. system_info.verbosity - output the results to stdout if enabled.
  70. The file 'site.cfg' is looked for in
  71. 1) Directory of main setup.py file being run.
  72. 2) Home directory of user running the setup.py file as ~/.numpy-site.cfg
  73. 3) System wide directory (location of this file...)
  74. The first one found is used to get system configuration options The
  75. format is that used by ConfigParser (i.e., Windows .INI style). The
  76. section ALL has options that are the default for each section. The
  77. available sections are fftw, atlas, and x11. Appropriate defaults are
  78. used if nothing is specified.
  79. The order of finding the locations of resources is the following:
  80. 1. environment variable
  81. 2. section in site.cfg
  82. 3. ALL section in site.cfg
  83. Only the first complete match is returned.
  84. Example:
  85. ----------
  86. [ALL]
  87. library_dirs = /usr/lib:/usr/local/lib:/opt/lib
  88. include_dirs = /usr/include:/usr/local/include:/opt/include
  89. src_dirs = /usr/local/src:/opt/src
  90. # search static libraries (.a) in preference to shared ones (.so)
  91. search_static_first = 0
  92. [fftw]
  93. libraries = rfftw, fftw
  94. [atlas]
  95. library_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas
  96. # for overriding the names of the atlas libraries
  97. libraries = lapack, f77blas, cblas, atlas
  98. [x11]
  99. library_dirs = /usr/X11R6/lib
  100. include_dirs = /usr/X11R6/include
  101. ----------
  102. Note that the ``libraries`` key is the default setting for libraries.
  103. Authors:
  104. Pearu Peterson <pearu@cens.ioc.ee>, February 2002
  105. David M. Cooke <cookedm@physics.mcmaster.ca>, April 2002
  106. Copyright 2002 Pearu Peterson all rights reserved,
  107. Pearu Peterson <pearu@cens.ioc.ee>
  108. Permission to use, modify, and distribute this software is given under the
  109. terms of the NumPy (BSD style) license. See LICENSE.txt that came with
  110. this distribution for specifics.
  111. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
  112. """
  113. from __future__ import division, absolute_import, print_function
  114. import sys
  115. import os
  116. import re
  117. import copy
  118. import warnings
  119. import subprocess
  120. import textwrap
  121. from glob import glob
  122. from functools import reduce
  123. if sys.version_info[0] < 3:
  124. from ConfigParser import NoOptionError
  125. from ConfigParser import RawConfigParser as ConfigParser
  126. else:
  127. from configparser import NoOptionError
  128. from configparser import RawConfigParser as ConfigParser
  129. # It seems that some people are importing ConfigParser from here so is
  130. # good to keep its class name. Use of RawConfigParser is needed in
  131. # order to be able to load path names with percent in them, like
  132. # `feature%2Fcool` which is common on git flow branch names.
  133. from distutils.errors import DistutilsError
  134. from distutils.dist import Distribution
  135. import distutils.sysconfig
  136. from numpy.distutils import log
  137. from distutils.util import get_platform
  138. from numpy.distutils.exec_command import (
  139. find_executable, filepath_from_subprocess_output,
  140. get_pythonexe)
  141. from numpy.distutils.misc_util import (is_sequence, is_string,
  142. get_shared_lib_extension)
  143. from numpy.distutils.command.config import config as cmd_config
  144. from numpy.distutils.compat import get_exception
  145. from numpy.distutils import customized_ccompiler as _customized_ccompiler
  146. from numpy.distutils import _shell_utils
  147. import distutils.ccompiler
  148. import tempfile
  149. import shutil
  150. # Determine number of bits
  151. import platform
  152. _bits = {'32bit': 32, '64bit': 64}
  153. platform_bits = _bits[platform.architecture()[0]]
  154. global_compiler = None
  155. def customized_ccompiler():
  156. global global_compiler
  157. if not global_compiler:
  158. global_compiler = _customized_ccompiler()
  159. return global_compiler
  160. def _c_string_literal(s):
  161. """
  162. Convert a python string into a literal suitable for inclusion into C code
  163. """
  164. # only these three characters are forbidden in C strings
  165. s = s.replace('\\', r'\\')
  166. s = s.replace('"', r'\"')
  167. s = s.replace('\n', r'\n')
  168. return '"{}"'.format(s)
  169. def libpaths(paths, bits):
  170. """Return a list of library paths valid on 32 or 64 bit systems.
  171. Inputs:
  172. paths : sequence
  173. A sequence of strings (typically paths)
  174. bits : int
  175. An integer, the only valid values are 32 or 64. A ValueError exception
  176. is raised otherwise.
  177. Examples:
  178. Consider a list of directories
  179. >>> paths = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']
  180. For a 32-bit platform, this is already valid:
  181. >>> np.distutils.system_info.libpaths(paths,32)
  182. ['/usr/X11R6/lib', '/usr/X11/lib', '/usr/lib']
  183. On 64 bits, we prepend the '64' postfix
  184. >>> np.distutils.system_info.libpaths(paths,64)
  185. ['/usr/X11R6/lib64', '/usr/X11R6/lib', '/usr/X11/lib64', '/usr/X11/lib',
  186. '/usr/lib64', '/usr/lib']
  187. """
  188. if bits not in (32, 64):
  189. raise ValueError("Invalid bit size in libpaths: 32 or 64 only")
  190. # Handle 32bit case
  191. if bits == 32:
  192. return paths
  193. # Handle 64bit case
  194. out = []
  195. for p in paths:
  196. out.extend([p + '64', p])
  197. return out
  198. if sys.platform == 'win32':
  199. default_lib_dirs = ['C:\\',
  200. os.path.join(distutils.sysconfig.EXEC_PREFIX,
  201. 'libs')]
  202. default_runtime_dirs = []
  203. default_include_dirs = []
  204. default_src_dirs = ['.']
  205. default_x11_lib_dirs = []
  206. default_x11_include_dirs = []
  207. _include_dirs = [
  208. 'include',
  209. 'include/suitesparse',
  210. ]
  211. _lib_dirs = [
  212. 'lib',
  213. ]
  214. _include_dirs = [d.replace('/', os.sep) for d in _include_dirs]
  215. _lib_dirs = [d.replace('/', os.sep) for d in _lib_dirs]
  216. def add_system_root(library_root):
  217. """Add a package manager root to the include directories"""
  218. global default_lib_dirs
  219. global default_include_dirs
  220. library_root = os.path.normpath(library_root)
  221. default_lib_dirs.extend(
  222. os.path.join(library_root, d) for d in _lib_dirs)
  223. default_include_dirs.extend(
  224. os.path.join(library_root, d) for d in _include_dirs)
  225. if sys.version_info >= (3, 3):
  226. # VCpkg is the de-facto package manager on windows for C/C++
  227. # libraries. If it is on the PATH, then we append its paths here.
  228. # We also don't re-implement shutil.which for Python 2.7 because
  229. # vcpkg doesn't support MSVC 2008.
  230. vcpkg = shutil.which('vcpkg')
  231. if vcpkg:
  232. vcpkg_dir = os.path.dirname(vcpkg)
  233. if platform.architecture() == '32bit':
  234. specifier = 'x86'
  235. else:
  236. specifier = 'x64'
  237. vcpkg_installed = os.path.join(vcpkg_dir, 'installed')
  238. for vcpkg_root in [
  239. os.path.join(vcpkg_installed, specifier + '-windows'),
  240. os.path.join(vcpkg_installed, specifier + '-windows-static'),
  241. ]:
  242. add_system_root(vcpkg_root)
  243. # Conda is another popular package manager that provides libraries
  244. conda = shutil.which('conda')
  245. if conda:
  246. conda_dir = os.path.dirname(conda)
  247. add_system_root(os.path.join(conda_dir, '..', 'Library'))
  248. add_system_root(os.path.join(conda_dir, 'Library'))
  249. else:
  250. default_lib_dirs = libpaths(['/usr/local/lib', '/opt/lib', '/usr/lib',
  251. '/opt/local/lib', '/sw/lib'], platform_bits)
  252. default_runtime_dirs = []
  253. default_include_dirs = ['/usr/local/include',
  254. '/opt/include', '/usr/include',
  255. # path of umfpack under macports
  256. '/opt/local/include/ufsparse',
  257. '/opt/local/include', '/sw/include',
  258. '/usr/include/suitesparse']
  259. default_src_dirs = ['.', '/usr/local/src', '/opt/src', '/sw/src']
  260. default_x11_lib_dirs = libpaths(['/usr/X11R6/lib', '/usr/X11/lib',
  261. '/usr/lib'], platform_bits)
  262. default_x11_include_dirs = ['/usr/X11R6/include', '/usr/X11/include',
  263. '/usr/include']
  264. if os.path.exists('/usr/lib/X11'):
  265. globbed_x11_dir = glob('/usr/lib/*/libX11.so')
  266. if globbed_x11_dir:
  267. x11_so_dir = os.path.split(globbed_x11_dir[0])[0]
  268. default_x11_lib_dirs.extend([x11_so_dir, '/usr/lib/X11'])
  269. default_x11_include_dirs.extend(['/usr/lib/X11/include',
  270. '/usr/include/X11'])
  271. with open(os.devnull, 'w') as tmp:
  272. try:
  273. p = subprocess.Popen(["gcc", "-print-multiarch"], stdout=subprocess.PIPE,
  274. stderr=tmp)
  275. except (OSError, DistutilsError):
  276. # OSError if gcc is not installed, or SandboxViolation (DistutilsError
  277. # subclass) if an old setuptools bug is triggered (see gh-3160).
  278. pass
  279. else:
  280. triplet = str(p.communicate()[0].decode().strip())
  281. if p.returncode == 0:
  282. # gcc supports the "-print-multiarch" option
  283. default_x11_lib_dirs += [os.path.join("/usr/lib/", triplet)]
  284. default_lib_dirs += [os.path.join("/usr/lib/", triplet)]
  285. if os.path.join(sys.prefix, 'lib') not in default_lib_dirs:
  286. default_lib_dirs.insert(0, os.path.join(sys.prefix, 'lib'))
  287. default_include_dirs.append(os.path.join(sys.prefix, 'include'))
  288. default_src_dirs.append(os.path.join(sys.prefix, 'src'))
  289. default_lib_dirs = [_m for _m in default_lib_dirs if os.path.isdir(_m)]
  290. default_runtime_dirs = [_m for _m in default_runtime_dirs if os.path.isdir(_m)]
  291. default_include_dirs = [_m for _m in default_include_dirs if os.path.isdir(_m)]
  292. default_src_dirs = [_m for _m in default_src_dirs if os.path.isdir(_m)]
  293. so_ext = get_shared_lib_extension()
  294. def get_standard_file(fname):
  295. """Returns a list of files named 'fname' from
  296. 1) System-wide directory (directory-location of this module)
  297. 2) Users HOME directory (os.environ['HOME'])
  298. 3) Local directory
  299. """
  300. # System-wide file
  301. filenames = []
  302. try:
  303. f = __file__
  304. except NameError:
  305. f = sys.argv[0]
  306. else:
  307. sysfile = os.path.join(os.path.split(os.path.abspath(f))[0],
  308. fname)
  309. if os.path.isfile(sysfile):
  310. filenames.append(sysfile)
  311. # Home directory
  312. # And look for the user config file
  313. try:
  314. f = os.path.expanduser('~')
  315. except KeyError:
  316. pass
  317. else:
  318. user_file = os.path.join(f, fname)
  319. if os.path.isfile(user_file):
  320. filenames.append(user_file)
  321. # Local file
  322. if os.path.isfile(fname):
  323. filenames.append(os.path.abspath(fname))
  324. return filenames
  325. def get_info(name, notfound_action=0):
  326. """
  327. notfound_action:
  328. 0 - do nothing
  329. 1 - display warning message
  330. 2 - raise error
  331. """
  332. cl = {'atlas': atlas_info, # use lapack_opt or blas_opt instead
  333. 'atlas_threads': atlas_threads_info, # ditto
  334. 'atlas_blas': atlas_blas_info,
  335. 'atlas_blas_threads': atlas_blas_threads_info,
  336. 'lapack_atlas': lapack_atlas_info, # use lapack_opt instead
  337. 'lapack_atlas_threads': lapack_atlas_threads_info, # ditto
  338. 'atlas_3_10': atlas_3_10_info, # use lapack_opt or blas_opt instead
  339. 'atlas_3_10_threads': atlas_3_10_threads_info, # ditto
  340. 'atlas_3_10_blas': atlas_3_10_blas_info,
  341. 'atlas_3_10_blas_threads': atlas_3_10_blas_threads_info,
  342. 'lapack_atlas_3_10': lapack_atlas_3_10_info, # use lapack_opt instead
  343. 'lapack_atlas_3_10_threads': lapack_atlas_3_10_threads_info, # ditto
  344. 'flame': flame_info, # use lapack_opt instead
  345. 'mkl': mkl_info,
  346. # openblas which may or may not have embedded lapack
  347. 'openblas': openblas_info, # use blas_opt instead
  348. # openblas with embedded lapack
  349. 'openblas_lapack': openblas_lapack_info, # use blas_opt instead
  350. 'openblas_clapack': openblas_clapack_info, # use blas_opt instead
  351. 'blis': blis_info, # use blas_opt instead
  352. 'lapack_mkl': lapack_mkl_info, # use lapack_opt instead
  353. 'blas_mkl': blas_mkl_info, # use blas_opt instead
  354. 'accelerate': accelerate_info, # use blas_opt instead
  355. 'openblas64_': openblas64__info,
  356. 'openblas64__lapack': openblas64__lapack_info,
  357. 'openblas_ilp64': openblas_ilp64_info,
  358. 'openblas_ilp64_lapack': openblas_ilp64_lapack_info,
  359. 'x11': x11_info,
  360. 'fft_opt': fft_opt_info,
  361. 'fftw': fftw_info,
  362. 'fftw2': fftw2_info,
  363. 'fftw3': fftw3_info,
  364. 'dfftw': dfftw_info,
  365. 'sfftw': sfftw_info,
  366. 'fftw_threads': fftw_threads_info,
  367. 'dfftw_threads': dfftw_threads_info,
  368. 'sfftw_threads': sfftw_threads_info,
  369. 'djbfft': djbfft_info,
  370. 'blas': blas_info, # use blas_opt instead
  371. 'lapack': lapack_info, # use lapack_opt instead
  372. 'lapack_src': lapack_src_info,
  373. 'blas_src': blas_src_info,
  374. 'numpy': numpy_info,
  375. 'f2py': f2py_info,
  376. 'Numeric': Numeric_info,
  377. 'numeric': Numeric_info,
  378. 'numarray': numarray_info,
  379. 'numerix': numerix_info,
  380. 'lapack_opt': lapack_opt_info,
  381. 'lapack_ilp64_opt': lapack_ilp64_opt_info,
  382. 'lapack_ilp64_plain_opt': lapack_ilp64_plain_opt_info,
  383. 'lapack64__opt': lapack64__opt_info,
  384. 'blas_opt': blas_opt_info,
  385. 'blas_ilp64_opt': blas_ilp64_opt_info,
  386. 'blas_ilp64_plain_opt': blas_ilp64_plain_opt_info,
  387. 'blas64__opt': blas64__opt_info,
  388. 'boost_python': boost_python_info,
  389. 'agg2': agg2_info,
  390. 'wx': wx_info,
  391. 'gdk_pixbuf_xlib_2': gdk_pixbuf_xlib_2_info,
  392. 'gdk-pixbuf-xlib-2.0': gdk_pixbuf_xlib_2_info,
  393. 'gdk_pixbuf_2': gdk_pixbuf_2_info,
  394. 'gdk-pixbuf-2.0': gdk_pixbuf_2_info,
  395. 'gdk': gdk_info,
  396. 'gdk_2': gdk_2_info,
  397. 'gdk-2.0': gdk_2_info,
  398. 'gdk_x11_2': gdk_x11_2_info,
  399. 'gdk-x11-2.0': gdk_x11_2_info,
  400. 'gtkp_x11_2': gtkp_x11_2_info,
  401. 'gtk+-x11-2.0': gtkp_x11_2_info,
  402. 'gtkp_2': gtkp_2_info,
  403. 'gtk+-2.0': gtkp_2_info,
  404. 'xft': xft_info,
  405. 'freetype2': freetype2_info,
  406. 'umfpack': umfpack_info,
  407. 'amd': amd_info,
  408. }.get(name.lower(), system_info)
  409. return cl().get_info(notfound_action)
  410. class NotFoundError(DistutilsError):
  411. """Some third-party program or library is not found."""
  412. class AliasedOptionError(DistutilsError):
  413. """
  414. Aliases entries in config files should not be existing.
  415. In section '{section}' we found multiple appearances of options {options}."""
  416. class AtlasNotFoundError(NotFoundError):
  417. """
  418. Atlas (http://github.com/math-atlas/math-atlas) libraries not found.
  419. Directories to search for the libraries can be specified in the
  420. numpy/distutils/site.cfg file (section [atlas]) or by setting
  421. the ATLAS environment variable."""
  422. class FlameNotFoundError(NotFoundError):
  423. """
  424. FLAME (http://www.cs.utexas.edu/~flame/web/) libraries not found.
  425. Directories to search for the libraries can be specified in the
  426. numpy/distutils/site.cfg file (section [flame])."""
  427. class LapackNotFoundError(NotFoundError):
  428. """
  429. Lapack (http://www.netlib.org/lapack/) libraries not found.
  430. Directories to search for the libraries can be specified in the
  431. numpy/distutils/site.cfg file (section [lapack]) or by setting
  432. the LAPACK environment variable."""
  433. class LapackSrcNotFoundError(LapackNotFoundError):
  434. """
  435. Lapack (http://www.netlib.org/lapack/) sources not found.
  436. Directories to search for the sources can be specified in the
  437. numpy/distutils/site.cfg file (section [lapack_src]) or by setting
  438. the LAPACK_SRC environment variable."""
  439. class LapackILP64NotFoundError(NotFoundError):
  440. """
  441. 64-bit Lapack libraries not found.
  442. Known libraries in numpy/distutils/site.cfg file are:
  443. openblas64_, openblas_ilp64
  444. """
  445. class BlasOptNotFoundError(NotFoundError):
  446. """
  447. Optimized (vendor) Blas libraries are not found.
  448. Falls back to netlib Blas library which has worse performance.
  449. A better performance should be easily gained by switching
  450. Blas library."""
  451. class BlasNotFoundError(NotFoundError):
  452. """
  453. Blas (http://www.netlib.org/blas/) libraries not found.
  454. Directories to search for the libraries can be specified in the
  455. numpy/distutils/site.cfg file (section [blas]) or by setting
  456. the BLAS environment variable."""
  457. class BlasILP64NotFoundError(NotFoundError):
  458. """
  459. 64-bit Blas libraries not found.
  460. Known libraries in numpy/distutils/site.cfg file are:
  461. openblas64_, openblas_ilp64
  462. """
  463. class BlasSrcNotFoundError(BlasNotFoundError):
  464. """
  465. Blas (http://www.netlib.org/blas/) sources not found.
  466. Directories to search for the sources can be specified in the
  467. numpy/distutils/site.cfg file (section [blas_src]) or by setting
  468. the BLAS_SRC environment variable."""
  469. class FFTWNotFoundError(NotFoundError):
  470. """
  471. FFTW (http://www.fftw.org/) libraries not found.
  472. Directories to search for the libraries can be specified in the
  473. numpy/distutils/site.cfg file (section [fftw]) or by setting
  474. the FFTW environment variable."""
  475. class DJBFFTNotFoundError(NotFoundError):
  476. """
  477. DJBFFT (https://cr.yp.to/djbfft.html) libraries not found.
  478. Directories to search for the libraries can be specified in the
  479. numpy/distutils/site.cfg file (section [djbfft]) or by setting
  480. the DJBFFT environment variable."""
  481. class NumericNotFoundError(NotFoundError):
  482. """
  483. Numeric (https://www.numpy.org/) module not found.
  484. Get it from above location, install it, and retry setup.py."""
  485. class X11NotFoundError(NotFoundError):
  486. """X11 libraries not found."""
  487. class UmfpackNotFoundError(NotFoundError):
  488. """
  489. UMFPACK sparse solver (https://www.cise.ufl.edu/research/sparse/umfpack/)
  490. not found. Directories to search for the libraries can be specified in the
  491. numpy/distutils/site.cfg file (section [umfpack]) or by setting
  492. the UMFPACK environment variable."""
  493. class system_info(object):
  494. """ get_info() is the only public method. Don't use others.
  495. """
  496. section = 'ALL'
  497. dir_env_var = None
  498. search_static_first = 0 # XXX: disabled by default, may disappear in
  499. # future unless it is proved to be useful.
  500. saved_results = {}
  501. notfounderror = NotFoundError
  502. def __init__(self,
  503. default_lib_dirs=default_lib_dirs,
  504. default_include_dirs=default_include_dirs,
  505. ):
  506. self.__class__.info = {}
  507. self.local_prefixes = []
  508. defaults = {'library_dirs': os.pathsep.join(default_lib_dirs),
  509. 'include_dirs': os.pathsep.join(default_include_dirs),
  510. 'runtime_library_dirs': os.pathsep.join(default_runtime_dirs),
  511. 'rpath': '',
  512. 'src_dirs': os.pathsep.join(default_src_dirs),
  513. 'search_static_first': str(self.search_static_first),
  514. 'extra_compile_args': '', 'extra_link_args': ''}
  515. self.cp = ConfigParser(defaults)
  516. self.files = []
  517. self.files.extend(get_standard_file('.numpy-site.cfg'))
  518. self.files.extend(get_standard_file('site.cfg'))
  519. self.parse_config_files()
  520. if self.section is not None:
  521. self.search_static_first = self.cp.getboolean(
  522. self.section, 'search_static_first')
  523. assert isinstance(self.search_static_first, int)
  524. def parse_config_files(self):
  525. self.cp.read(self.files)
  526. if not self.cp.has_section(self.section):
  527. if self.section is not None:
  528. self.cp.add_section(self.section)
  529. def calc_libraries_info(self):
  530. libs = self.get_libraries()
  531. dirs = self.get_lib_dirs()
  532. # The extensions use runtime_library_dirs
  533. r_dirs = self.get_runtime_lib_dirs()
  534. # Intrinsic distutils use rpath, we simply append both entries
  535. # as though they were one entry
  536. r_dirs.extend(self.get_runtime_lib_dirs(key='rpath'))
  537. info = {}
  538. for lib in libs:
  539. i = self.check_libs(dirs, [lib])
  540. if i is not None:
  541. dict_append(info, **i)
  542. else:
  543. log.info('Library %s was not found. Ignoring' % (lib))
  544. if r_dirs:
  545. i = self.check_libs(r_dirs, [lib])
  546. if i is not None:
  547. # Swap library keywords found to runtime_library_dirs
  548. # the libraries are insisting on the user having defined
  549. # them using the library_dirs, and not necessarily by
  550. # runtime_library_dirs
  551. del i['libraries']
  552. i['runtime_library_dirs'] = i.pop('library_dirs')
  553. dict_append(info, **i)
  554. else:
  555. log.info('Runtime library %s was not found. Ignoring' % (lib))
  556. return info
  557. def set_info(self, **info):
  558. if info:
  559. lib_info = self.calc_libraries_info()
  560. dict_append(info, **lib_info)
  561. # Update extra information
  562. extra_info = self.calc_extra_info()
  563. dict_append(info, **extra_info)
  564. self.saved_results[self.__class__.__name__] = info
  565. def get_option_single(self, *options):
  566. """ Ensure that only one of `options` are found in the section
  567. Parameters
  568. ----------
  569. *options : list of str
  570. a list of options to be found in the section (``self.section``)
  571. Returns
  572. -------
  573. str :
  574. the option that is uniquely found in the section
  575. Raises
  576. ------
  577. AliasedOptionError :
  578. in case more than one of the options are found
  579. """
  580. found = map(lambda opt: self.cp.has_option(self.section, opt), options)
  581. found = list(found)
  582. if sum(found) == 1:
  583. return options[found.index(True)]
  584. elif sum(found) == 0:
  585. # nothing is found anyways
  586. return options[0]
  587. # Else we have more than 1 key found
  588. if AliasedOptionError.__doc__ is None:
  589. raise AliasedOptionError()
  590. raise AliasedOptionError(AliasedOptionError.__doc__.format(
  591. section=self.section, options='[{}]'.format(', '.join(options))))
  592. def has_info(self):
  593. return self.__class__.__name__ in self.saved_results
  594. def calc_extra_info(self):
  595. """ Updates the information in the current information with
  596. respect to these flags:
  597. extra_compile_args
  598. extra_link_args
  599. """
  600. info = {}
  601. for key in ['extra_compile_args', 'extra_link_args']:
  602. # Get values
  603. opt = self.cp.get(self.section, key)
  604. opt = _shell_utils.NativeParser.split(opt)
  605. if opt:
  606. tmp = {key: opt}
  607. dict_append(info, **tmp)
  608. return info
  609. def get_info(self, notfound_action=0):
  610. """ Return a dictonary with items that are compatible
  611. with numpy.distutils.setup keyword arguments.
  612. """
  613. flag = 0
  614. if not self.has_info():
  615. flag = 1
  616. log.info(self.__class__.__name__ + ':')
  617. if hasattr(self, 'calc_info'):
  618. self.calc_info()
  619. if notfound_action:
  620. if not self.has_info():
  621. if notfound_action == 1:
  622. warnings.warn(self.notfounderror.__doc__, stacklevel=2)
  623. elif notfound_action == 2:
  624. raise self.notfounderror(self.notfounderror.__doc__)
  625. else:
  626. raise ValueError(repr(notfound_action))
  627. if not self.has_info():
  628. log.info(' NOT AVAILABLE')
  629. self.set_info()
  630. else:
  631. log.info(' FOUND:')
  632. res = self.saved_results.get(self.__class__.__name__)
  633. if log.get_threshold() <= log.INFO and flag:
  634. for k, v in res.items():
  635. v = str(v)
  636. if k in ['sources', 'libraries'] and len(v) > 270:
  637. v = v[:120] + '...\n...\n...' + v[-120:]
  638. log.info(' %s = %s', k, v)
  639. log.info('')
  640. return copy.deepcopy(res)
  641. def get_paths(self, section, key):
  642. dirs = self.cp.get(section, key).split(os.pathsep)
  643. env_var = self.dir_env_var
  644. if env_var:
  645. if is_sequence(env_var):
  646. e0 = env_var[-1]
  647. for e in env_var:
  648. if e in os.environ:
  649. e0 = e
  650. break
  651. if not env_var[0] == e0:
  652. log.info('Setting %s=%s' % (env_var[0], e0))
  653. env_var = e0
  654. if env_var and env_var in os.environ:
  655. d = os.environ[env_var]
  656. if d == 'None':
  657. log.info('Disabled %s: %s',
  658. self.__class__.__name__, '(%s is None)'
  659. % (env_var,))
  660. return []
  661. if os.path.isfile(d):
  662. dirs = [os.path.dirname(d)] + dirs
  663. l = getattr(self, '_lib_names', [])
  664. if len(l) == 1:
  665. b = os.path.basename(d)
  666. b = os.path.splitext(b)[0]
  667. if b[:3] == 'lib':
  668. log.info('Replacing _lib_names[0]==%r with %r' \
  669. % (self._lib_names[0], b[3:]))
  670. self._lib_names[0] = b[3:]
  671. else:
  672. ds = d.split(os.pathsep)
  673. ds2 = []
  674. for d in ds:
  675. if os.path.isdir(d):
  676. ds2.append(d)
  677. for dd in ['include', 'lib']:
  678. d1 = os.path.join(d, dd)
  679. if os.path.isdir(d1):
  680. ds2.append(d1)
  681. dirs = ds2 + dirs
  682. default_dirs = self.cp.get(self.section, key).split(os.pathsep)
  683. dirs.extend(default_dirs)
  684. ret = []
  685. for d in dirs:
  686. if len(d) > 0 and not os.path.isdir(d):
  687. warnings.warn('Specified path %s is invalid.' % d, stacklevel=2)
  688. continue
  689. if d not in ret:
  690. ret.append(d)
  691. log.debug('( %s = %s )', key, ':'.join(ret))
  692. return ret
  693. def get_lib_dirs(self, key='library_dirs'):
  694. return self.get_paths(self.section, key)
  695. def get_runtime_lib_dirs(self, key='runtime_library_dirs'):
  696. path = self.get_paths(self.section, key)
  697. if path == ['']:
  698. path = []
  699. return path
  700. def get_include_dirs(self, key='include_dirs'):
  701. return self.get_paths(self.section, key)
  702. def get_src_dirs(self, key='src_dirs'):
  703. return self.get_paths(self.section, key)
  704. def get_libs(self, key, default):
  705. try:
  706. libs = self.cp.get(self.section, key)
  707. except NoOptionError:
  708. if not default:
  709. return []
  710. if is_string(default):
  711. return [default]
  712. return default
  713. return [b for b in [a.strip() for a in libs.split(',')] if b]
  714. def get_libraries(self, key='libraries'):
  715. if hasattr(self, '_lib_names'):
  716. return self.get_libs(key, default=self._lib_names)
  717. else:
  718. return self.get_libs(key, '')
  719. def library_extensions(self):
  720. c = customized_ccompiler()
  721. static_exts = []
  722. if c.compiler_type != 'msvc':
  723. # MSVC doesn't understand binutils
  724. static_exts.append('.a')
  725. if sys.platform == 'win32':
  726. static_exts.append('.lib') # .lib is used by MSVC and others
  727. if self.search_static_first:
  728. exts = static_exts + [so_ext]
  729. else:
  730. exts = [so_ext] + static_exts
  731. if sys.platform == 'cygwin':
  732. exts.append('.dll.a')
  733. if sys.platform == 'darwin':
  734. exts.append('.dylib')
  735. return exts
  736. def check_libs(self, lib_dirs, libs, opt_libs=[]):
  737. """If static or shared libraries are available then return
  738. their info dictionary.
  739. Checks for all libraries as shared libraries first, then
  740. static (or vice versa if self.search_static_first is True).
  741. """
  742. exts = self.library_extensions()
  743. info = None
  744. for ext in exts:
  745. info = self._check_libs(lib_dirs, libs, opt_libs, [ext])
  746. if info is not None:
  747. break
  748. if not info:
  749. log.info(' libraries %s not found in %s', ','.join(libs),
  750. lib_dirs)
  751. return info
  752. def check_libs2(self, lib_dirs, libs, opt_libs=[]):
  753. """If static or shared libraries are available then return
  754. their info dictionary.
  755. Checks each library for shared or static.
  756. """
  757. exts = self.library_extensions()
  758. info = self._check_libs(lib_dirs, libs, opt_libs, exts)
  759. if not info:
  760. log.info(' libraries %s not found in %s', ','.join(libs),
  761. lib_dirs)
  762. return info
  763. def _find_lib(self, lib_dir, lib, exts):
  764. assert is_string(lib_dir)
  765. # under windows first try without 'lib' prefix
  766. if sys.platform == 'win32':
  767. lib_prefixes = ['', 'lib']
  768. else:
  769. lib_prefixes = ['lib']
  770. # for each library name, see if we can find a file for it.
  771. for ext in exts:
  772. for prefix in lib_prefixes:
  773. p = self.combine_paths(lib_dir, prefix + lib + ext)
  774. if p:
  775. break
  776. if p:
  777. assert len(p) == 1
  778. # ??? splitext on p[0] would do this for cygwin
  779. # doesn't seem correct
  780. if ext == '.dll.a':
  781. lib += '.dll'
  782. if ext == '.lib':
  783. lib = prefix + lib
  784. return lib
  785. return False
  786. def _find_libs(self, lib_dirs, libs, exts):
  787. # make sure we preserve the order of libs, as it can be important
  788. found_dirs, found_libs = [], []
  789. for lib in libs:
  790. for lib_dir in lib_dirs:
  791. found_lib = self._find_lib(lib_dir, lib, exts)
  792. if found_lib:
  793. found_libs.append(found_lib)
  794. if lib_dir not in found_dirs:
  795. found_dirs.append(lib_dir)
  796. break
  797. return found_dirs, found_libs
  798. def _check_libs(self, lib_dirs, libs, opt_libs, exts):
  799. """Find mandatory and optional libs in expected paths.
  800. Missing optional libraries are silently forgotten.
  801. """
  802. if not is_sequence(lib_dirs):
  803. lib_dirs = [lib_dirs]
  804. # First, try to find the mandatory libraries
  805. found_dirs, found_libs = self._find_libs(lib_dirs, libs, exts)
  806. if len(found_libs) > 0 and len(found_libs) == len(libs):
  807. # Now, check for optional libraries
  808. opt_found_dirs, opt_found_libs = self._find_libs(lib_dirs, opt_libs, exts)
  809. found_libs.extend(opt_found_libs)
  810. for lib_dir in opt_found_dirs:
  811. if lib_dir not in found_dirs:
  812. found_dirs.append(lib_dir)
  813. info = {'libraries': found_libs, 'library_dirs': found_dirs}
  814. return info
  815. else:
  816. return None
  817. def combine_paths(self, *args):
  818. """Return a list of existing paths composed by all combinations
  819. of items from the arguments.
  820. """
  821. return combine_paths(*args)
  822. class fft_opt_info(system_info):
  823. def calc_info(self):
  824. info = {}
  825. fftw_info = get_info('fftw3') or get_info('fftw2') or get_info('dfftw')
  826. djbfft_info = get_info('djbfft')
  827. if fftw_info:
  828. dict_append(info, **fftw_info)
  829. if djbfft_info:
  830. dict_append(info, **djbfft_info)
  831. self.set_info(**info)
  832. return
  833. class fftw_info(system_info):
  834. #variables to override
  835. section = 'fftw'
  836. dir_env_var = 'FFTW'
  837. notfounderror = FFTWNotFoundError
  838. ver_info = [{'name':'fftw3',
  839. 'libs':['fftw3'],
  840. 'includes':['fftw3.h'],
  841. 'macros':[('SCIPY_FFTW3_H', None)]},
  842. {'name':'fftw2',
  843. 'libs':['rfftw', 'fftw'],
  844. 'includes':['fftw.h', 'rfftw.h'],
  845. 'macros':[('SCIPY_FFTW_H', None)]}]
  846. def calc_ver_info(self, ver_param):
  847. """Returns True on successful version detection, else False"""
  848. lib_dirs = self.get_lib_dirs()
  849. incl_dirs = self.get_include_dirs()
  850. opt = self.get_option_single(self.section + '_libs', 'libraries')
  851. libs = self.get_libs(opt, ver_param['libs'])
  852. info = self.check_libs(lib_dirs, libs)
  853. if info is not None:
  854. flag = 0
  855. for d in incl_dirs:
  856. if len(self.combine_paths(d, ver_param['includes'])) \
  857. == len(ver_param['includes']):
  858. dict_append(info, include_dirs=[d])
  859. flag = 1
  860. break
  861. if flag:
  862. dict_append(info, define_macros=ver_param['macros'])
  863. else:
  864. info = None
  865. if info is not None:
  866. self.set_info(**info)
  867. return True
  868. else:
  869. log.info(' %s not found' % (ver_param['name']))
  870. return False
  871. def calc_info(self):
  872. for i in self.ver_info:
  873. if self.calc_ver_info(i):
  874. break
  875. class fftw2_info(fftw_info):
  876. #variables to override
  877. section = 'fftw'
  878. dir_env_var = 'FFTW'
  879. notfounderror = FFTWNotFoundError
  880. ver_info = [{'name':'fftw2',
  881. 'libs':['rfftw', 'fftw'],
  882. 'includes':['fftw.h', 'rfftw.h'],
  883. 'macros':[('SCIPY_FFTW_H', None)]}
  884. ]
  885. class fftw3_info(fftw_info):
  886. #variables to override
  887. section = 'fftw3'
  888. dir_env_var = 'FFTW3'
  889. notfounderror = FFTWNotFoundError
  890. ver_info = [{'name':'fftw3',
  891. 'libs':['fftw3'],
  892. 'includes':['fftw3.h'],
  893. 'macros':[('SCIPY_FFTW3_H', None)]},
  894. ]
  895. class dfftw_info(fftw_info):
  896. section = 'fftw'
  897. dir_env_var = 'FFTW'
  898. ver_info = [{'name':'dfftw',
  899. 'libs':['drfftw', 'dfftw'],
  900. 'includes':['dfftw.h', 'drfftw.h'],
  901. 'macros':[('SCIPY_DFFTW_H', None)]}]
  902. class sfftw_info(fftw_info):
  903. section = 'fftw'
  904. dir_env_var = 'FFTW'
  905. ver_info = [{'name':'sfftw',
  906. 'libs':['srfftw', 'sfftw'],
  907. 'includes':['sfftw.h', 'srfftw.h'],
  908. 'macros':[('SCIPY_SFFTW_H', None)]}]
  909. class fftw_threads_info(fftw_info):
  910. section = 'fftw'
  911. dir_env_var = 'FFTW'
  912. ver_info = [{'name':'fftw threads',
  913. 'libs':['rfftw_threads', 'fftw_threads'],
  914. 'includes':['fftw_threads.h', 'rfftw_threads.h'],
  915. 'macros':[('SCIPY_FFTW_THREADS_H', None)]}]
  916. class dfftw_threads_info(fftw_info):
  917. section = 'fftw'
  918. dir_env_var = 'FFTW'
  919. ver_info = [{'name':'dfftw threads',
  920. 'libs':['drfftw_threads', 'dfftw_threads'],
  921. 'includes':['dfftw_threads.h', 'drfftw_threads.h'],
  922. 'macros':[('SCIPY_DFFTW_THREADS_H', None)]}]
  923. class sfftw_threads_info(fftw_info):
  924. section = 'fftw'
  925. dir_env_var = 'FFTW'
  926. ver_info = [{'name':'sfftw threads',
  927. 'libs':['srfftw_threads', 'sfftw_threads'],
  928. 'includes':['sfftw_threads.h', 'srfftw_threads.h'],
  929. 'macros':[('SCIPY_SFFTW_THREADS_H', None)]}]
  930. class djbfft_info(system_info):
  931. section = 'djbfft'
  932. dir_env_var = 'DJBFFT'
  933. notfounderror = DJBFFTNotFoundError
  934. def get_paths(self, section, key):
  935. pre_dirs = system_info.get_paths(self, section, key)
  936. dirs = []
  937. for d in pre_dirs:
  938. dirs.extend(self.combine_paths(d, ['djbfft']) + [d])
  939. return [d for d in dirs if os.path.isdir(d)]
  940. def calc_info(self):
  941. lib_dirs = self.get_lib_dirs()
  942. incl_dirs = self.get_include_dirs()
  943. info = None
  944. for d in lib_dirs:
  945. p = self.combine_paths(d, ['djbfft.a'])
  946. if p:
  947. info = {'extra_objects': p}
  948. break
  949. p = self.combine_paths(d, ['libdjbfft.a', 'libdjbfft' + so_ext])
  950. if p:
  951. info = {'libraries': ['djbfft'], 'library_dirs': [d]}
  952. break
  953. if info is None:
  954. return
  955. for d in incl_dirs:
  956. if len(self.combine_paths(d, ['fftc8.h', 'fftfreq.h'])) == 2:
  957. dict_append(info, include_dirs=[d],
  958. define_macros=[('SCIPY_DJBFFT_H', None)])
  959. self.set_info(**info)
  960. return
  961. return
  962. class mkl_info(system_info):
  963. section = 'mkl'
  964. dir_env_var = 'MKLROOT'
  965. _lib_mkl = ['mkl_rt']
  966. def get_mkl_rootdir(self):
  967. mklroot = os.environ.get('MKLROOT', None)
  968. if mklroot is not None:
  969. return mklroot
  970. paths = os.environ.get('LD_LIBRARY_PATH', '').split(os.pathsep)
  971. ld_so_conf = '/etc/ld.so.conf'
  972. if os.path.isfile(ld_so_conf):
  973. with open(ld_so_conf, 'r') as f:
  974. for d in f:
  975. d = d.strip()
  976. if d:
  977. paths.append(d)
  978. intel_mkl_dirs = []
  979. for path in paths:
  980. path_atoms = path.split(os.sep)
  981. for m in path_atoms:
  982. if m.startswith('mkl'):
  983. d = os.sep.join(path_atoms[:path_atoms.index(m) + 2])
  984. intel_mkl_dirs.append(d)
  985. break
  986. for d in paths:
  987. dirs = glob(os.path.join(d, 'mkl', '*'))
  988. dirs += glob(os.path.join(d, 'mkl*'))
  989. for sub_dir in dirs:
  990. if os.path.isdir(os.path.join(sub_dir, 'lib')):
  991. return sub_dir
  992. return None
  993. def __init__(self):
  994. mklroot = self.get_mkl_rootdir()
  995. if mklroot is None:
  996. system_info.__init__(self)
  997. else:
  998. from .cpuinfo import cpu
  999. if cpu.is_Itanium():
  1000. plt = '64'
  1001. elif cpu.is_Intel() and cpu.is_64bit():
  1002. plt = 'intel64'
  1003. else:
  1004. plt = '32'
  1005. system_info.__init__(
  1006. self,
  1007. default_lib_dirs=[os.path.join(mklroot, 'lib', plt)],
  1008. default_include_dirs=[os.path.join(mklroot, 'include')])
  1009. def calc_info(self):
  1010. lib_dirs = self.get_lib_dirs()
  1011. incl_dirs = self.get_include_dirs()
  1012. opt = self.get_option_single('mkl_libs', 'libraries')
  1013. mkl_libs = self.get_libs(opt, self._lib_mkl)
  1014. info = self.check_libs2(lib_dirs, mkl_libs)
  1015. if info is None:
  1016. return
  1017. dict_append(info,
  1018. define_macros=[('SCIPY_MKL_H', None),
  1019. ('HAVE_CBLAS', None)],
  1020. include_dirs=incl_dirs)
  1021. if sys.platform == 'win32':
  1022. pass # win32 has no pthread library
  1023. else:
  1024. dict_append(info, libraries=['pthread'])
  1025. self.set_info(**info)
  1026. class lapack_mkl_info(mkl_info):
  1027. pass
  1028. class blas_mkl_info(mkl_info):
  1029. pass
  1030. class atlas_info(system_info):
  1031. section = 'atlas'
  1032. dir_env_var = 'ATLAS'
  1033. _lib_names = ['f77blas', 'cblas']
  1034. if sys.platform[:7] == 'freebsd':
  1035. _lib_atlas = ['atlas_r']
  1036. _lib_lapack = ['alapack_r']
  1037. else:
  1038. _lib_atlas = ['atlas']
  1039. _lib_lapack = ['lapack']
  1040. notfounderror = AtlasNotFoundError
  1041. def get_paths(self, section, key):
  1042. pre_dirs = system_info.get_paths(self, section, key)
  1043. dirs = []
  1044. for d in pre_dirs:
  1045. dirs.extend(self.combine_paths(d, ['atlas*', 'ATLAS*',
  1046. 'sse', '3dnow', 'sse2']) + [d])
  1047. return [d for d in dirs if os.path.isdir(d)]
  1048. def calc_info(self):
  1049. lib_dirs = self.get_lib_dirs()
  1050. info = {}
  1051. opt = self.get_option_single('atlas_libs', 'libraries')
  1052. atlas_libs = self.get_libs(opt, self._lib_names + self._lib_atlas)
  1053. lapack_libs = self.get_libs('lapack_libs', self._lib_lapack)
  1054. atlas = None
  1055. lapack = None
  1056. atlas_1 = None
  1057. for d in lib_dirs:
  1058. # FIXME: lapack_atlas is unused
  1059. lapack_atlas = self.check_libs2(d, ['lapack_atlas'], [])
  1060. atlas = self.check_libs2(d, atlas_libs, [])
  1061. if atlas is not None:
  1062. lib_dirs2 = [d] + self.combine_paths(d, ['atlas*', 'ATLAS*'])
  1063. lapack = self.check_libs2(lib_dirs2, lapack_libs, [])
  1064. if lapack is not None:
  1065. break
  1066. if atlas:
  1067. atlas_1 = atlas
  1068. log.info(self.__class__)
  1069. if atlas is None:
  1070. atlas = atlas_1
  1071. if atlas is None:
  1072. return
  1073. include_dirs = self.get_include_dirs()
  1074. h = (self.combine_paths(lib_dirs + include_dirs, 'cblas.h') or [None])
  1075. h = h[0]
  1076. if h:
  1077. h = os.path.dirname(h)
  1078. dict_append(info, include_dirs=[h])
  1079. info['language'] = 'c'
  1080. if lapack is not None:
  1081. dict_append(info, **lapack)
  1082. dict_append(info, **atlas)
  1083. elif 'lapack_atlas' in atlas['libraries']:
  1084. dict_append(info, **atlas)
  1085. dict_append(info,
  1086. define_macros=[('ATLAS_WITH_LAPACK_ATLAS', None)])
  1087. self.set_info(**info)
  1088. return
  1089. else:
  1090. dict_append(info, **atlas)
  1091. dict_append(info, define_macros=[('ATLAS_WITHOUT_LAPACK', None)])
  1092. message = textwrap.dedent("""
  1093. *********************************************************************
  1094. Could not find lapack library within the ATLAS installation.
  1095. *********************************************************************
  1096. """)
  1097. warnings.warn(message, stacklevel=2)
  1098. self.set_info(**info)
  1099. return
  1100. # Check if lapack library is complete, only warn if it is not.
  1101. lapack_dir = lapack['library_dirs'][0]
  1102. lapack_name = lapack['libraries'][0]
  1103. lapack_lib = None
  1104. lib_prefixes = ['lib']
  1105. if sys.platform == 'win32':
  1106. lib_prefixes.append('')
  1107. for e in self.library_extensions():
  1108. for prefix in lib_prefixes:
  1109. fn = os.path.join(lapack_dir, prefix + lapack_name + e)
  1110. if os.path.exists(fn):
  1111. lapack_lib = fn
  1112. break
  1113. if lapack_lib:
  1114. break
  1115. if lapack_lib is not None:
  1116. sz = os.stat(lapack_lib)[6]
  1117. if sz <= 4000 * 1024:
  1118. message = textwrap.dedent("""
  1119. *********************************************************************
  1120. Lapack library (from ATLAS) is probably incomplete:
  1121. size of %s is %sk (expected >4000k)
  1122. Follow the instructions in the KNOWN PROBLEMS section of the file
  1123. numpy/INSTALL.txt.
  1124. *********************************************************************
  1125. """) % (lapack_lib, sz / 1024)
  1126. warnings.warn(message, stacklevel=2)
  1127. else:
  1128. info['language'] = 'f77'
  1129. atlas_version, atlas_extra_info = get_atlas_version(**atlas)
  1130. dict_append(info, **atlas_extra_info)
  1131. self.set_info(**info)
  1132. class atlas_blas_info(atlas_info):
  1133. _lib_names = ['f77blas', 'cblas']
  1134. def calc_info(self):
  1135. lib_dirs = self.get_lib_dirs()
  1136. info = {}
  1137. opt = self.get_option_single('atlas_libs', 'libraries')
  1138. atlas_libs = self.get_libs(opt, self._lib_names + self._lib_atlas)
  1139. atlas = self.check_libs2(lib_dirs, atlas_libs, [])
  1140. if atlas is None:
  1141. return
  1142. include_dirs = self.get_include_dirs()
  1143. h = (self.combine_paths(lib_dirs + include_dirs, 'cblas.h') or [None])
  1144. h = h[0]
  1145. if h:
  1146. h = os.path.dirname(h)
  1147. dict_append(info, include_dirs=[h])
  1148. info['language'] = 'c'
  1149. info['define_macros'] = [('HAVE_CBLAS', None)]
  1150. atlas_version, atlas_extra_info = get_atlas_version(**atlas)
  1151. dict_append(atlas, **atlas_extra_info)
  1152. dict_append(info, **atlas)
  1153. self.set_info(**info)
  1154. return
  1155. class atlas_threads_info(atlas_info):
  1156. dir_env_var = ['PTATLAS', 'ATLAS']
  1157. _lib_names = ['ptf77blas', 'ptcblas']
  1158. class atlas_blas_threads_info(atlas_blas_info):
  1159. dir_env_var = ['PTATLAS', 'ATLAS']
  1160. _lib_names = ['ptf77blas', 'ptcblas']
  1161. class lapack_atlas_info(atlas_info):
  1162. _lib_names = ['lapack_atlas'] + atlas_info._lib_names
  1163. class lapack_atlas_threads_info(atlas_threads_info):
  1164. _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names
  1165. class atlas_3_10_info(atlas_info):
  1166. _lib_names = ['satlas']
  1167. _lib_atlas = _lib_names
  1168. _lib_lapack = _lib_names
  1169. class atlas_3_10_blas_info(atlas_3_10_info):
  1170. _lib_names = ['satlas']
  1171. def calc_info(self):
  1172. lib_dirs = self.get_lib_dirs()
  1173. info = {}
  1174. opt = self.get_option_single('atlas_lib', 'libraries')
  1175. atlas_libs = self.get_libs(opt, self._lib_names)
  1176. atlas = self.check_libs2(lib_dirs, atlas_libs, [])
  1177. if atlas is None:
  1178. return
  1179. include_dirs = self.get_include_dirs()
  1180. h = (self.combine_paths(lib_dirs + include_dirs, 'cblas.h') or [None])
  1181. h = h[0]
  1182. if h:
  1183. h = os.path.dirname(h)
  1184. dict_append(info, include_dirs=[h])
  1185. info['language'] = 'c'
  1186. info['define_macros'] = [('HAVE_CBLAS', None)]
  1187. atlas_version, atlas_extra_info = get_atlas_version(**atlas)
  1188. dict_append(atlas, **atlas_extra_info)
  1189. dict_append(info, **atlas)
  1190. self.set_info(**info)
  1191. return
  1192. class atlas_3_10_threads_info(atlas_3_10_info):
  1193. dir_env_var = ['PTATLAS', 'ATLAS']
  1194. _lib_names = ['tatlas']
  1195. _lib_atlas = _lib_names
  1196. _lib_lapack = _lib_names
  1197. class atlas_3_10_blas_threads_info(atlas_3_10_blas_info):
  1198. dir_env_var = ['PTATLAS', 'ATLAS']
  1199. _lib_names = ['tatlas']
  1200. class lapack_atlas_3_10_info(atlas_3_10_info):
  1201. pass
  1202. class lapack_atlas_3_10_threads_info(atlas_3_10_threads_info):
  1203. pass
  1204. class lapack_info(system_info):
  1205. section = 'lapack'
  1206. dir_env_var = 'LAPACK'
  1207. _lib_names = ['lapack']
  1208. notfounderror = LapackNotFoundError
  1209. def calc_info(self):
  1210. lib_dirs = self.get_lib_dirs()
  1211. opt = self.get_option_single('lapack_libs', 'libraries')
  1212. lapack_libs = self.get_libs(opt, self._lib_names)
  1213. info = self.check_libs(lib_dirs, lapack_libs, [])
  1214. if info is None:
  1215. return
  1216. info['language'] = 'f77'
  1217. self.set_info(**info)
  1218. class lapack_src_info(system_info):
  1219. section = 'lapack_src'
  1220. dir_env_var = 'LAPACK_SRC'
  1221. notfounderror = LapackSrcNotFoundError
  1222. def get_paths(self, section, key):
  1223. pre_dirs = system_info.get_paths(self, section, key)
  1224. dirs = []
  1225. for d in pre_dirs:
  1226. dirs.extend([d] + self.combine_paths(d, ['LAPACK*/SRC', 'SRC']))
  1227. return [d for d in dirs if os.path.isdir(d)]
  1228. def calc_info(self):
  1229. src_dirs = self.get_src_dirs()
  1230. src_dir = ''
  1231. for d in src_dirs:
  1232. if os.path.isfile(os.path.join(d, 'dgesv.f')):
  1233. src_dir = d
  1234. break
  1235. if not src_dir:
  1236. #XXX: Get sources from netlib. May be ask first.
  1237. return
  1238. # The following is extracted from LAPACK-3.0/SRC/Makefile.
  1239. # Added missing names from lapack-lite-3.1.1/SRC/Makefile
  1240. # while keeping removed names for Lapack-3.0 compatibility.
  1241. allaux = '''
  1242. ilaenv ieeeck lsame lsamen xerbla
  1243. iparmq
  1244. ''' # *.f
  1245. laux = '''
  1246. bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1
  1247. laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2
  1248. lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre
  1249. larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4
  1250. lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1
  1251. lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf
  1252. stebz stedc steqr sterf
  1253. larra larrc larrd larr larrk larrj larrr laneg laisnan isnan
  1254. lazq3 lazq4
  1255. ''' # [s|d]*.f
  1256. lasrc = '''
  1257. gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak
  1258. gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv
  1259. gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2
  1260. geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd
  1261. gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal
  1262. gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd
  1263. ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein
  1264. hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0
  1265. lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb
  1266. lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp
  1267. laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv
  1268. lartv larz larzb larzt laswp lasyf latbs latdf latps latrd
  1269. latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv
  1270. pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2
  1271. potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri
  1272. pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs
  1273. spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv
  1274. sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2
  1275. tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs
  1276. trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs
  1277. tzrqf tzrzf
  1278. lacn2 lahr2 stemr laqr0 laqr1 laqr2 laqr3 laqr4 laqr5
  1279. ''' # [s|c|d|z]*.f
  1280. sd_lasrc = '''
  1281. laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l
  1282. org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr
  1283. orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3
  1284. ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx
  1285. sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd
  1286. stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd
  1287. sygvx sytd2 sytrd
  1288. ''' # [s|d]*.f
  1289. cz_lasrc = '''
  1290. bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev
  1291. heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv
  1292. hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd
  1293. hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf
  1294. hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7
  1295. laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe
  1296. laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv
  1297. spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq
  1298. ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2
  1299. unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr
  1300. ''' # [c|z]*.f
  1301. #######
  1302. sclaux = laux + ' econd ' # s*.f
  1303. dzlaux = laux + ' secnd ' # d*.f
  1304. slasrc = lasrc + sd_lasrc # s*.f
  1305. dlasrc = lasrc + sd_lasrc # d*.f
  1306. clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f
  1307. zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f
  1308. oclasrc = ' icmax1 scsum1 ' # *.f
  1309. ozlasrc = ' izmax1 dzsum1 ' # *.f
  1310. sources = ['s%s.f' % f for f in (sclaux + slasrc).split()] \
  1311. + ['d%s.f' % f for f in (dzlaux + dlasrc).split()] \
  1312. + ['c%s.f' % f for f in (clasrc).split()] \
  1313. + ['z%s.f' % f for f in (zlasrc).split()] \
  1314. + ['%s.f' % f for f in (allaux + oclasrc + ozlasrc).split()]
  1315. sources = [os.path.join(src_dir, f) for f in sources]
  1316. # Lapack 3.1:
  1317. src_dir2 = os.path.join(src_dir, '..', 'INSTALL')
  1318. sources += [os.path.join(src_dir2, p + 'lamch.f') for p in 'sdcz']
  1319. # Lapack 3.2.1:
  1320. sources += [os.path.join(src_dir, p + 'larfp.f') for p in 'sdcz']
  1321. sources += [os.path.join(src_dir, 'ila' + p + 'lr.f') for p in 'sdcz']
  1322. sources += [os.path.join(src_dir, 'ila' + p + 'lc.f') for p in 'sdcz']
  1323. # Should we check here actual existence of source files?
  1324. # Yes, the file listing is different between 3.0 and 3.1
  1325. # versions.
  1326. sources = [f for f in sources if os.path.isfile(f)]
  1327. info = {'sources': sources, 'language': 'f77'}
  1328. self.set_info(**info)
  1329. atlas_version_c_text = r'''
  1330. /* This file is generated from numpy/distutils/system_info.py */
  1331. void ATL_buildinfo(void);
  1332. int main(void) {
  1333. ATL_buildinfo();
  1334. return 0;
  1335. }
  1336. '''
  1337. _cached_atlas_version = {}
  1338. def get_atlas_version(**config):
  1339. libraries = config.get('libraries', [])
  1340. library_dirs = config.get('library_dirs', [])
  1341. key = (tuple(libraries), tuple(library_dirs))
  1342. if key in _cached_atlas_version:
  1343. return _cached_atlas_version[key]
  1344. c = cmd_config(Distribution())
  1345. atlas_version = None
  1346. info = {}
  1347. try:
  1348. s, o = c.get_output(atlas_version_c_text,
  1349. libraries=libraries, library_dirs=library_dirs,
  1350. )
  1351. if s and re.search(r'undefined reference to `_gfortran', o, re.M):
  1352. s, o = c.get_output(atlas_version_c_text,
  1353. libraries=libraries + ['gfortran'],
  1354. library_dirs=library_dirs,
  1355. )
  1356. if not s:
  1357. warnings.warn(textwrap.dedent("""
  1358. *****************************************************
  1359. Linkage with ATLAS requires gfortran. Use
  1360. python setup.py config_fc --fcompiler=gnu95 ...
  1361. when building extension libraries that use ATLAS.
  1362. Make sure that -lgfortran is used for C++ extensions.
  1363. *****************************************************
  1364. """), stacklevel=2)
  1365. dict_append(info, language='f90',
  1366. define_macros=[('ATLAS_REQUIRES_GFORTRAN', None)])
  1367. except Exception: # failed to get version from file -- maybe on Windows
  1368. # look at directory name
  1369. for o in library_dirs:
  1370. m = re.search(r'ATLAS_(?P<version>\d+[.]\d+[.]\d+)_', o)
  1371. if m:
  1372. atlas_version = m.group('version')
  1373. if atlas_version is not None:
  1374. break
  1375. # final choice --- look at ATLAS_VERSION environment
  1376. # variable
  1377. if atlas_version is None:
  1378. atlas_version = os.environ.get('ATLAS_VERSION', None)
  1379. if atlas_version:
  1380. dict_append(info, define_macros=[(
  1381. 'ATLAS_INFO', _c_string_literal(atlas_version))
  1382. ])
  1383. else:
  1384. dict_append(info, define_macros=[('NO_ATLAS_INFO', -1)])
  1385. return atlas_version or '?.?.?', info
  1386. if not s:
  1387. m = re.search(r'ATLAS version (?P<version>\d+[.]\d+[.]\d+)', o)
  1388. if m:
  1389. atlas_version = m.group('version')
  1390. if atlas_version is None:
  1391. if re.search(r'undefined symbol: ATL_buildinfo', o, re.M):
  1392. atlas_version = '3.2.1_pre3.3.6'
  1393. else:
  1394. log.info('Status: %d', s)
  1395. log.info('Output: %s', o)
  1396. elif atlas_version == '3.2.1_pre3.3.6':
  1397. dict_append(info, define_macros=[('NO_ATLAS_INFO', -2)])
  1398. else:
  1399. dict_append(info, define_macros=[(
  1400. 'ATLAS_INFO', _c_string_literal(atlas_version))
  1401. ])
  1402. result = _cached_atlas_version[key] = atlas_version, info
  1403. return result
  1404. class lapack_opt_info(system_info):
  1405. notfounderror = LapackNotFoundError
  1406. # List of all known BLAS libraries, in the default order
  1407. lapack_order = ['mkl', 'openblas', 'flame', 'atlas', 'accelerate', 'lapack']
  1408. order_env_var_name = 'NPY_LAPACK_ORDER'
  1409. def _calc_info_mkl(self):
  1410. info = get_info('lapack_mkl')
  1411. if info:
  1412. self.set_info(**info)
  1413. return True
  1414. return False
  1415. def _calc_info_openblas(self):
  1416. info = get_info('openblas_lapack')
  1417. if info:
  1418. self.set_info(**info)
  1419. return True
  1420. info = get_info('openblas_clapack')
  1421. if info:
  1422. self.set_info(**info)
  1423. return True
  1424. return False
  1425. def _calc_info_flame(self):
  1426. info = get_info('flame')
  1427. if info:
  1428. self.set_info(**info)
  1429. return True
  1430. return False
  1431. def _calc_info_atlas(self):
  1432. info = get_info('atlas_3_10_threads')
  1433. if not info:
  1434. info = get_info('atlas_3_10')
  1435. if not info:
  1436. info = get_info('atlas_threads')
  1437. if not info:
  1438. info = get_info('atlas')
  1439. if info:
  1440. # Figure out if ATLAS has lapack...
  1441. # If not we need the lapack library, but not BLAS!
  1442. l = info.get('define_macros', [])
  1443. if ('ATLAS_WITH_LAPACK_ATLAS', None) in l \
  1444. or ('ATLAS_WITHOUT_LAPACK', None) in l:
  1445. # Get LAPACK (with possible warnings)
  1446. # If not found we don't accept anything
  1447. # since we can't use ATLAS with LAPACK!
  1448. lapack_info = self._get_info_lapack()
  1449. if not lapack_info:
  1450. return False
  1451. dict_append(info, **lapack_info)
  1452. self.set_info(**info)
  1453. return True
  1454. return False
  1455. def _calc_info_accelerate(self):
  1456. info = get_info('accelerate')
  1457. if info:
  1458. self.set_info(**info)
  1459. return True
  1460. return False
  1461. def _get_info_blas(self):
  1462. # Default to get the optimized BLAS implementation
  1463. info = get_info('blas_opt')
  1464. if not info:
  1465. warnings.warn(BlasNotFoundError.__doc__ or '', stacklevel=3)
  1466. info_src = get_info('blas_src')
  1467. if not info_src:
  1468. warnings.warn(BlasSrcNotFoundError.__doc__ or '', stacklevel=3)
  1469. return {}
  1470. dict_append(info, libraries=[('fblas_src', info_src)])
  1471. return info
  1472. def _get_info_lapack(self):
  1473. info = get_info('lapack')
  1474. if not info:
  1475. warnings.warn(LapackNotFoundError.__doc__ or '', stacklevel=3)
  1476. info_src = get_info('lapack_src')
  1477. if not info_src:
  1478. warnings.warn(LapackSrcNotFoundError.__doc__ or '', stacklevel=3)
  1479. return {}
  1480. dict_append(info, libraries=[('flapack_src', info_src)])
  1481. return info
  1482. def _calc_info_lapack(self):
  1483. info = self._get_info_lapack()
  1484. if info:
  1485. info_blas = self._get_info_blas()
  1486. dict_append(info, **info_blas)
  1487. dict_append(info, define_macros=[('NO_ATLAS_INFO', 1)])
  1488. self.set_info(**info)
  1489. return True
  1490. return False
  1491. def _calc_info(self, name):
  1492. return getattr(self, '_calc_info_{}'.format(name))()
  1493. def calc_info(self):
  1494. user_order = os.environ.get(self.order_env_var_name, None)
  1495. if user_order is None:
  1496. lapack_order = self.lapack_order
  1497. else:
  1498. # the user has requested the order of the
  1499. # check they are all in the available list, a COMMA SEPARATED list
  1500. user_order = user_order.lower().split(',')
  1501. non_existing = []
  1502. lapack_order = []
  1503. for order in user_order:
  1504. if order in self.lapack_order:
  1505. lapack_order.append(order)
  1506. elif len(order) > 0:
  1507. non_existing.append(order)
  1508. if len(non_existing) > 0:
  1509. raise ValueError("lapack_opt_info user defined "
  1510. "LAPACK order has unacceptable "
  1511. "values: {}".format(non_existing))
  1512. for lapack in lapack_order:
  1513. if self._calc_info(lapack):
  1514. return
  1515. if 'lapack' not in lapack_order:
  1516. # Since the user may request *not* to use any library, we still need
  1517. # to raise warnings to signal missing packages!
  1518. warnings.warn(LapackNotFoundError.__doc__ or '', stacklevel=2)
  1519. warnings.warn(LapackSrcNotFoundError.__doc__ or '', stacklevel=2)
  1520. class _ilp64_opt_info_mixin:
  1521. symbol_suffix = None
  1522. symbol_prefix = None
  1523. def _check_info(self, info):
  1524. macros = dict(info.get('define_macros', []))
  1525. prefix = macros.get('BLAS_SYMBOL_PREFIX', '')
  1526. suffix = macros.get('BLAS_SYMBOL_SUFFIX', '')
  1527. if self.symbol_prefix not in (None, prefix):
  1528. return False
  1529. if self.symbol_suffix not in (None, suffix):
  1530. return False
  1531. return bool(info)
  1532. class lapack_ilp64_opt_info(lapack_opt_info, _ilp64_opt_info_mixin):
  1533. notfounderror = LapackILP64NotFoundError
  1534. lapack_order = ['openblas64_', 'openblas_ilp64']
  1535. order_env_var_name = 'NPY_LAPACK_ILP64_ORDER'
  1536. def _calc_info(self, name):
  1537. info = get_info(name + '_lapack')
  1538. if self._check_info(info):
  1539. self.set_info(**info)
  1540. return True
  1541. return False
  1542. class lapack_ilp64_plain_opt_info(lapack_ilp64_opt_info):
  1543. # Same as lapack_ilp64_opt_info, but fix symbol names
  1544. symbol_prefix = ''
  1545. symbol_suffix = ''
  1546. class lapack64__opt_info(lapack_ilp64_opt_info):
  1547. symbol_prefix = ''
  1548. symbol_suffix = '64_'
  1549. class blas_opt_info(system_info):
  1550. notfounderror = BlasNotFoundError
  1551. # List of all known BLAS libraries, in the default order
  1552. blas_order = ['mkl', 'blis', 'openblas', 'atlas', 'accelerate', 'blas']
  1553. order_env_var_name = 'NPY_BLAS_ORDER'
  1554. def _calc_info_mkl(self):
  1555. info = get_info('blas_mkl')
  1556. if info:
  1557. self.set_info(**info)
  1558. return True
  1559. return False
  1560. def _calc_info_blis(self):
  1561. info = get_info('blis')
  1562. if info:
  1563. self.set_info(**info)
  1564. return True
  1565. return False
  1566. def _calc_info_openblas(self):
  1567. info = get_info('openblas')
  1568. if info:
  1569. self.set_info(**info)
  1570. return True
  1571. return False
  1572. def _calc_info_atlas(self):
  1573. info = get_info('atlas_3_10_blas_threads')
  1574. if not info:
  1575. info = get_info('atlas_3_10_blas')
  1576. if not info:
  1577. info = get_info('atlas_blas_threads')
  1578. if not info:
  1579. info = get_info('atlas_blas')
  1580. if info:
  1581. self.set_info(**info)
  1582. return True
  1583. return False
  1584. def _calc_info_accelerate(self):
  1585. info = get_info('accelerate')
  1586. if info:
  1587. self.set_info(**info)
  1588. return True
  1589. return False
  1590. def _calc_info_blas(self):
  1591. # Warn about a non-optimized BLAS library
  1592. warnings.warn(BlasOptNotFoundError.__doc__ or '', stacklevel=3)
  1593. info = {}
  1594. dict_append(info, define_macros=[('NO_ATLAS_INFO', 1)])
  1595. blas = get_info('blas')
  1596. if blas:
  1597. dict_append(info, **blas)
  1598. else:
  1599. # Not even BLAS was found!
  1600. warnings.warn(BlasNotFoundError.__doc__ or '', stacklevel=3)
  1601. blas_src = get_info('blas_src')
  1602. if not blas_src:
  1603. warnings.warn(BlasSrcNotFoundError.__doc__ or '', stacklevel=3)
  1604. return False
  1605. dict_append(info, libraries=[('fblas_src', blas_src)])
  1606. self.set_info(**info)
  1607. return True
  1608. def _calc_info(self, name):
  1609. return getattr(self, '_calc_info_{}'.format(name))()
  1610. def calc_info(self):
  1611. user_order = os.environ.get(self.order_env_var_name, None)
  1612. if user_order is None:
  1613. blas_order = self.blas_order
  1614. else:
  1615. # the user has requested the order of the
  1616. # check they are all in the available list
  1617. user_order = user_order.lower().split(',')
  1618. non_existing = []
  1619. blas_order = []
  1620. for order in user_order:
  1621. if order in self.blas_order:
  1622. blas_order.append(order)
  1623. elif len(order) > 0:
  1624. non_existing.append(order)
  1625. if len(non_existing) > 0:
  1626. raise ValueError("blas_opt_info user defined BLAS order has unacceptable values: {}".format(non_existing))
  1627. for blas in blas_order:
  1628. if self._calc_info(blas):
  1629. return
  1630. if 'blas' not in blas_order:
  1631. # Since the user may request *not* to use any library, we still need
  1632. # to raise warnings to signal missing packages!
  1633. warnings.warn(BlasNotFoundError.__doc__ or '', stacklevel=2)
  1634. warnings.warn(BlasSrcNotFoundError.__doc__ or '', stacklevel=2)
  1635. class blas_ilp64_opt_info(blas_opt_info, _ilp64_opt_info_mixin):
  1636. notfounderror = BlasILP64NotFoundError
  1637. blas_order = ['openblas64_', 'openblas_ilp64']
  1638. order_env_var_name = 'NPY_BLAS_ILP64_ORDER'
  1639. def _calc_info(self, name):
  1640. info = get_info(name)
  1641. if self._check_info(info):
  1642. self.set_info(**info)
  1643. return True
  1644. return False
  1645. class blas_ilp64_plain_opt_info(blas_ilp64_opt_info):
  1646. symbol_prefix = ''
  1647. symbol_suffix = ''
  1648. class blas64__opt_info(blas_ilp64_opt_info):
  1649. symbol_prefix = ''
  1650. symbol_suffix = '64_'
  1651. class blas_info(system_info):
  1652. section = 'blas'
  1653. dir_env_var = 'BLAS'
  1654. _lib_names = ['blas']
  1655. notfounderror = BlasNotFoundError
  1656. def calc_info(self):
  1657. lib_dirs = self.get_lib_dirs()
  1658. opt = self.get_option_single('blas_libs', 'libraries')
  1659. blas_libs = self.get_libs(opt, self._lib_names)
  1660. info = self.check_libs(lib_dirs, blas_libs, [])
  1661. if info is None:
  1662. return
  1663. else:
  1664. info['include_dirs'] = self.get_include_dirs()
  1665. if platform.system() == 'Windows':
  1666. # The check for windows is needed because get_cblas_libs uses the
  1667. # same compiler that was used to compile Python and msvc is
  1668. # often not installed when mingw is being used. This rough
  1669. # treatment is not desirable, but windows is tricky.
  1670. info['language'] = 'f77' # XXX: is it generally true?
  1671. else:
  1672. lib = self.get_cblas_libs(info)
  1673. if lib is not None:
  1674. info['language'] = 'c'
  1675. info['libraries'] = lib
  1676. info['define_macros'] = [('HAVE_CBLAS', None)]
  1677. self.set_info(**info)
  1678. def get_cblas_libs(self, info):
  1679. """ Check whether we can link with CBLAS interface
  1680. This method will search through several combinations of libraries
  1681. to check whether CBLAS is present:
  1682. 1. Libraries in ``info['libraries']``, as is
  1683. 2. As 1. but also explicitly adding ``'cblas'`` as a library
  1684. 3. As 1. but also explicitly adding ``'blas'`` as a library
  1685. 4. Check only library ``'cblas'``
  1686. 5. Check only library ``'blas'``
  1687. Parameters
  1688. ----------
  1689. info : dict
  1690. system information dictionary for compilation and linking
  1691. Returns
  1692. -------
  1693. libraries : list of str or None
  1694. a list of libraries that enables the use of CBLAS interface.
  1695. Returns None if not found or a compilation error occurs.
  1696. Since 1.17 returns a list.
  1697. """
  1698. # primitive cblas check by looking for the header and trying to link
  1699. # cblas or blas
  1700. c = customized_ccompiler()
  1701. tmpdir = tempfile.mkdtemp()
  1702. s = textwrap.dedent("""\
  1703. #include <cblas.h>
  1704. int main(int argc, const char *argv[])
  1705. {
  1706. double a[4] = {1,2,3,4};
  1707. double b[4] = {5,6,7,8};
  1708. return cblas_ddot(4, a, 1, b, 1) > 10;
  1709. }""")
  1710. src = os.path.join(tmpdir, 'source.c')
  1711. try:
  1712. with open(src, 'wt') as f:
  1713. f.write(s)
  1714. try:
  1715. # check we can compile (find headers)
  1716. obj = c.compile([src], output_dir=tmpdir,
  1717. include_dirs=self.get_include_dirs())
  1718. except (distutils.ccompiler.CompileError, distutils.ccompiler.LinkError):
  1719. return None
  1720. # check we can link (find library)
  1721. # some systems have separate cblas and blas libs.
  1722. for libs in [info['libraries'], ['cblas'] + info['libraries'],
  1723. ['blas'] + info['libraries'], ['cblas'], ['blas']]:
  1724. try:
  1725. c.link_executable(obj, os.path.join(tmpdir, "a.out"),
  1726. libraries=libs,
  1727. library_dirs=info['library_dirs'],
  1728. extra_postargs=info.get('extra_link_args', []))
  1729. return libs
  1730. except distutils.ccompiler.LinkError:
  1731. pass
  1732. finally:
  1733. shutil.rmtree(tmpdir)
  1734. return None
  1735. class openblas_info(blas_info):
  1736. section = 'openblas'
  1737. dir_env_var = 'OPENBLAS'
  1738. _lib_names = ['openblas']
  1739. _require_symbols = []
  1740. notfounderror = BlasNotFoundError
  1741. @property
  1742. def symbol_prefix(self):
  1743. try:
  1744. return self.cp.get(self.section, 'symbol_prefix')
  1745. except NoOptionError:
  1746. return ''
  1747. @property
  1748. def symbol_suffix(self):
  1749. try:
  1750. return self.cp.get(self.section, 'symbol_suffix')
  1751. except NoOptionError:
  1752. return ''
  1753. def _calc_info(self):
  1754. c = customized_ccompiler()
  1755. lib_dirs = self.get_lib_dirs()
  1756. # Prefer to use libraries over openblas_libs
  1757. opt = self.get_option_single('openblas_libs', 'libraries')
  1758. openblas_libs = self.get_libs(opt, self._lib_names)
  1759. info = self.check_libs(lib_dirs, openblas_libs, [])
  1760. if c.compiler_type == "msvc" and info is None:
  1761. from numpy.distutils.fcompiler import new_fcompiler
  1762. f = new_fcompiler(c_compiler=c)
  1763. if f and f.compiler_type == 'gnu95':
  1764. # Try gfortran-compatible library files
  1765. info = self.check_msvc_gfortran_libs(lib_dirs, openblas_libs)
  1766. # Skip lapack check, we'd need build_ext to do it
  1767. skip_symbol_check = True
  1768. elif info:
  1769. skip_symbol_check = False
  1770. info['language'] = 'c'
  1771. if info is None:
  1772. return None
  1773. # Add extra info for OpenBLAS
  1774. extra_info = self.calc_extra_info()
  1775. dict_append(info, **extra_info)
  1776. if not (skip_symbol_check or self.check_symbols(info)):
  1777. return None
  1778. info['define_macros'] = [('HAVE_CBLAS', None)]
  1779. if self.symbol_prefix:
  1780. info['define_macros'] += [('BLAS_SYMBOL_PREFIX', self.symbol_prefix)]
  1781. if self.symbol_suffix:
  1782. info['define_macros'] += [('BLAS_SYMBOL_SUFFIX', self.symbol_suffix)]
  1783. return info
  1784. def calc_info(self):
  1785. info = self._calc_info()
  1786. if info is not None:
  1787. self.set_info(**info)
  1788. def check_msvc_gfortran_libs(self, library_dirs, libraries):
  1789. # First, find the full path to each library directory
  1790. library_paths = []
  1791. for library in libraries:
  1792. for library_dir in library_dirs:
  1793. # MinGW static ext will be .a
  1794. fullpath = os.path.join(library_dir, library + '.a')
  1795. if os.path.isfile(fullpath):
  1796. library_paths.append(fullpath)
  1797. break
  1798. else:
  1799. return None
  1800. # Generate numpy.distutils virtual static library file
  1801. basename = self.__class__.__name__
  1802. tmpdir = os.path.join(os.getcwd(), 'build', basename)
  1803. if not os.path.isdir(tmpdir):
  1804. os.makedirs(tmpdir)
  1805. info = {'library_dirs': [tmpdir],
  1806. 'libraries': [basename],
  1807. 'language': 'f77'}
  1808. fake_lib_file = os.path.join(tmpdir, basename + '.fobjects')
  1809. fake_clib_file = os.path.join(tmpdir, basename + '.cobjects')
  1810. with open(fake_lib_file, 'w') as f:
  1811. f.write("\n".join(library_paths))
  1812. with open(fake_clib_file, 'w') as f:
  1813. pass
  1814. return info
  1815. def check_symbols(self, info):
  1816. res = False
  1817. c = customized_ccompiler()
  1818. tmpdir = tempfile.mkdtemp()
  1819. prototypes = "\n".join("void %s%s%s();" % (self.symbol_prefix,
  1820. symbol_name,
  1821. self.symbol_suffix)
  1822. for symbol_name in self._require_symbols)
  1823. calls = "\n".join("%s%s%s();" % (self.symbol_prefix,
  1824. symbol_name,
  1825. self.symbol_suffix)
  1826. for symbol_name in self._require_symbols)
  1827. s = textwrap.dedent("""\
  1828. %(prototypes)s
  1829. int main(int argc, const char *argv[])
  1830. {
  1831. %(calls)s
  1832. return 0;
  1833. }""") % dict(prototypes=prototypes, calls=calls)
  1834. src = os.path.join(tmpdir, 'source.c')
  1835. out = os.path.join(tmpdir, 'a.out')
  1836. # Add the additional "extra" arguments
  1837. try:
  1838. extra_args = info['extra_link_args']
  1839. except Exception:
  1840. extra_args = []
  1841. if sys.version_info < (3, 5) and sys.version_info > (3, 0) and c.compiler_type == "msvc":
  1842. extra_args.append("/MANIFEST")
  1843. try:
  1844. with open(src, 'wt') as f:
  1845. f.write(s)
  1846. obj = c.compile([src], output_dir=tmpdir)
  1847. try:
  1848. c.link_executable(obj, out, libraries=info['libraries'],
  1849. library_dirs=info['library_dirs'],
  1850. extra_postargs=extra_args)
  1851. res = True
  1852. except distutils.ccompiler.LinkError:
  1853. res = False
  1854. finally:
  1855. shutil.rmtree(tmpdir)
  1856. return res
  1857. class openblas_lapack_info(openblas_info):
  1858. section = 'openblas'
  1859. dir_env_var = 'OPENBLAS'
  1860. _lib_names = ['openblas']
  1861. _require_symbols = ['zungqr_']
  1862. notfounderror = BlasNotFoundError
  1863. class openblas_clapack_info(openblas_lapack_info):
  1864. _lib_names = ['openblas', 'lapack']
  1865. class openblas_ilp64_info(openblas_info):
  1866. section = 'openblas_ilp64'
  1867. dir_env_var = 'OPENBLAS_ILP64'
  1868. _lib_names = ['openblas64']
  1869. _require_symbols = ['dgemm_', 'cblas_dgemm']
  1870. notfounderror = BlasILP64NotFoundError
  1871. def _calc_info(self):
  1872. info = super()._calc_info()
  1873. if info is not None:
  1874. info['define_macros'] += [('HAVE_BLAS_ILP64', None)]
  1875. return info
  1876. class openblas_ilp64_lapack_info(openblas_ilp64_info):
  1877. _require_symbols = ['dgemm_', 'cblas_dgemm', 'zungqr_', 'LAPACKE_zungqr']
  1878. def _calc_info(self):
  1879. info = super()._calc_info()
  1880. if info:
  1881. info['define_macros'] += [('HAVE_LAPACKE', None)]
  1882. return info
  1883. class openblas64__info(openblas_ilp64_info):
  1884. # ILP64 Openblas, with default symbol suffix
  1885. section = 'openblas64_'
  1886. dir_env_var = 'OPENBLAS64_'
  1887. _lib_names = ['openblas64_']
  1888. symbol_suffix = '64_'
  1889. symbol_prefix = ''
  1890. class openblas64__lapack_info(openblas_ilp64_lapack_info, openblas64__info):
  1891. pass
  1892. class blis_info(blas_info):
  1893. section = 'blis'
  1894. dir_env_var = 'BLIS'
  1895. _lib_names = ['blis']
  1896. notfounderror = BlasNotFoundError
  1897. def calc_info(self):
  1898. lib_dirs = self.get_lib_dirs()
  1899. opt = self.get_option_single('blis_libs', 'libraries')
  1900. blis_libs = self.get_libs(opt, self._lib_names)
  1901. info = self.check_libs2(lib_dirs, blis_libs, [])
  1902. if info is None:
  1903. return
  1904. # Add include dirs
  1905. incl_dirs = self.get_include_dirs()
  1906. dict_append(info,
  1907. language='c',
  1908. define_macros=[('HAVE_CBLAS', None)],
  1909. include_dirs=incl_dirs)
  1910. self.set_info(**info)
  1911. class flame_info(system_info):
  1912. """ Usage of libflame for LAPACK operations
  1913. This requires libflame to be compiled with lapack wrappers:
  1914. ./configure --enable-lapack2flame ...
  1915. Be aware that libflame 5.1.0 has some missing names in the shared library, so
  1916. if you have problems, try the static flame library.
  1917. """
  1918. section = 'flame'
  1919. _lib_names = ['flame']
  1920. notfounderror = FlameNotFoundError
  1921. def check_embedded_lapack(self, info):
  1922. """ libflame does not necessarily have a wrapper for fortran LAPACK, we need to check """
  1923. c = customized_ccompiler()
  1924. tmpdir = tempfile.mkdtemp()
  1925. s = textwrap.dedent("""\
  1926. void zungqr_();
  1927. int main(int argc, const char *argv[])
  1928. {
  1929. zungqr_();
  1930. return 0;
  1931. }""")
  1932. src = os.path.join(tmpdir, 'source.c')
  1933. out = os.path.join(tmpdir, 'a.out')
  1934. # Add the additional "extra" arguments
  1935. extra_args = info.get('extra_link_args', [])
  1936. try:
  1937. with open(src, 'wt') as f:
  1938. f.write(s)
  1939. obj = c.compile([src], output_dir=tmpdir)
  1940. try:
  1941. c.link_executable(obj, out, libraries=info['libraries'],
  1942. library_dirs=info['library_dirs'],
  1943. extra_postargs=extra_args)
  1944. return True
  1945. except distutils.ccompiler.LinkError:
  1946. return False
  1947. finally:
  1948. shutil.rmtree(tmpdir)
  1949. def calc_info(self):
  1950. lib_dirs = self.get_lib_dirs()
  1951. flame_libs = self.get_libs('libraries', self._lib_names)
  1952. info = self.check_libs2(lib_dirs, flame_libs, [])
  1953. if info is None:
  1954. return
  1955. if self.check_embedded_lapack(info):
  1956. # check if the user has supplied all information required
  1957. self.set_info(**info)
  1958. else:
  1959. # Try and get the BLAS lib to see if we can get it to work
  1960. blas_info = get_info('blas_opt')
  1961. if not blas_info:
  1962. # since we already failed once, this ain't going to work either
  1963. return
  1964. # Now we need to merge the two dictionaries
  1965. for key in blas_info:
  1966. if isinstance(blas_info[key], list):
  1967. info[key] = info.get(key, []) + blas_info[key]
  1968. elif isinstance(blas_info[key], tuple):
  1969. info[key] = info.get(key, ()) + blas_info[key]
  1970. else:
  1971. info[key] = info.get(key, '') + blas_info[key]
  1972. # Now check again
  1973. if self.check_embedded_lapack(info):
  1974. self.set_info(**info)
  1975. class accelerate_info(system_info):
  1976. section = 'accelerate'
  1977. _lib_names = ['accelerate', 'veclib']
  1978. notfounderror = BlasNotFoundError
  1979. def calc_info(self):
  1980. # Make possible to enable/disable from config file/env var
  1981. libraries = os.environ.get('ACCELERATE')
  1982. if libraries:
  1983. libraries = [libraries]
  1984. else:
  1985. libraries = self.get_libs('libraries', self._lib_names)
  1986. libraries = [lib.strip().lower() for lib in libraries]
  1987. if (sys.platform == 'darwin' and
  1988. not os.getenv('_PYTHON_HOST_PLATFORM', None)):
  1989. # Use the system BLAS from Accelerate or vecLib under OSX
  1990. args = []
  1991. link_args = []
  1992. if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \
  1993. 'x86_64' in get_platform() or \
  1994. 'i386' in platform.platform():
  1995. intel = 1
  1996. else:
  1997. intel = 0
  1998. if (os.path.exists('/System/Library/Frameworks'
  1999. '/Accelerate.framework/') and
  2000. 'accelerate' in libraries):
  2001. if intel:
  2002. args.extend(['-msse3'])
  2003. else:
  2004. args.extend(['-faltivec'])
  2005. args.extend([
  2006. '-I/System/Library/Frameworks/vecLib.framework/Headers'])
  2007. link_args.extend(['-Wl,-framework', '-Wl,Accelerate'])
  2008. elif (os.path.exists('/System/Library/Frameworks'
  2009. '/vecLib.framework/') and
  2010. 'veclib' in libraries):
  2011. if intel:
  2012. args.extend(['-msse3'])
  2013. else:
  2014. args.extend(['-faltivec'])
  2015. args.extend([
  2016. '-I/System/Library/Frameworks/vecLib.framework/Headers'])
  2017. link_args.extend(['-Wl,-framework', '-Wl,vecLib'])
  2018. if args:
  2019. self.set_info(extra_compile_args=args,
  2020. extra_link_args=link_args,
  2021. define_macros=[('NO_ATLAS_INFO', 3),
  2022. ('HAVE_CBLAS', None)])
  2023. return
  2024. class blas_src_info(system_info):
  2025. section = 'blas_src'
  2026. dir_env_var = 'BLAS_SRC'
  2027. notfounderror = BlasSrcNotFoundError
  2028. def get_paths(self, section, key):
  2029. pre_dirs = system_info.get_paths(self, section, key)
  2030. dirs = []
  2031. for d in pre_dirs:
  2032. dirs.extend([d] + self.combine_paths(d, ['blas']))
  2033. return [d for d in dirs if os.path.isdir(d)]
  2034. def calc_info(self):
  2035. src_dirs = self.get_src_dirs()
  2036. src_dir = ''
  2037. for d in src_dirs:
  2038. if os.path.isfile(os.path.join(d, 'daxpy.f')):
  2039. src_dir = d
  2040. break
  2041. if not src_dir:
  2042. #XXX: Get sources from netlib. May be ask first.
  2043. return
  2044. blas1 = '''
  2045. caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot
  2046. dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2
  2047. srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg
  2048. dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax
  2049. snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap
  2050. scabs1
  2051. '''
  2052. blas2 = '''
  2053. cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv
  2054. chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv
  2055. dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv
  2056. sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger
  2057. stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc
  2058. zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2
  2059. ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv
  2060. '''
  2061. blas3 = '''
  2062. cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k
  2063. dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm
  2064. ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm
  2065. '''
  2066. sources = [os.path.join(src_dir, f + '.f') \
  2067. for f in (blas1 + blas2 + blas3).split()]
  2068. #XXX: should we check here actual existence of source files?
  2069. sources = [f for f in sources if os.path.isfile(f)]
  2070. info = {'sources': sources, 'language': 'f77'}
  2071. self.set_info(**info)
  2072. class x11_info(system_info):
  2073. section = 'x11'
  2074. notfounderror = X11NotFoundError
  2075. _lib_names = ['X11']
  2076. def __init__(self):
  2077. system_info.__init__(self,
  2078. default_lib_dirs=default_x11_lib_dirs,
  2079. default_include_dirs=default_x11_include_dirs)
  2080. def calc_info(self):
  2081. if sys.platform in ['win32']:
  2082. return
  2083. lib_dirs = self.get_lib_dirs()
  2084. include_dirs = self.get_include_dirs()
  2085. opt = self.get_option_single('x11_libs', 'libraries')
  2086. x11_libs = self.get_libs(opt, self._lib_names)
  2087. info = self.check_libs(lib_dirs, x11_libs, [])
  2088. if info is None:
  2089. return
  2090. inc_dir = None
  2091. for d in include_dirs:
  2092. if self.combine_paths(d, 'X11/X.h'):
  2093. inc_dir = d
  2094. break
  2095. if inc_dir is not None:
  2096. dict_append(info, include_dirs=[inc_dir])
  2097. self.set_info(**info)
  2098. class _numpy_info(system_info):
  2099. section = 'Numeric'
  2100. modulename = 'Numeric'
  2101. notfounderror = NumericNotFoundError
  2102. def __init__(self):
  2103. include_dirs = []
  2104. try:
  2105. module = __import__(self.modulename)
  2106. prefix = []
  2107. for name in module.__file__.split(os.sep):
  2108. if name == 'lib':
  2109. break
  2110. prefix.append(name)
  2111. # Ask numpy for its own include path before attempting
  2112. # anything else
  2113. try:
  2114. include_dirs.append(getattr(module, 'get_include')())
  2115. except AttributeError:
  2116. pass
  2117. include_dirs.append(distutils.sysconfig.get_python_inc(
  2118. prefix=os.sep.join(prefix)))
  2119. except ImportError:
  2120. pass
  2121. py_incl_dir = distutils.sysconfig.get_python_inc()
  2122. include_dirs.append(py_incl_dir)
  2123. py_pincl_dir = distutils.sysconfig.get_python_inc(plat_specific=True)
  2124. if py_pincl_dir not in include_dirs:
  2125. include_dirs.append(py_pincl_dir)
  2126. for d in default_include_dirs:
  2127. d = os.path.join(d, os.path.basename(py_incl_dir))
  2128. if d not in include_dirs:
  2129. include_dirs.append(d)
  2130. system_info.__init__(self,
  2131. default_lib_dirs=[],
  2132. default_include_dirs=include_dirs)
  2133. def calc_info(self):
  2134. try:
  2135. module = __import__(self.modulename)
  2136. except ImportError:
  2137. return
  2138. info = {}
  2139. macros = []
  2140. for v in ['__version__', 'version']:
  2141. vrs = getattr(module, v, None)
  2142. if vrs is None:
  2143. continue
  2144. macros = [(self.modulename.upper() + '_VERSION',
  2145. _c_string_literal(vrs)),
  2146. (self.modulename.upper(), None)]
  2147. break
  2148. dict_append(info, define_macros=macros)
  2149. include_dirs = self.get_include_dirs()
  2150. inc_dir = None
  2151. for d in include_dirs:
  2152. if self.combine_paths(d,
  2153. os.path.join(self.modulename,
  2154. 'arrayobject.h')):
  2155. inc_dir = d
  2156. break
  2157. if inc_dir is not None:
  2158. dict_append(info, include_dirs=[inc_dir])
  2159. if info:
  2160. self.set_info(**info)
  2161. return
  2162. class numarray_info(_numpy_info):
  2163. section = 'numarray'
  2164. modulename = 'numarray'
  2165. class Numeric_info(_numpy_info):
  2166. section = 'Numeric'
  2167. modulename = 'Numeric'
  2168. class numpy_info(_numpy_info):
  2169. section = 'numpy'
  2170. modulename = 'numpy'
  2171. class numerix_info(system_info):
  2172. section = 'numerix'
  2173. def calc_info(self):
  2174. which = None, None
  2175. if os.getenv("NUMERIX"):
  2176. which = os.getenv("NUMERIX"), "environment var"
  2177. # If all the above fail, default to numpy.
  2178. if which[0] is None:
  2179. which = "numpy", "defaulted"
  2180. try:
  2181. import numpy # noqa: F401
  2182. which = "numpy", "defaulted"
  2183. except ImportError:
  2184. msg1 = str(get_exception())
  2185. try:
  2186. import Numeric # noqa: F401
  2187. which = "numeric", "defaulted"
  2188. except ImportError:
  2189. msg2 = str(get_exception())
  2190. try:
  2191. import numarray # noqa: F401
  2192. which = "numarray", "defaulted"
  2193. except ImportError:
  2194. msg3 = str(get_exception())
  2195. log.info(msg1)
  2196. log.info(msg2)
  2197. log.info(msg3)
  2198. which = which[0].strip().lower(), which[1]
  2199. if which[0] not in ["numeric", "numarray", "numpy"]:
  2200. raise ValueError("numerix selector must be either 'Numeric' "
  2201. "or 'numarray' or 'numpy' but the value obtained"
  2202. " from the %s was '%s'." % (which[1], which[0]))
  2203. os.environ['NUMERIX'] = which[0]
  2204. self.set_info(**get_info(which[0]))
  2205. class f2py_info(system_info):
  2206. def calc_info(self):
  2207. try:
  2208. import numpy.f2py as f2py
  2209. except ImportError:
  2210. return
  2211. f2py_dir = os.path.join(os.path.dirname(f2py.__file__), 'src')
  2212. self.set_info(sources=[os.path.join(f2py_dir, 'fortranobject.c')],
  2213. include_dirs=[f2py_dir])
  2214. return
  2215. class boost_python_info(system_info):
  2216. section = 'boost_python'
  2217. dir_env_var = 'BOOST'
  2218. def get_paths(self, section, key):
  2219. pre_dirs = system_info.get_paths(self, section, key)
  2220. dirs = []
  2221. for d in pre_dirs:
  2222. dirs.extend([d] + self.combine_paths(d, ['boost*']))
  2223. return [d for d in dirs if os.path.isdir(d)]
  2224. def calc_info(self):
  2225. src_dirs = self.get_src_dirs()
  2226. src_dir = ''
  2227. for d in src_dirs:
  2228. if os.path.isfile(os.path.join(d, 'libs', 'python', 'src',
  2229. 'module.cpp')):
  2230. src_dir = d
  2231. break
  2232. if not src_dir:
  2233. return
  2234. py_incl_dirs = [distutils.sysconfig.get_python_inc()]
  2235. py_pincl_dir = distutils.sysconfig.get_python_inc(plat_specific=True)
  2236. if py_pincl_dir not in py_incl_dirs:
  2237. py_incl_dirs.append(py_pincl_dir)
  2238. srcs_dir = os.path.join(src_dir, 'libs', 'python', 'src')
  2239. bpl_srcs = glob(os.path.join(srcs_dir, '*.cpp'))
  2240. bpl_srcs += glob(os.path.join(srcs_dir, '*', '*.cpp'))
  2241. info = {'libraries': [('boost_python_src',
  2242. {'include_dirs': [src_dir] + py_incl_dirs,
  2243. 'sources':bpl_srcs}
  2244. )],
  2245. 'include_dirs': [src_dir],
  2246. }
  2247. if info:
  2248. self.set_info(**info)
  2249. return
  2250. class agg2_info(system_info):
  2251. section = 'agg2'
  2252. dir_env_var = 'AGG2'
  2253. def get_paths(self, section, key):
  2254. pre_dirs = system_info.get_paths(self, section, key)
  2255. dirs = []
  2256. for d in pre_dirs:
  2257. dirs.extend([d] + self.combine_paths(d, ['agg2*']))
  2258. return [d for d in dirs if os.path.isdir(d)]
  2259. def calc_info(self):
  2260. src_dirs = self.get_src_dirs()
  2261. src_dir = ''
  2262. for d in src_dirs:
  2263. if os.path.isfile(os.path.join(d, 'src', 'agg_affine_matrix.cpp')):
  2264. src_dir = d
  2265. break
  2266. if not src_dir:
  2267. return
  2268. if sys.platform == 'win32':
  2269. agg2_srcs = glob(os.path.join(src_dir, 'src', 'platform',
  2270. 'win32', 'agg_win32_bmp.cpp'))
  2271. else:
  2272. agg2_srcs = glob(os.path.join(src_dir, 'src', '*.cpp'))
  2273. agg2_srcs += [os.path.join(src_dir, 'src', 'platform',
  2274. 'X11',
  2275. 'agg_platform_support.cpp')]
  2276. info = {'libraries':
  2277. [('agg2_src',
  2278. {'sources': agg2_srcs,
  2279. 'include_dirs': [os.path.join(src_dir, 'include')],
  2280. }
  2281. )],
  2282. 'include_dirs': [os.path.join(src_dir, 'include')],
  2283. }
  2284. if info:
  2285. self.set_info(**info)
  2286. return
  2287. class _pkg_config_info(system_info):
  2288. section = None
  2289. config_env_var = 'PKG_CONFIG'
  2290. default_config_exe = 'pkg-config'
  2291. append_config_exe = ''
  2292. version_macro_name = None
  2293. release_macro_name = None
  2294. version_flag = '--modversion'
  2295. cflags_flag = '--cflags'
  2296. def get_config_exe(self):
  2297. if self.config_env_var in os.environ:
  2298. return os.environ[self.config_env_var]
  2299. return self.default_config_exe
  2300. def get_config_output(self, config_exe, option):
  2301. cmd = config_exe + ' ' + self.append_config_exe + ' ' + option
  2302. try:
  2303. o = subprocess.check_output(cmd)
  2304. except (OSError, subprocess.CalledProcessError):
  2305. pass
  2306. else:
  2307. o = filepath_from_subprocess_output(o)
  2308. return o
  2309. def calc_info(self):
  2310. config_exe = find_executable(self.get_config_exe())
  2311. if not config_exe:
  2312. log.warn('File not found: %s. Cannot determine %s info.' \
  2313. % (config_exe, self.section))
  2314. return
  2315. info = {}
  2316. macros = []
  2317. libraries = []
  2318. library_dirs = []
  2319. include_dirs = []
  2320. extra_link_args = []
  2321. extra_compile_args = []
  2322. version = self.get_config_output(config_exe, self.version_flag)
  2323. if version:
  2324. macros.append((self.__class__.__name__.split('.')[-1].upper(),
  2325. _c_string_literal(version)))
  2326. if self.version_macro_name:
  2327. macros.append((self.version_macro_name + '_%s'
  2328. % (version.replace('.', '_')), None))
  2329. if self.release_macro_name:
  2330. release = self.get_config_output(config_exe, '--release')
  2331. if release:
  2332. macros.append((self.release_macro_name + '_%s'
  2333. % (release.replace('.', '_')), None))
  2334. opts = self.get_config_output(config_exe, '--libs')
  2335. if opts:
  2336. for opt in opts.split():
  2337. if opt[:2] == '-l':
  2338. libraries.append(opt[2:])
  2339. elif opt[:2] == '-L':
  2340. library_dirs.append(opt[2:])
  2341. else:
  2342. extra_link_args.append(opt)
  2343. opts = self.get_config_output(config_exe, self.cflags_flag)
  2344. if opts:
  2345. for opt in opts.split():
  2346. if opt[:2] == '-I':
  2347. include_dirs.append(opt[2:])
  2348. elif opt[:2] == '-D':
  2349. if '=' in opt:
  2350. n, v = opt[2:].split('=')
  2351. macros.append((n, v))
  2352. else:
  2353. macros.append((opt[2:], None))
  2354. else:
  2355. extra_compile_args.append(opt)
  2356. if macros:
  2357. dict_append(info, define_macros=macros)
  2358. if libraries:
  2359. dict_append(info, libraries=libraries)
  2360. if library_dirs:
  2361. dict_append(info, library_dirs=library_dirs)
  2362. if include_dirs:
  2363. dict_append(info, include_dirs=include_dirs)
  2364. if extra_link_args:
  2365. dict_append(info, extra_link_args=extra_link_args)
  2366. if extra_compile_args:
  2367. dict_append(info, extra_compile_args=extra_compile_args)
  2368. if info:
  2369. self.set_info(**info)
  2370. return
  2371. class wx_info(_pkg_config_info):
  2372. section = 'wx'
  2373. config_env_var = 'WX_CONFIG'
  2374. default_config_exe = 'wx-config'
  2375. append_config_exe = ''
  2376. version_macro_name = 'WX_VERSION'
  2377. release_macro_name = 'WX_RELEASE'
  2378. version_flag = '--version'
  2379. cflags_flag = '--cxxflags'
  2380. class gdk_pixbuf_xlib_2_info(_pkg_config_info):
  2381. section = 'gdk_pixbuf_xlib_2'
  2382. append_config_exe = 'gdk-pixbuf-xlib-2.0'
  2383. version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'
  2384. class gdk_pixbuf_2_info(_pkg_config_info):
  2385. section = 'gdk_pixbuf_2'
  2386. append_config_exe = 'gdk-pixbuf-2.0'
  2387. version_macro_name = 'GDK_PIXBUF_VERSION'
  2388. class gdk_x11_2_info(_pkg_config_info):
  2389. section = 'gdk_x11_2'
  2390. append_config_exe = 'gdk-x11-2.0'
  2391. version_macro_name = 'GDK_X11_VERSION'
  2392. class gdk_2_info(_pkg_config_info):
  2393. section = 'gdk_2'
  2394. append_config_exe = 'gdk-2.0'
  2395. version_macro_name = 'GDK_VERSION'
  2396. class gdk_info(_pkg_config_info):
  2397. section = 'gdk'
  2398. append_config_exe = 'gdk'
  2399. version_macro_name = 'GDK_VERSION'
  2400. class gtkp_x11_2_info(_pkg_config_info):
  2401. section = 'gtkp_x11_2'
  2402. append_config_exe = 'gtk+-x11-2.0'
  2403. version_macro_name = 'GTK_X11_VERSION'
  2404. class gtkp_2_info(_pkg_config_info):
  2405. section = 'gtkp_2'
  2406. append_config_exe = 'gtk+-2.0'
  2407. version_macro_name = 'GTK_VERSION'
  2408. class xft_info(_pkg_config_info):
  2409. section = 'xft'
  2410. append_config_exe = 'xft'
  2411. version_macro_name = 'XFT_VERSION'
  2412. class freetype2_info(_pkg_config_info):
  2413. section = 'freetype2'
  2414. append_config_exe = 'freetype2'
  2415. version_macro_name = 'FREETYPE2_VERSION'
  2416. class amd_info(system_info):
  2417. section = 'amd'
  2418. dir_env_var = 'AMD'
  2419. _lib_names = ['amd']
  2420. def calc_info(self):
  2421. lib_dirs = self.get_lib_dirs()
  2422. opt = self.get_option_single('amd_libs', 'libraries')
  2423. amd_libs = self.get_libs(opt, self._lib_names)
  2424. info = self.check_libs(lib_dirs, amd_libs, [])
  2425. if info is None:
  2426. return
  2427. include_dirs = self.get_include_dirs()
  2428. inc_dir = None
  2429. for d in include_dirs:
  2430. p = self.combine_paths(d, 'amd.h')
  2431. if p:
  2432. inc_dir = os.path.dirname(p[0])
  2433. break
  2434. if inc_dir is not None:
  2435. dict_append(info, include_dirs=[inc_dir],
  2436. define_macros=[('SCIPY_AMD_H', None)],
  2437. swig_opts=['-I' + inc_dir])
  2438. self.set_info(**info)
  2439. return
  2440. class umfpack_info(system_info):
  2441. section = 'umfpack'
  2442. dir_env_var = 'UMFPACK'
  2443. notfounderror = UmfpackNotFoundError
  2444. _lib_names = ['umfpack']
  2445. def calc_info(self):
  2446. lib_dirs = self.get_lib_dirs()
  2447. opt = self.get_option_single('umfpack_libs', 'libraries')
  2448. umfpack_libs = self.get_libs(opt, self._lib_names)
  2449. info = self.check_libs(lib_dirs, umfpack_libs, [])
  2450. if info is None:
  2451. return
  2452. include_dirs = self.get_include_dirs()
  2453. inc_dir = None
  2454. for d in include_dirs:
  2455. p = self.combine_paths(d, ['', 'umfpack'], 'umfpack.h')
  2456. if p:
  2457. inc_dir = os.path.dirname(p[0])
  2458. break
  2459. if inc_dir is not None:
  2460. dict_append(info, include_dirs=[inc_dir],
  2461. define_macros=[('SCIPY_UMFPACK_H', None)],
  2462. swig_opts=['-I' + inc_dir])
  2463. dict_append(info, **get_info('amd'))
  2464. self.set_info(**info)
  2465. return
  2466. def combine_paths(*args, **kws):
  2467. """ Return a list of existing paths composed by all combinations of
  2468. items from arguments.
  2469. """
  2470. r = []
  2471. for a in args:
  2472. if not a:
  2473. continue
  2474. if is_string(a):
  2475. a = [a]
  2476. r.append(a)
  2477. args = r
  2478. if not args:
  2479. return []
  2480. if len(args) == 1:
  2481. result = reduce(lambda a, b: a + b, map(glob, args[0]), [])
  2482. elif len(args) == 2:
  2483. result = []
  2484. for a0 in args[0]:
  2485. for a1 in args[1]:
  2486. result.extend(glob(os.path.join(a0, a1)))
  2487. else:
  2488. result = combine_paths(*(combine_paths(args[0], args[1]) + args[2:]))
  2489. log.debug('(paths: %s)', ','.join(result))
  2490. return result
  2491. language_map = {'c': 0, 'c++': 1, 'f77': 2, 'f90': 3}
  2492. inv_language_map = {0: 'c', 1: 'c++', 2: 'f77', 3: 'f90'}
  2493. def dict_append(d, **kws):
  2494. languages = []
  2495. for k, v in kws.items():
  2496. if k == 'language':
  2497. languages.append(v)
  2498. continue
  2499. if k in d:
  2500. if k in ['library_dirs', 'include_dirs',
  2501. 'extra_compile_args', 'extra_link_args',
  2502. 'runtime_library_dirs', 'define_macros']:
  2503. [d[k].append(vv) for vv in v if vv not in d[k]]
  2504. else:
  2505. d[k].extend(v)
  2506. else:
  2507. d[k] = v
  2508. if languages:
  2509. l = inv_language_map[max([language_map.get(l, 0) for l in languages])]
  2510. d['language'] = l
  2511. return
  2512. def parseCmdLine(argv=(None,)):
  2513. import optparse
  2514. parser = optparse.OptionParser("usage: %prog [-v] [info objs]")
  2515. parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
  2516. default=False,
  2517. help='be verbose and print more messages')
  2518. opts, args = parser.parse_args(args=argv[1:])
  2519. return opts, args
  2520. def show_all(argv=None):
  2521. import inspect
  2522. if argv is None:
  2523. argv = sys.argv
  2524. opts, args = parseCmdLine(argv)
  2525. if opts.verbose:
  2526. log.set_threshold(log.DEBUG)
  2527. else:
  2528. log.set_threshold(log.INFO)
  2529. show_only = []
  2530. for n in args:
  2531. if n[-5:] != '_info':
  2532. n = n + '_info'
  2533. show_only.append(n)
  2534. show_all = not show_only
  2535. _gdict_ = globals().copy()
  2536. for name, c in _gdict_.items():
  2537. if not inspect.isclass(c):
  2538. continue
  2539. if not issubclass(c, system_info) or c is system_info:
  2540. continue
  2541. if not show_all:
  2542. if name not in show_only:
  2543. continue
  2544. del show_only[show_only.index(name)]
  2545. conf = c()
  2546. conf.verbosity = 2
  2547. # FIXME: r not used
  2548. r = conf.get_info()
  2549. if show_only:
  2550. log.info('Info classes not defined: %s', ','.join(show_only))
  2551. if __name__ == "__main__":
  2552. show_all()