Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.libsvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.learn.libsvm
Commits
4495f282
Commit
4495f282
authored
11 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Fixes initial compilation issues
parent
fcc62cad
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
setup.py
+21
-12
21 additions, 12 deletions
setup.py
xbob/learn/libsvm/file.cpp
+2
-1
2 additions, 1 deletion
xbob/learn/libsvm/file.cpp
xbob/learn/libsvm/version.cpp
+5
-5
5 additions, 5 deletions
xbob/learn/libsvm/version.cpp
with
28 additions
and
18 deletions
setup.py
+
21
−
12
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
,
...
...
This diff is collapsed.
Click to expand it.
xbob/learn/libsvm/file.cpp
+
2
−
1
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
),
...
...
This diff is collapsed.
Click to expand it.
xbob/learn/libsvm/version.cpp
+
5
−
5
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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment