Extend system-info with information about OIIO, OCIO and OSL

Summary:
Version of those libraries might be useful to know.

- OIIO and OCIO is exposed via bpy.app.oiio and bpy.app.ocio.
  There're "supported", "version" and "version_string" defined
  in those modules.

- OSL is available as _cycles.osl_version and _cycles.osl_version_string.

Reviewers: campbellbarton

Reviewed By: campbellbarton

CC: dingto

Differential Revision: http://developer.blender.org/D79
This commit is contained in:
Sergey Sharybin 2013-12-08 15:03:17 +06:00
parent 55416f435a
commit 46f8dba4c7
16 changed files with 401 additions and 1 deletions

@ -475,11 +475,25 @@ void *CCL_python_module_init()
PyObject *mod = PyModule_Create(&ccl::module);
#ifdef WITH_OSL
/* TODO(sergey): This gives us library we've been linking against.
* In theory with dynamic OSL library it might not be
* accurate, but there's nothing in OSL API which we
* might use th get version in runtime.
*/
int curversion = OSL_LIBRARY_VERSION_CODE;
PyModule_AddObject(mod, "with_osl", Py_True);
Py_INCREF(Py_True);
PyModule_AddObject(mod, "osl_version",
Py_BuildValue("(iii)",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
PyModule_AddObject(mod, "osl_version_string",
PyUnicode_FromFormat("%2d, %2d, %2d",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
PyModule_AddObject(mod, "with_osl", Py_False);
Py_INCREF(Py_False);
PyModule_AddStringCOnstant(mod, "osl_version", "unknown");
PyModule_AddStringCOnstant(mod, "osl_version_string", "unknown");
#endif
#ifdef WITH_NETWORK

@ -431,3 +431,13 @@ void FallbackImpl::finishGLSLDraw(OCIO_GLSLDrawState * /*state*/)
void FallbackImpl::freeGLState(struct OCIO_GLSLDrawState * /*state_r*/)
{
}
const char *FallbackImpl::getVersionString(void)
{
return "fallback";
}
int FallbackImpl::getVersionHex(void)
{
return 0;
}

@ -338,3 +338,13 @@ void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state)
{
impl->freeGLState(state);
}
const char *OCIO_getVersionString(void)
{
return impl->getVersionString();
}
int OCIO_getVersionHex(void)
{
return impl->getVersionHex();
}

@ -193,6 +193,9 @@ int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorR
void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state);
void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state);
const char *OCIO_getVersionString(void);
int OCIO_getVersionHex(void);
#ifdef __cplusplus
}
#endif

@ -609,3 +609,13 @@ void OCIOImpl::matrixTransformScale(float *m44, float *offset4, const float *sca
{
MatrixTransform::Scale(m44, offset4, scale4f);
}
const char *OCIOImpl::getVersionString(void)
{
return GetVersion();
}
int OCIOImpl::getVersionHex(void)
{
return GetVersionHex();
}

@ -110,6 +110,9 @@ public:
OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide) = 0;
virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
virtual const char *getVersionString(void) = 0;
virtual int getVersionHex(void) = 0;
};
class FallbackImpl : public IOCIOImpl {
@ -194,6 +197,9 @@ public:
OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide);
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
void freeGLState(struct OCIO_GLSLDrawState *state_r);
const char *getVersionString(void);
int getVersionHex(void);
};
#ifdef WITH_OCIO
@ -279,6 +285,9 @@ public:
OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide);
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
void freeGLState(struct OCIO_GLSLDrawState *state_r);
const char *getVersionString(void);
int getVersionHex(void);
};
#endif

@ -118,6 +118,36 @@ def write_sysinfo(op):
else:
output.write("Blender was built without FFmpeg support\n")
output.write("\nOther Libraries:\n")
output.write(lilies)
ocio = bpy.app.ocio
output.write("OpenColorIO: ")
if ocio.supported:
if ocio.version_string == "fallback":
output.write("Blender was built with OpenColorIO, " +
"but it currently uses fallback color management.\n")
else:
output.write("%s\n" % (ocio.version_string))
else:
output.write("Blender was built without OpenColorIO support\n")
oiio = bpy.app.oiio
output.write("OpenImageIO: ")
if ocio.supported :
output.write("%s\n" % (oiio.version_string))
else:
output.write("Blender was built without OpenImageIO support\n")
output.write("OpenShadingLanguuage: ")
if bpy.app.build_options.cycles:
if bpy.app.build_options.cycles_osl:
from _cycles import osl_version_string
output.write("%s\n" % (osl_version_string))
else:
output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
else:
output.write("Blender was built without Cycles support\n")
if bpy.app.background:
output.write("\nOpenGL: missing, background mode\n")
else:

