This section includes information for using the Python API of bob.extension.
A custom build class for Pkg-config based extensions
Checks if the requirements for the given packages are satisfied.
Raises a RuntimeError in case requirements are not satisfied. This means either not finding a package if no version number is specified or verifying that the package version does not match the required version by the builder.
Package requirements can be set like this:
"pkg > VERSION"
In this case, the package version should be greater than the given version number. Comparisons are done using distutils.version.LooseVersion. You can use other comparators such as <, <=, >= or ==. If no version number is given, then we only require that the package is installed.
Generates standard macros with library, module names and prefix
Re-organizes the -isystem includes so that more specific paths come first
Normalizes the requirements keeping only the most tight
Bases: distutils.extension.Extension
Extension building with pkg-config packages.
See the documentation for distutils.extension.Extension for more details on input parameters.
Initialize the extension with parameters.
External package extensions (mostly comming from pkg-config), adds a single parameter to the standard arguments of the constructor:
packages : [list]
This should be a list of strings indicating the name of the bob (pkg-config) modules you would like to have linked to your extension additionally to bob-python. Candidates are module names like “bob-machine” or “bob-math”.
For convenience, you can also specify “opencv” or other ‘pkg-config’ registered packages as a dependencies.
A class for capturing configuration information from boost
Example usage:
>>> from bob.extension import boost
>>> pkg = boost('>= 1.35')
>>> pkg.include_directory
'...'
>>> pkg.version
'...'
You can also use this class to retrieve information about installed Boost libraries and link information:
>>> from bob.extension import boost
>>> pkg = boost('>= 1.35')
>>> pkg.libconfig(['python', 'system'])
(...)
Searches for the Boost library in stock locations. Allows user to override.
If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations.
Returns a tuple containing the library configuration for requested modules.
This function respects the path location where the include files for Boost are installed.
Parameters:
A list that defines in which order to search for libraries on the default search path, defined by self.include_directory. Tune this list if you have compiled specific versions of Boost with support to multi-threading (-mt), debug (-g), STLPORT (-p) or required to insert compiler, the underlying thread API used or your own namespace.
Here are the keywords you can use:
Example templates:
Returns:
Returns package availability and version number macros
This method returns a python list with 2 macros indicating package availability and a version number, using standard GNU compatible names. Example:
>>> from bob.extension import boost
>>> pkg = boost('>= 1.34')
>>> pkg.macros()
[('HAVE_BOOST', '1'), ('BOOST_VERSION', '"..."')]
A class for capturing configuration information from pkg-config
Example usage:
>>> from bob.extension import pkgconfig
>>> blitz = pkgconfig('blitz')
>>> blitz.include_directories()
[...]
>>> blitz.library_directories()
[...]
If the package does not exist, a RuntimeError is raised. All calls to any methods of a pkgconfig object are translated into a subprocess call that queries for that specific information. If pkg-config fails, a RuntimeError is raised.
Constructor
Parameters:
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config <name>
Returns a pre-processed dictionary containing compilation options.
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --cflags-only-other <name>
The returned dictionary contains two entries extra_compile_args and define_macros. The define_macros entries are ready for deployment in the setup() function of your package.
Returns a pre-processed list containing extra link arguments.
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --libs-only-other <name>
Returns a pre-processed list containing include directories.
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --cflags-only-I <name>
Returns a pre-processed list containing libraries to link against
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --libs-only-l <name>
Returns a pre-processed list containing library directories.
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --libs-only-L <name>
Returns package availability and version number macros
This method returns a python list with 2 macros indicating package availability and a version number, using standard GNU compatible names. For example, if the package is named foo and its version is 1.4, this command would return:
>>> from bob.extension import pkgconfig
>>> blitz = pkgconfig('blitz')
>>> blitz.package_macros()
[('HAVE_BLITZ', '1'), ('BLITZ_VERSION', '"..."')]
Returns a variable with a specific name (if it exists)
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --variable=<variable-name> <name>
Warning
If a variable does not exist in a package, pkg-config does not signal an error. Instead, it returns an empty string. So, do we.
Returns a list with all variable names know to this package
Equivalent command line version:
$ PKG_CONFIG_PATH=<paths> pkg-config --print-variables <name>
Uniqu-fy preserving order