Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.math
Commits
4e28faf9
Commit
4e28faf9
authored
Mar 23, 2014
by
André Anjos
💬
Browse files
Add function to print comprehensive dependence list
parent
426b37db
Changes
3
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
4e28faf9
...
...
@@ -40,6 +40,14 @@ setup(
],
ext_modules
=
[
Extension
(
"xbob.math.version"
,
[
"xbob/math/version.cpp"
,
],
packages
=
packages
,
version
=
version
,
include_dirs
=
include_dirs
,
),
Extension
(
"xbob.math._library"
,
[
"xbob/math/histogram.cpp"
,
...
...
xbob/math/__init__.py
View file @
4e28faf9
from
._library
import
__version__
from
._library
import
*
def
get_config
():
"""Returns a string containing the configuration information.
"""
import
pkg_resources
from
.version
import
externals
packages
=
pkg_resources
.
require
(
__name__
)
this
=
packages
[
0
]
deps
=
packages
[
1
:]
retval
=
"%s: %s (%s)
\n
"
%
(
this
.
key
,
this
.
version
,
this
.
location
)
retval
+=
" - c/c++ dependencies:
\n
"
for
k
in
sorted
(
externals
):
retval
+=
" - %s: %s
\n
"
%
(
k
,
externals
[
k
])
retval
+=
" - python dependencies:
\n
"
for
d
in
deps
:
retval
+=
" - %s: %s (%s)
\n
"
%
(
d
.
key
,
d
.
version
,
d
.
location
)
return
retval
.
strip
()
# gets sphinx autodoc done right - don't remove it
__all__
=
[
_
for
_
in
dir
()
if
not
_
.
startswith
(
'_'
)]
xbob/math/version.cpp
0 → 100644
View file @
4e28faf9
/**
* @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
(
"{ssss}"
,
"name"
,
"gcc"
,
"version"
,
f
.
str
().
c_str
());
# elif defined(__llvm__) && !defined(__clang__)
return
Py_BuildValue
(
"{ssss}"
,
"name"
,
"llvm-gcc"
,
"version"
,
__VERSION__
);
# elif defined(__clang__)
return
Py_BuildValue
(
"{ssss}"
,
"name"
,
"clang"
,
"version"
,
__clang_version__
);
# else
return
Py_BuildValue
(
"{ssss}"
,
"name"
,
"unsupported"
,
"version"
,
"unknown"
);
# 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
);
}
/**
* Numpy version
*/
static
PyObject
*
numpy_version
()
{
return
Py_BuildValue
(
"{ssss}"
,
"abi"
,
BOOST_PP_STRINGIZE
(
NPY_VERSION
),
"api"
,
BOOST_PP_STRINGIZE
(
NPY_API_VERSION
));
}
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
;
}
if
(
!
dict_steal
(
retval
,
"NumPy"
,
numpy_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
();
}
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