Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.image
Commits
45866d77
Commit
45866d77
authored
May 21, 2015
by
Manuel Günther
Browse files
Applied new versioning system
parent
5f37c196
Changes
5
Hide whitespace changes
Inline
Side-by-side
bob/io/image/include/bob.io.image/config.h
0 → 100644
View file @
45866d77
/**
* @author Manuel Guenther <manuel.guenther@idiap.ch>
* @date Thu 21 May 16:23:42 CEST 2015
*
* @brief Versioning information for bob.io.image
*/
#ifndef BOB_IO_IMAGE_CONFIG_H
#define BOB_IO_IMAGE_CONFIG_H
#ifdef BOB_IMPORT_VERSION
/***************************************
* Here we define some functions that should be used to build version dictionaries in the version.cpp file
* There will be a compiler warning, when these functions are not used, so use them!
***************************************/
#include <Python.h>
#include <boost/preprocessor/stringize.hpp>
extern
"C"
{
#include <jpeglib.h>
#define PNG_SKIP_SETJMP_CHECK
// #define requires because of the problematic pngconf.h.
// Look at the thread here:
// https://bugs.launchpad.net/ubuntu/+source/libpng/+bug/218409
#include <png.h>
#include <gif_lib.h>
#include <tiffio.h>
}
/**
* LibJPEG version
*/
static
PyObject
*
libjpeg_version
()
{
boost
::
format
f
(
"%d (compiled with %d bits depth)"
);
f
%
LIBJPEG_VERSION
%
BITS_IN_JSAMPLE
;
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
}
/**
* Libpng version
*/
static
PyObject
*
libpng_version
()
{
return
Py_BuildValue
(
"s"
,
PNG_LIBPNG_VER_STRING
);
}
/**
* Libtiff version
*/
static
PyObject
*
libtiff_version
()
{
static
const
std
::
string
beg_str
(
"LIBTIFF, Version "
);
static
const
size_t
beg_len
=
beg_str
.
size
();
std
::
string
vtiff
(
TIFFGetVersion
());
// Remove first part if it starts with "LIBTIFF, Version "
if
(
vtiff
.
compare
(
0
,
beg_len
,
beg_str
)
==
0
)
vtiff
=
vtiff
.
substr
(
beg_len
);
// Remove multiple (copyright) lines if any
size_t
end_line
=
vtiff
.
find
(
"
\n
"
);
if
(
end_line
!=
std
::
string
::
npos
)
vtiff
=
vtiff
.
substr
(
0
,
end_line
);
return
Py_BuildValue
(
"s"
,
vtiff
.
c_str
());
}
/**
* Version of giflib support
*/
static
PyObject
*
giflib_version
()
{
#ifdef GIF_LIB_VERSION
return
Py_BuildValue
(
"s"
,
GIF_LIB_VERSION
);
#else
boost
::
format
f
(
"%s.%s.%s"
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_MAJOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_MINOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_RELEASE
);
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
#endif
}
#endif // BOB_IMPORT_VERSION
#endif
/* BOB_IO_IMAGE_CONFIG_H */
bob/io/image/main.cpp
View file @
45866d77
...
...
@@ -11,6 +11,7 @@
#include <bob.blitz/capi.h>
#include <bob.blitz/cleanup.h>
#include <bob.core/api.h>
#include <bob.io.base/api.h>
#include "file.h"
...
...
@@ -44,17 +45,9 @@ static PyObject* create_module (void) {
auto
m_
=
make_safe
(
m
);
/* imports dependencies */
if
(
import_bob_blitz
()
<
0
)
{
PyErr_Print
();
PyErr_Format
(
PyExc_ImportError
,
"cannot import `%s'"
,
BOB_EXT_MODULE_NAME
);
return
0
;
}
if
(
import_bob_io_base
()
<
0
)
{
PyErr_Print
();
PyErr_Format
(
PyExc_ImportError
,
"cannot import `%s'"
,
BOB_EXT_MODULE_NAME
);
return
0
;
}
if
(
import_bob_blitz
()
<
0
)
return
0
;
if
(
import_bob_core_logging
()
<
0
)
return
0
;
if
(
import_bob_io_base
()
<
0
)
return
0
;
/* activates image plugins */
if
(
!
PyBobIoCodec_Register
(
".tif"
,
"TIFF, compresssed (libtiff)"
,
...
...
@@ -109,9 +102,7 @@ static PyObject* create_module (void) {
PyErr_Print
();
}
Py_INCREF
(
m
);
return
m
;
return
Py_BuildValue
(
"O"
,
m
);
}
PyMODINIT_FUNC
BOB_EXT_ENTRY_NAME
(
void
)
{
...
...
bob/io/image/version.cpp
View file @
45866d77
...
...
@@ -5,177 +5,13 @@
* @brief Binds configuration information available from bob
*/
#include <Python.h>
#ifdef NO_IMPORT_ARRAY
#undef NO_IMPORT_ARRAY
#endif
#include <bob.blitz/capi.h>
#define BOB_IMPORT_VERSION
#include <bob.blitz/config.h>
#include <bob.blitz/cleanup.h>
#include <bob.io.base/api.h>
#include <string>
#include <boost/preprocessor/stringize.hpp>
#include <boost/version.hpp>
#include <boost/format.hpp>
#include <bob.core/config.h>
#include <bob.io.base/config.h>
#include <bob.io.image/config.h>
extern
"C"
{
#include <jpeglib.h>
#define PNG_SKIP_SETJMP_CHECK
// #define requires because of the problematic pngconf.h.
// Look at the thread here:
// https://bugs.launchpad.net/ubuntu/+source/libpng/+bug/218409
#include <png.h>
#include <gif_lib.h>
#include <tiffio.h>
}
static
int
dict_set
(
PyObject
*
d
,
const
char
*
key
,
const
char
*
value
)
{
PyObject
*
v
=
Py_BuildValue
(
"s"
,
value
);
if
(
!
v
)
return
0
;
auto
v_
=
make_safe
(
v
);
int
retval
=
PyDict_SetItemString
(
d
,
key
,
v
);
if
(
retval
==
0
)
return
1
;
//all good
return
0
;
//a problem occurred
}
static
int
dict_steal
(
PyObject
*
d
,
const
char
*
key
,
PyObject
*
value
)
{
if
(
!
value
)
return
0
;
auto
value_
=
make_safe
(
value
);
int
retval
=
PyDict_SetItemString
(
d
,
key
,
value
);
if
(
retval
==
0
)
return
1
;
//all good
return
0
;
//a problem occurred
}
/**
* LibJPEG version
*/
static
PyObject
*
libjpeg_version
()
{
boost
::
format
f
(
"%d (compiled with %d bits depth)"
);
f
%
LIBJPEG_VERSION
;
f
%
BITS_IN_JSAMPLE
;
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
}
/**
* Libpng version
*/
static
PyObject
*
libpng_version
()
{
return
Py_BuildValue
(
"s"
,
PNG_LIBPNG_VER_STRING
);
}
/**
* Libtiff version
*/
static
PyObject
*
libtiff_version
()
{
static
const
std
::
string
beg_str
(
"LIBTIFF, Version "
);
static
const
size_t
beg_len
=
beg_str
.
size
();
std
::
string
vtiff
(
TIFFGetVersion
());
// Remove first part if it starts with "LIBTIFF, Version "
if
(
vtiff
.
compare
(
0
,
beg_len
,
beg_str
)
==
0
)
vtiff
=
vtiff
.
substr
(
beg_len
);
// Remove multiple (copyright) lines if any
size_t
end_line
=
vtiff
.
find
(
"
\n
"
);
if
(
end_line
!=
std
::
string
::
npos
)
vtiff
=
vtiff
.
substr
(
0
,
end_line
);
return
Py_BuildValue
(
"s"
,
vtiff
.
c_str
());
}
/**
* Version of giflib support
*/
static
PyObject
*
giflib_version
()
{
#ifdef GIF_LIB_VERSION
return
Py_BuildValue
(
"s"
,
GIF_LIB_VERSION
);
#else
boost
::
format
f
(
"%s.%s.%s"
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_MAJOR
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_MINOR
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_RELEASE
);
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
#endif
}
/**
* 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
());
}
/**
* Numpy version
*/
static
PyObject
*
numpy_version
()
{
return
Py_BuildValue
(
"{ssss}"
,
"abi"
,
BOOST_PP_STRINGIZE
(
NPY_VERSION
),
"api"
,
BOOST_PP_STRINGIZE
(
NPY_API_VERSION
));
}
/**
* bob.blitz c/c++ api version
*/
static
PyObject
*
bob_blitz_version
()
{
return
Py_BuildValue
(
"{ss}"
,
"api"
,
BOOST_PP_STRINGIZE
(
BOB_BLITZ_API_VERSION
));
}
/**
* bob.core c/c++ api version
*/
static
PyObject
*
bob_core_version
()
{
return
Py_BuildValue
(
"{ss}"
,
"api"
,
BOOST_PP_STRINGIZE
(
BOB_CORE_API_VERSION
));
}
/**
* bob.io.base c/c++ api version
*/
static
PyObject
*
bob_io_base_version
()
{
return
Py_BuildValue
(
"{ss}"
,
"api"
,
BOOST_PP_STRINGIZE
(
BOB_IO_BASE_API_VERSION
));
}
static
PyObject
*
build_version_dictionary
()
{
...
...
@@ -184,21 +20,21 @@ static PyObject* build_version_dictionary() {
auto
retval_
=
make_safe
(
retval
);
if
(
!
dict_steal
(
retval
,
"libjpeg"
,
libjpeg_version
()))
return
0
;
if
(
!
dict_s
e
t
(
retval
,
"libnetpbm"
,
"Unknown version"
))
return
0
;
if
(
!
dict_st
eal
(
retval
,
"libnetpbm"
,
Py_BuildValue
(
"s"
,
"Unknown version"
))
)
return
0
;
if
(
!
dict_steal
(
retval
,
"libpng"
,
libpng_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"libtiff"
,
libtiff_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"giflib"
,
giflib_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"HDF5"
,
hdf5_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
;
if
(
!
dict_steal
(
retval
,
"NumPy"
,
numpy_version
()))
return
0
;
if
(
!
dict_s
e
t
(
retval
,
"Blitz++"
,
BZ_VERSION
))
return
0
;
if
(
!
dict_st
eal
(
retval
,
"Blitz++"
,
blitz_version
()
))
return
0
;
if
(
!
dict_steal
(
retval
,
"bob.blitz"
,
bob_blitz_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"bob.core"
,
bob_core_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"bob.io.base"
,
bob_io_base_version
()))
return
0
;
Py_INCREF
(
retval
);
return
retval
;
return
Py_BuildValue
(
"O"
,
retval
);
}
static
PyMethodDef
module_methods
[]
=
{
...
...
@@ -235,22 +71,7 @@ static PyObject* create_module (void) {
return
0
;
if
(
PyModule_AddObject
(
m
,
"externals"
,
build_version_dictionary
())
<
0
)
return
0
;
/* imports dependencies */
if
(
import_bob_blitz
()
<
0
)
{
PyErr_Print
();
PyErr_Format
(
PyExc_ImportError
,
"cannot import `%s'"
,
BOB_EXT_MODULE_NAME
);
return
0
;
}
if
(
import_bob_io_base
()
<
0
)
{
PyErr_Print
();
PyErr_Format
(
PyExc_ImportError
,
"cannot import `%s'"
,
BOB_EXT_MODULE_NAME
);
return
0
;
}
Py_INCREF
(
m
);
return
m
;
return
Py_BuildValue
(
"O"
,
m
);
}
PyMODINIT_FUNC
BOB_EXT_ENTRY_NAME
(
void
)
{
...
...
setup.py
View file @
45866d77
...
...
@@ -18,7 +18,7 @@ build_requires = load_requirements()
version
=
open
(
"version.txt"
).
read
().
rstrip
()
packages
=
[
'boost'
,
'libpng'
]
boost_modules
=
[
'system'
]
boost_modules
=
[
'system'
,
'filesystem'
]
def
libjpeg_version
(
header
):
...
...
@@ -412,6 +412,7 @@ define_macros = \
gif_pkg
.
macros
()
+
\
netpbm_pkg
.
macros
()
setup
(
name
=
'bob.io.image'
,
...
...
@@ -442,10 +443,10 @@ setup(
"bob/io/image/version.cpp"
,
],
packages
=
packages
,
boost_modules
=
[
'system'
]
,
boost_modules
=
boost_modules
,
bob_packages
=
bob_packages
,
version
=
version
,
system_include_dirs
=
system_include_dirs
,
system_include_dirs
=
system_include_dirs
+
[
'bob/io/image/include'
]
,
library_dirs
=
library_dirs
,
libraries
=
libraries
,
define_macros
=
define_macros
,
...
...
@@ -462,7 +463,7 @@ setup(
"bob/io/image/main.cpp"
,
],
packages
=
packages
,
boost_modules
=
[
'filesystem'
]
,
boost_modules
=
boost_modules
,
bob_packages
=
bob_packages
,
version
=
version
,
system_include_dirs
=
system_include_dirs
,
...
...
@@ -488,4 +489,4 @@ setup(
'Environment :: Plugins'
,
],
)
)
version.txt
View file @
45866d77
2.0.2b0
\ No newline at end of file
2.0.2b1
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