sys_info.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. # classes for extracting info from blenders internal classes
  20. def write_sysinfo(filepath):
  21. import sys
  22. import subprocess
  23. import bpy
  24. import bgl
  25. # pretty repr
  26. def prepr(v):
  27. r = repr(v)
  28. vt = type(v)
  29. if vt is bytes:
  30. r = r[2:-1]
  31. elif vt is list or vt is tuple:
  32. r = r[1:-1]
  33. return r
  34. with open(filepath, 'w', encoding="utf-8") as output:
  35. try:
  36. header = "= Blender %s System Information =\n" % bpy.app.version_string
  37. lilies = "%s\n\n" % ((len(header) - 1) * "=")
  38. output.write(lilies[:-1])
  39. output.write(header)
  40. output.write(lilies)
  41. def title(text):
  42. return "\n%s:\n%s" % (text, lilies)
  43. # build info
  44. output.write(title("Blender"))
  45. output.write(
  46. "version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
  47. (bpy.app.version_string,
  48. prepr(bpy.app.build_branch),
  49. prepr(bpy.app.build_commit_date),
  50. prepr(bpy.app.build_commit_time),
  51. prepr(bpy.app.build_hash),
  52. prepr(bpy.app.build_type),
  53. ))
  54. output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
  55. output.write("platform: %s\n" % prepr(bpy.app.build_platform))
  56. output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
  57. output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
  58. output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
  59. output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
  60. output.write("build system: %s\n" % prepr(bpy.app.build_system))
  61. # python info
  62. output.write(title("Python"))
  63. output.write("version: %s\n" % (sys.version))
  64. output.write("paths:\n")
  65. for p in sys.path:
  66. output.write("\t%r\n" % p)
  67. output.write(title("Python (External Binary)"))
  68. output.write("binary path: %s\n" % prepr(bpy.app.binary_path_python))
  69. try:
  70. py_ver = prepr(subprocess.check_output([
  71. bpy.app.binary_path_python,
  72. "--version",
  73. ]).strip())
  74. except Exception as e:
  75. py_ver = str(e)
  76. output.write("version: %s\n" % py_ver)
  77. del py_ver
  78. output.write(title("Directories"))
  79. output.write("scripts:\n")
  80. for p in bpy.utils.script_paths():
  81. output.write("\t%r\n" % p)
  82. output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
  83. output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
  84. output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
  85. output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
  86. output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
  87. output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
  88. output.write("tempdir: %r\n" % (bpy.app.tempdir))
  89. output.write(title("FFmpeg"))
  90. ffmpeg = bpy.app.ffmpeg
  91. if ffmpeg.supported:
  92. for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
  93. output.write(
  94. "%s:%s%r\n" % (lib, " " * (10 - len(lib)),
  95. getattr(ffmpeg, lib + "_version_string")))
  96. else:
  97. output.write("Blender was built without FFmpeg support\n")
  98. if bpy.app.build_options.sdl:
  99. output.write(title("SDL"))
  100. output.write("Version: %s\n" % bpy.app.sdl.version_string)
  101. output.write("Loading method: ")
  102. if bpy.app.build_options.sdl_dynload:
  103. output.write("dynamically loaded by Blender (WITH_SDL_DYNLOAD=ON)\n")
  104. else:
  105. output.write("linked (WITH_SDL_DYNLOAD=OFF)\n")
  106. if not bpy.app.sdl.available:
  107. output.write("WARNING: Blender could not load SDL library\n")
  108. output.write(title("Other Libraries"))
  109. ocio = bpy.app.ocio
  110. output.write("OpenColorIO: ")
  111. if ocio.supported:
  112. if ocio.version_string == "fallback":
  113. output.write("Blender was built with OpenColorIO, " +
  114. "but it currently uses fallback color management.\n")
  115. else:
  116. output.write("%s\n" % (ocio.version_string))
  117. else:
  118. output.write("Blender was built without OpenColorIO support\n")
  119. oiio = bpy.app.oiio
  120. output.write("OpenImageIO: ")
  121. if ocio.supported:
  122. output.write("%s\n" % (oiio.version_string))
  123. else:
  124. output.write("Blender was built without OpenImageIO support\n")
  125. output.write("OpenShadingLanguage: ")
  126. if bpy.app.build_options.cycles:
  127. if bpy.app.build_options.cycles_osl:
  128. from _cycles import osl_version_string
  129. output.write("%s\n" % (osl_version_string))
  130. else:
  131. output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
  132. else:
  133. output.write("Blender was built without Cycles support\n")
  134. opensubdiv = bpy.app.opensubdiv
  135. output.write("OpenSubdiv: ")
  136. if opensubdiv.supported:
  137. output.write("%s\n" % opensubdiv.version_string)
  138. else:
  139. output.write("Blender was built without OpenSubdiv support\n")
  140. openvdb = bpy.app.openvdb
  141. output.write("OpenVDB: ")
  142. if openvdb.supported:
  143. output.write("%s\n" % openvdb.version_string)
  144. else:
  145. output.write("Blender was built without OpenVDB support\n")
  146. alembic = bpy.app.alembic
  147. output.write("Alembic: ")
  148. if alembic.supported:
  149. output.write("%s\n" % alembic.version_string)
  150. else:
  151. output.write("Blender was built without Alembic support\n")
  152. if not bpy.app.build_options.sdl:
  153. output.write("SDL: Blender was built without SDL support\n")
  154. if bpy.app.background:
  155. output.write("\nOpenGL: missing, background mode\n")
  156. else:
  157. output.write(title("OpenGL"))
  158. version = bgl.glGetString(bgl.GL_RENDERER)
  159. output.write("renderer:\t%r\n" % version)
  160. output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
  161. output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
  162. output.write("extensions:\n")
  163. limit = bgl.Buffer(bgl.GL_INT, 1)
  164. bgl.glGetIntegerv(bgl.GL_NUM_EXTENSIONS, limit)
  165. glext = []
  166. for i in range(limit[0]):
  167. glext.append(bgl.glGetStringi(bgl.GL_EXTENSIONS, i))
  168. glext = sorted(glext)
  169. for l in glext:
  170. output.write("\t%s\n" % l)
  171. output.write(title("Implementation Dependent OpenGL Limits"))
  172. bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_VERTICES, limit)
  173. output.write("Maximum DrawElements Vertices:\t%d\n" % limit[0])
  174. bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_INDICES, limit)
  175. output.write("Maximum DrawElements Indices:\t%d\n" % limit[0])
  176. output.write("\nGLSL:\n")
  177. bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
  178. output.write("Maximum Varying Floats:\t%d\n" % limit[0])
  179. bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
  180. output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
  181. bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
  182. output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
  183. bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
  184. output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
  185. bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
  186. output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
  187. bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
  188. output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
  189. bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
  190. output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])
  191. if bpy.app.build_options.cycles:
  192. import cycles
  193. output.write(title("Cycles"))
  194. output.write(cycles.engine.system_info())
  195. import addon_utils
  196. addon_utils.modules()
  197. output.write(title("Enabled add-ons"))
  198. for addon in bpy.context.preferences.addons.keys():
  199. addon_mod = addon_utils.addons_fake_modules.get(addon, None)
  200. if addon_mod is None:
  201. output.write("%s (MISSING)\n" % (addon))
  202. else:
  203. output.write("%s (version: %s, path: %s)\n" %
  204. (addon, addon_mod.bl_info.get('version', "UNKNOWN"), addon_mod.__file__))
  205. except Exception as e:
  206. output.write("ERROR: %s\n" % e)