@ -275,6 +275,11 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
}
}
int OIIO_getVersionHex(void)
{
return openimageio_version();
}
} // export "C"

@ -39,12 +39,16 @@ extern "C" {
#include <stdio.h>
struct ImBuf;
int imb_is_a_photoshop (const char *name);
int imb_save_photoshop (struct ImBuf *ibuf, const char *name, int flags);
struct ImBuf *imb_load_photoshop (const char *name, int flags, char *colorspace);
int OIIO_getVersionHex(void);
#ifdef __cplusplus
}

@ -183,8 +183,13 @@ if env['WITH_BF_SMOKE']:
if env['WITH_BF_COLLADA']:
defs.append('WITH_COLLADA')
if env['WITH_BF_OIIO']:
if env['WITH_BF_OCIO']:
defs.append('WITH_OCIO')
incs += ' ' + '#/intern/opencolorio'
if env['WITH_BF_OIIO']:
defs.append('WITH_OPENIMAGEIO')
incs += ' ../../imbuf/intern/oiio'
if env['WITH_BF_PLAYER']:
defs.append('WITH_PLAYER')

@ -35,6 +35,7 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/cycles/blender
../../../../intern/opencolorio
../../../../intern/guardedalloc
)
@ -49,6 +50,8 @@ set(SRC
bpy_app_ffmpeg.c
bpy_app_build_options.c
bpy_app_handlers.c
bpy_app_ocio.c
bpy_app_oiio.c
bpy_app_translations.c
bpy_driver.c
bpy_interface.c
@ -73,6 +76,8 @@ set(SRC
bpy_app_ffmpeg.h
bpy_app_build_options.h
bpy_app_handlers.h
bpy_app_ocio.h
bpy_app_oiio.h
bpy_app_translations.h
bpy_driver.h
bpy_intern_string.h
@ -242,6 +247,13 @@ if(WITH_OPENCOLORIO)
add_definitions(-DWITH_OCIO)
endif()
if(WITH_OPENIMAGEIO)
add_definitions(-DWITH_OPENIMAGEIO)
list(APPEND INC
../../imbuf/intern/oiio
)
endif()
if(WITH_PLAYER)
add_definitions(-DWITH_PLAYER)
endif()

@ -34,6 +34,8 @@
#include "bpy_app.h"
#include "bpy_app_ffmpeg.h"
#include "bpy_app_ocio.h"
#include "bpy_app_oiio.h"
#include "bpy_app_build_options.h"
#include "bpy_app_translations.h"
@ -93,6 +95,8 @@ static PyStructSequence_Field app_info_fields[] = {
/* submodules */
{(char *)"ffmpeg", (char *)"FFmpeg library information backend"},
{(char *)"ocio", (char *)"OpenColorIO library information backend"},
{(char *)"oiio", (char *)"OpenImageIO library information backend"},
{(char *)"build_options", (char *)"A set containing most important enabled optional build features"},
{(char *)"handlers", (char *)"Application handler callbacks"},
{(char *)"translations", (char *)"Application and addons internationalization API"},
@ -167,6 +171,8 @@ static PyObject *make_app_info(void)
#endif
SetObjItem(BPY_app_ffmpeg_struct());
SetObjItem(BPY_app_ocio_struct());
SetObjItem(BPY_app_oiio_struct());
SetObjItem(BPY_app_build_options_struct());
SetObjItem(BPY_app_handlers_struct());
SetObjItem(BPY_app_translations_struct());

@ -0,0 +1,109 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_ocio.c
* \ingroup pythonintern
*/
#include <Python.h>
#include "BLI_utildefines.h"
#include "bpy_app_ocio.h"
#ifdef WITH_OCIO
# include "ocio_capi.h"
#endif
static PyTypeObject BlenderAppOCIOType;
static PyStructSequence_Field app_ocio_info_fields[] = {
{(char *)"supported", (char *)("Boolean, True when Blender is built with OpenColorIO support")},
{(char *)("version"), (char *)("The OpenColorIO version as a tuple of 3 numbers")},
{(char *)("version_string"), (char *)("The OpenColorIO version formatted as a string")},
{NULL}
};
static PyStructSequence_Desc app_ocio_info_desc = {
(char *)"bpy.app.ocio", /* name */
(char *)"This module contains information about OpenColorIO blender is linked against", /* doc */
app_ocio_info_fields, /* fields */
(sizeof(app_ocio_info_fields) / sizeof(PyStructSequence_Field)) - 1
};
static PyObject *make_ocio_info(void)
{
PyObject *ocio_info;
int pos = 0;
#ifdef WITH_OCIO
int curversion;
#endif
ocio_info = PyStructSequence_New(&BlenderAppOCIOType);
if (ocio_info == NULL) {
return NULL;
}
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(ocio_info, pos++, PyUnicode_FromString(str))
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(ocio_info, pos++, obj)
#ifdef WITH_OCIO
curversion = OCIO_getVersionHex();
SetObjItem(PyBool_FromLong(1));
SetObjItem(Py_BuildValue("(iii)",
curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
#else
SetObjItem(PyBool_FromLong(0));
SetStrItem("Unknown");
SetStrItem("Unknown");
#endif
if (PyErr_Occurred()) {
Py_CLEAR(ocio_info);
return NULL;
}
#undef SetStrItem
#undef SetObjItem
return ocio_info;
}
PyObject *BPY_app_ocio_struct(void)
{
PyObject *ret;
PyStructSequence_InitType(&BlenderAppOCIOType, &app_ocio_info_desc);
ret = make_ocio_info();
/* prevent user from creating new instances */
BlenderAppOCIOType.tp_init = NULL;
BlenderAppOCIOType.tp_new = NULL;
BlenderAppOCIOType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
return ret;
}

@ -0,0 +1,32 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_ocio.h
* \ingroup pythonintern
*/
#ifndef __BPY_APP_OCIO_H__
#define __BPY_APP_OCIO_H__
PyObject *BPY_app_ocio_struct(void);
#endif /* __BPY_APP_OCIO_H__ */

@ -0,0 +1,109 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_oiio.c
* \ingroup pythonintern
*/
#include <Python.h>
#include "BLI_utildefines.h"
#include "bpy_app_oiio.h"
#ifdef WITH_OPENIMAGEIO
# include "openimageio_api.h"
#endif
static PyTypeObject BlenderAppOIIOType;
static PyStructSequence_Field app_oiio_info_fields[] = {
{(char *)"supported", (char *)("Boolean, True when Blender is built with OpenImageIO support")},
{(char *)("version"), (char *)("The OpenImageIO version as a tuple of 3 numbers")},
{(char *)("version_string"), (char *)("The OpenImageIO version formatted as a string")},
{NULL}
};
static PyStructSequence_Desc app_oiio_info_desc = {
(char *)"bpy.app.oiio", /* name */
(char *)"This module contains information about OpeImageIO blender is linked against", /* doc */
app_oiio_info_fields, /* fields */
(sizeof(app_oiio_info_fields) / sizeof(PyStructSequence_Field)) - 1
};
static PyObject *make_oiio_info(void)
{
PyObject *oiio_info;
int pos = 0;
#ifdef WITH_OPENIMAGEIO
int curversion;
#endif
oiio_info = PyStructSequence_New(&BlenderAppOIIOType);
if (oiio_info == NULL) {
return NULL;
}
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(oiio_info, pos++, PyUnicode_FromString(str))
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(oiio_info, pos++, obj)
#ifdef WITH_OPENIMAGEIO
curversion = OIIO_getVersionHex();
SetObjItem(PyBool_FromLong(1));
SetObjItem(Py_BuildValue("(iii)",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
SetObjItem(PyBool_FromLong(0));
SetStrItem("Unknown");
SetStrItem("Unknown");
#endif
if (PyErr_Occurred()) {
Py_CLEAR(oiio_info);
return NULL;
}
#undef SetStrItem
#undef SetObjItem
return oiio_info;
}
PyObject *BPY_app_oiio_struct(void)
{
PyObject *ret;
PyStructSequence_InitType(&BlenderAppOIIOType, &app_oiio_info_desc);
ret = make_oiio_info();
/* prevent user from creating new instances */
BlenderAppOIIOType.tp_init = NULL;
BlenderAppOIIOType.tp_new = NULL;
BlenderAppOIIOType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
return ret;
}

@ -0,0 +1,32 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_oiio.h
* \ingroup pythonintern
*/
#ifndef __BPY_APP_OIIO_H__
#define __BPY_APP_OIIO_H__
PyObject *BPY_app_oiio_struct(void);
#endif /* __BPY_APP_OIIO_H__ */