Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.learn.libsvm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.learn.libsvm
Commits
4495f282
Commit
4495f282
authored
Mar 26, 2014
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes initial compilation issues
parent
fcc62cad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
18 deletions
+28
-18
setup.py
setup.py
+21
-12
xbob/learn/libsvm/file.cpp
xbob/learn/libsvm/file.cpp
+2
-1
xbob/learn/libsvm/version.cpp
xbob/learn/libsvm/version.cpp
+5
-5
No files found.
setup.py
View file @
4495f282
...
...
@@ -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=['
lib
svm'])
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
.
lib
svm
',
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.
lib
svm.version",
[
"xbob/learn/svm/version.cpp",
"xbob/learn/
lib
svm/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.
lib
svm._library",
[
"xbob/learn/li
near
/file.cpp",
"xbob/learn/li
bsvm
/file.cpp",
],
packages = packages,
include_dirs = include_dirs,
...
...
xbob/learn/libsvm/file.cpp
View file @
4495f282
...
...
@@ -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
),
...
...
xbob/learn/libsvm/version.cpp
View file @
4495f282
...
...
@@ -23,7 +23,7 @@
#include <xbob.blitz/capi.h>
#include <xbob.blitz/cleanup.h>
#include <xbob.io/config.h>
#include <xbob.learn.li
near
/config.h>
#include <xbob.learn.li
bsvm
/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_LI
NEAR
_API_VERSION
)
<
0
)
if
(
PyModule_AddIntConstant
(
m
,
"api"
,
XBOB_LEARN_LI
BSVM
_API_VERSION
)
<
0
)
return
0
;
if
(
PyModule_AddStringConstant
(
m
,
"module"
,
XBOB_EXT_MODULE_VERSION
)
<
0
)
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment