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

Add Travis-CI support

parent e38f031e
No related branches found
No related tags found
No related merge requests found
# After changing this file, run it through http://lint.travis-ci.org/
# Generates 4 builds, the ones for python3 will install external wheels
language: python
python:
- 2.6
- 2.7
matrix:
include:
- python: 3.2
env:
- NUMPYSPEC===1.7.1
- python: 3.3
env:
- NUMPYSPEC===1.8.0
before_install:
- sudo add-apt-repository -y ppa:biometrics/bob
- sudo apt-get update -qq
- sudo apt-get install -qq bob-dev
- if [ -n "${NUMPYSPEC}" ]; then sudo apt-get install -qq libatlas-dev libatlas-base-dev liblapack-dev gfortran; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --upgrade pip setuptools; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel numpy$NUMPYSPEC sphinx nose matplotlib; fi
install:
- "python bootstrap.py"
- "./bin/buildout"
script:
- "./bin/nosetests -sv"
- "./bin/sphinx-build -b doctest doc sphinx"
- "./bin/sphinx-build -b html doc sphinx"
......@@ -2,6 +2,9 @@
.. Andre Anjos <andre.anjos@idiap.ch>
.. Thu 29 Aug 2013 16:07:57 CEST
.. image:: https://travis-ci.org/bioidiap/xbob.measure.svg?branch=master
:target: https://travis-ci.org/bioidiap/xbob.measure
=================================
Python bindings for bob.measure
=================================
......
......@@ -18,13 +18,13 @@ develop = src/xbob.extension
debug = true
verbose = true
prefixes = /idiap/group/torch5spro/nightlies/last/bob/linux-x86_64-release
/Users/andre/work/bob/b/dbg/
/Users/andre/work/bob/b/dbgx/
[sources]
xbob.extension = git git@github.com:bioidiap/xbob.extension branch=prototype
xbob.blitz = git git@github.com:bioidiap/xbob.blitz
xbob.math = git git@github.com:bioidiap/xbob.math
xbob.io = git git@github.com:bioidiap/xbob.io
xbob.extension = git https://github.com/bioidiap/xbob.extension branch=prototype
xbob.blitz = git https://github.com/bioidiap/xbob.blitz
xbob.math = git https://github.com/bioidiap/xbob.math
xbob.io = git https://github.com/bioidiap/xbob.io
[scripts]
recipe = xbob.buildout:scripts
......@@ -7,7 +7,7 @@ from setuptools import setup, find_packages, dist
dist.Distribution(dict(setup_requires=['xbob.blitz']))
from xbob.blitz.extension import Extension
packages = ['bob-measure >= 1.3']
packages = ['bob-measure >= 1.2.2']
version = '2.0.0a0'
setup(
......@@ -30,6 +30,7 @@ setup(
'xbob.blitz',
'xbob.math',
'xbob.io',
'matplotlib',
],
namespace_packages=[
......@@ -37,6 +38,13 @@ setup(
],
ext_modules = [
Extension("xbob.measure.version",
[
"xbob/measure/version.cpp",
],
packages = packages,
version = version,
),
Extension("xbob.measure._library",
[
"xbob/measure/main.cpp",
......
from ._library import *
from . import version
from .version import module as __version__
from . import plot
from . import load
......
......@@ -13,6 +13,11 @@ import numpy
import nose.tools
import xbob.io
from .version import externals
from distutils.version import StrictVersion
if StrictVersion(externals['Bob'][0]) < '1.3.0a0': HAVE_BOB_1_2_2 = True
else: HAVE_BOB_1_2_2 = False
def F(f):
"""Returns the test file on the "data" subdirectory"""
import pkg_resources
......@@ -184,6 +189,7 @@ def test_plots():
# uncomment the next line to save a reference value
# save('nonsep-roc.hdf5', xy)
xyref = xbob.io.load(F('nonsep-roc.hdf5'))
if HAVE_BOB_1_2_2: xyref = xyref[::-1,:]
assert numpy.array_equal(xy, xyref)
# This example will test the Precision-Recall plot calculation functionality.
......@@ -198,6 +204,7 @@ def test_plots():
# uncomment the next line to save a reference value
# save('nonsep-det.hdf5', det_xyzw)
det_xyzw_ref = xbob.io.load(F('nonsep-det.hdf5'))
if HAVE_BOB_1_2_2: det_xyzw_ref = det_xyzw_ref[::-1,:]
assert numpy.allclose(det_xyzw, det_xyzw_ref, atol=1e-15)
# This example will test the EPC plot calculation functionality. For the
......@@ -228,6 +235,7 @@ def test_rocch():
negatives = xbob.io.load(F('linsep-negatives.hdf5'))
# References obtained using Bosaris 1.06
pmiss_pfa_ref = numpy.array([[1., 0., 0.], [0., 0., 1.]])
if HAVE_BOB_1_2_2: pmiss_pfa_ref = pmiss_pfa_ref[::-1,:]
eer_ref = 0.
# Computes
pmiss_pfa = rocch(negatives, positives)
......@@ -242,6 +250,7 @@ def test_rocch():
negatives = xbob.io.load(F('nonsep-negatives.hdf5'))
# References obtained using Bosaris 1.06
pmiss_pfa_ref = numpy.array([[1., 0.68, 0.28, 0.1, 0.06, 0., 0.], [0, 0, 0.08, 0.12, 0.22, 0.48, 1.]])
if HAVE_BOB_1_2_2: pmiss_pfa_ref = pmiss_pfa_ref[::-1,:]
eer_ref = 0.116363636363636
# Computes
pmiss_pfa = rocch(negatives, positives)
......
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Thu 7 Nov 13:50:16 2013
*
* @brief Binds configuration information available from bob
*/
#include <Python.h>
#include <bob/config.h>
#include <string>
#include <cstdlib>
#include <blitz/blitz.h>
#include <boost/preprocessor/stringize.hpp>
#include <boost/version.hpp>
#include <boost/format.hpp>
#ifdef NO_IMPORT_ARRAY
#undef NO_IMPORT_ARRAY
#endif
#include <xbob.blitz/capi.h>
#include <xbob.blitz/cleanup.h>
static int dict_steal(PyObject* d, const char* key, PyObject* value) {
if (!value) return 0;
int retval = PyDict_SetItemString(d, key, value);
Py_DECREF(value);
if (retval == 0) return 1; //all good
return 0; //a problem occurred
}
/**
* Describes the version of Boost libraries installed
*/
static PyObject* boost_version() {
boost::format f("%d.%d.%d");
f % (BOOST_VERSION / 100000);
f % (BOOST_VERSION / 100 % 1000);
f % (BOOST_VERSION % 100);
return Py_BuildValue("s", f.str().c_str());
}
/**
* Describes the compiler version
*/
static PyObject* compiler_version() {
# if defined(__GNUC__) && !defined(__llvm__)
boost::format f("%s.%s.%s");
f % BOOST_PP_STRINGIZE(__GNUC__);
f % BOOST_PP_STRINGIZE(__GNUC_MINOR__);
f % BOOST_PP_STRINGIZE(__GNUC_PATCHLEVEL__);
return Py_BuildValue("ss", "gcc", f.str().c_str());
# elif defined(__llvm__) && !defined(__clang__)
return Py_BuildValue("ss", "llvm-gcc", __VERSION__);
# elif defined(__clang__)
return Py_BuildValue("ss", "clang", __clang_version__);
# else
return Py_BuildValue("s", "unsupported");
# endif
}
/**
* Python version with which we compiled the extensions
*/
static PyObject* python_version() {
boost::format f("%s.%s.%s");
f % BOOST_PP_STRINGIZE(PY_MAJOR_VERSION);
f % BOOST_PP_STRINGIZE(PY_MINOR_VERSION);
f % BOOST_PP_STRINGIZE(PY_MICRO_VERSION);
return Py_BuildValue("s", f.str().c_str());
}
/**
* 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;
if (!dict_steal(retval, "Boost", boost_version())) {
Py_DECREF(retval);
return 0;
}
if (!dict_steal(retval, "Compiler", compiler_version())) {
Py_DECREF(retval);
return 0;
}
if (!dict_steal(retval, "Python", python_version())) {
Py_DECREF(retval);
return 0;
}
if (!dict_steal(retval, "Bob", bob_version())) {
Py_DECREF(retval);
return 0;
}
return retval;
}
static PyMethodDef module_methods[] = {
{0} /* Sentinel */
};
PyDoc_STRVAR(module_docstr,
"Information about software used to compile the C++ Bob API"
);
#if PY_VERSION_HEX >= 0x03000000
static PyModuleDef module_definition = {
PyModuleDef_HEAD_INIT,
XBOB_EXT_MODULE_NAME,
module_docstr,
-1,
module_methods,
0, 0, 0, 0
};
#endif
static PyObject* create_module (void) {
# if PY_VERSION_HEX >= 0x03000000
PyObject* m = PyModule_Create(&module_definition);
# else
PyObject* m = Py_InitModule3(XBOB_EXT_MODULE_NAME, module_methods, module_docstr);
# endif
if (!m) return 0;
auto m_ = make_safe(m); ///< protects against early returns
/* register version numbers and constants */
if (PyModule_AddStringConstant(m, "module", XBOB_EXT_MODULE_VERSION) < 0)
return 0;
PyObject* externals = build_version_dictionary();
if (!externals) return 0;
if (PyModule_AddObject(m, "externals", externals) < 0) return 0;
if (import_xbob_blitz() < 0) return 0;
Py_INCREF(m);
return m;
}
PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) {
# if PY_VERSION_HEX >= 0x03000000
return
# endif
create_module();
}
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