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

Fixes initial compilation issues

parent fcc62cad
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,8 @@
from setuptools import setup, find_packages, dist
dist.Distribution(dict(setup_requires=['xbob.extension', 'xbob.blitz', 'xbob.io']))
import xbob.extension
import xbob.blitz
from xbob.extension.utils import egrep, find_header, find_library
from xbob.blitz.extension import Extension
import xbob.io
import os
......@@ -14,7 +14,6 @@ package_dir = os.path.dirname(os.path.realpath(__file__))
package_dir = os.path.join(package_dir, 'xbob', 'learn', 'libsvm', 'include')
include_dirs = [
package_dir,
xbob.blitz.get_include(),
xbob.io.get_include(),
]
......@@ -24,7 +23,6 @@ version = '2.0.0a0'
# process libsvm requirement
import os
from distutils.version import LooseVersion
from xbob.extension.utils import egrep, find_header, find_library
def libsvm_version(svm_h):
......@@ -57,15 +55,26 @@ class libsvm:
"""
def __init__ (self, requirement=''):
def __init__ (self, requirement='', only_static=False):
"""
Searches for libsvm in stock locations. Allows user to override.
If the user sets the environment variable XBOB_PREFIX_PATH, that prefixes
the standard path locations.
Parameters:
requirement, str
A string, indicating a version requirement for libsvm. For example,
``'>= 3.12'``.
only_static, boolean
A flag, that indicates if we intend to link against the static library
only. This will trigger our library search to disconsider shared
libraries when searching.
"""
candidates = find_header('svm.h', subpaths=['svm'])
candidates = find_header('svm.h', subpaths=['libsvm'])
if not candidates:
raise RuntimeError("could not find libsvm's `svm.h' - have you installed libsvm on this machine?")
......@@ -116,7 +125,7 @@ class libsvm:
if ext in ['.so', '.a', '.dylib', '.dll']:
self.libraries.append(name[3:]) #strip 'lib' from the name
else: #link against the whole thing
self.libraries.append(':' + f)
self.libraries.append(':' + os.path.basename(candidates[0]))
# library path
self.library_directory = os.path.dirname(candidates[0])
......@@ -147,7 +156,7 @@ define_macros = pkg.macros()
setup(
name='xbob.learn.svm',
name='xbob.learn.libsvm',
version=version,
description='Bob bindings to libsvm',
url='http://github.com/bioidiap/xbob.learn.libsvm',
......@@ -172,9 +181,9 @@ setup(
],
ext_modules = [
Extension("xbob.learn.svm.version",
Extension("xbob.learn.libsvm.version",
[
"xbob/learn/svm/version.cpp",
"xbob/learn/libsvm/version.cpp",
],
packages = packages,
include_dirs = include_dirs,
......@@ -184,9 +193,9 @@ setup(
library_dirs = library_dirs,
libraries = libraries,
),
Extension("xbob.learn.svm._library",
Extension("xbob.learn.libsvm._library",
[
"xbob/learn/linear/file.cpp",
"xbob/learn/libsvm/file.cpp",
],
packages = packages,
include_dirs = include_dirs,
......
......@@ -9,10 +9,11 @@
#include <xbob.learn.libsvm/file.h>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
static bool is_colon(char i) { return i == ':'; }
bob::learn::libsvm::File (const std::string& filename):
bob::learn::libsvm::File::File (const std::string& filename):
m_filename(filename),
m_file(m_filename.c_str()),
m_shape(0),
......
......@@ -23,7 +23,7 @@
#include <xbob.blitz/capi.h>
#include <xbob.blitz/cleanup.h>
#include <xbob.io/config.h>
#include <xbob.learn.linear/config.h>
#include <xbob.learn.libsvm/config.h>
static int dict_set(PyObject* d, const char* key, const char* value) {
PyObject* v = Py_BuildValue("s", value);
......@@ -45,11 +45,11 @@ static int dict_steal(PyObject* d, const char* key, PyObject* value) {
/**
* Describes the libsvm version
*/
static PyObject* libsvm_version() {
static PyObject* get_libsvm_version() {
boost::format s("%d.%d");
s % (LIBSVM_VERSION / 100);
s % (LIBSVM_VERSION % 100);
return Py_BuildValue("s", f.str().c_str());
return Py_BuildValue("s", s.str().c_str());
}
/**
......@@ -129,7 +129,7 @@ static PyObject* build_version_dictionary() {
auto retval_ = make_safe(retval);
if (!dict_set(retval, "Blitz++", BZ_VERSION)) return 0;
if (!dict_steal(retval, "libSVM", libsvm_version())) return 0;
if (!dict_steal(retval, "libSVM", get_libsvm_version())) return 0;
if (!dict_steal(retval, "Boost", boost_version())) return 0;
if (!dict_steal(retval, "Compiler", compiler_version())) return 0;
if (!dict_steal(retval, "Python", python_version())) return 0;
......@@ -172,7 +172,7 @@ static PyObject* create_module (void) {
auto m_ = make_safe(m); ///< protects against early returns
/* register version numbers and constants */
if (PyModule_AddIntConstant(m, "api", XBOB_LEARN_LINEAR_API_VERSION) < 0)
if (PyModule_AddIntConstant(m, "api", XBOB_LEARN_LIBSVM_API_VERSION) < 0)
return 0;
if (PyModule_AddStringConstant(m, "module", XBOB_EXT_MODULE_VERSION) < 0)
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment