Skip to content
Snippets Groups Projects
Commit 8998068d authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Require only bob 1.2.2 to compile

parent 35a28875
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ package_dir = os.path.dirname(os.path.realpath(__file__))
package_dir = os.path.join(package_dir, 'xbob', 'io', 'include')
include_dirs = [package_dir]
packages = ['bob-io >= 1.3']
packages = ['bob-io >= 1.2.2']
version = '2.0.0a0'
setup(
......
......@@ -76,6 +76,23 @@ static void PyBobIoHDF5File_Delete (PyBobIoHDF5FileObject* o) {
}
static bob::io::HDF5File::mode_t mode_from_char (char mode) {
bob::io::HDF5File::mode_t new_mode = bob::io::HDF5File::inout;
switch (mode) {
case 'r': new_mode = bob::io::HDF5File::in; break;
case 'a': new_mode = bob::io::HDF5File::inout; break;
case 'w': new_mode = bob::io::HDF5File::trunc; break;
case 'x': new_mode = bob::io::HDF5File::excl; break;
default:
PyErr_SetString(PyExc_RuntimeError, "Supported flags are 'r' (read-only), 'a' (read/write/append), 'w' (read/write/truncate) or 'x' (read/write/exclusive)");
}
return new_mode;
}
/* The __init__(self) method */
static int PyBobIoHDF5File_Init(PyBobIoHDF5FileObject* self,
PyObject *args, PyObject* kwds) {
......@@ -106,6 +123,8 @@ static int PyBobIoHDF5File_Init(PyBobIoHDF5FileObject* self,
PyErr_Format(PyExc_ValueError, "file open mode string should have 1 element and be either 'r' (read), 'w' (write), 'a' (append), 'x' (exclusive)");
return -1;
}
bob::io::HDF5File::mode_t mode_mode = mode_from_char(mode);
if (PyErr_Occurred()) return -1;
#if PY_VERSION_HEX >= 0x03000000
const char* c_filename = PyBytes_AS_STRING(filename);
......@@ -114,7 +133,7 @@ static int PyBobIoHDF5File_Init(PyBobIoHDF5FileObject* self,
#endif
try {
self->f.reset(new bob::io::HDF5File(c_filename, mode));
self->f.reset(new bob::io::HDF5File(c_filename, mode_mode));
}
catch (std::exception& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
......
......@@ -15,6 +15,7 @@ import random
import nose.tools
from . import HDF5File, load, save, peek_all, test_utils
from .test_utils import bob_at_least
def read_write_check(outfile, dname, data, dtype=None):
"""Tests scalar input/output on HDF5 files"""
......@@ -313,6 +314,7 @@ def test_string_support():
del outfile
os.unlink(tmpname)
@bob_at_least('1.3.0a0')
def test_string_attribute_support():
try:
......
......@@ -117,6 +117,31 @@ def ffmpeg_found(version_geq=None):
return test_wrapper
def bob_at_least(version_geq):
'''Decorator to check if at least a certain version of Bob is installed
To use this, decorate your test routine with something like:
.. code-block:: python
@bob_at_least('1.2.2')
'''
def test_wrapper(test):
@functools.wraps(test)
def wrapper(*args, **kwargs):
from .version import externals
inst = SV(externals['Bob'][0])
if inst < version_geq:
raise nose.plugins.skip.SkipTest('Bob version installed (%s) is smaller than required for this test (%s)' % (externals['Bob'][0], version_geq))
return test(*args, **kwargs)
return wrapper
return test_wrapper
def codec_available(codec):
'''Decorator to check if a codec is available before enabling a test'''
......
......@@ -276,12 +276,21 @@ static PyObject* matio_version() {
#endif
}
/**
* Bob version, API version and platform
*/
static PyObject* bob_version() {
return Py_BuildValue("sis", BOB_VERSION, BOB_API_VERSION, BOB_PLATFORM);
}
static PyObject* build_version_dictionary() {
PyObject* retval = PyDict_New();
if (!retval) return 0;
auto retval_ = make_safe(retval);
if (!dict_steal(retval, "Bob", bob_version())) return 0;
if (!dict_steal(retval, "HDF5", hdf5_version())) return 0;
if (!dict_steal(retval, "FFmpeg", ffmpeg_version())) return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment