ddt  0.1
Functions | Variables
shiboken_helper Namespace Reference

Functions

def generate_sources (project_path, module_dir, module_name, include_directories, use_pyside=False)
 Generate source files using shiboken2. More...
 
def find_binding_files (dir)
 Finds the files necessary for the bindings. More...
 
def get_project_includes (project_root, directories)
 Gets a list of paths to include directories. More...
 
def find_project_includes (root_dir)
 Find include directories in the given directory. More...
 
def run_shiboken (header_file, typesystem_file, include_paths, project_root, module_dir, use_pyside)
 Calls shiboken2 to generate the python bindings. More...
 
def get_generated_sources (directory, subdirectory)
 Gets the generated '.cpp' files. More...
 

Variables

def binding_files = find_binding_files("./src")
 
list include_roots = ["datatransfer", "datavisualisation", "imagehandling", "utils"]
 
list include_dirs = []
 
string seperator = ":"
 
string includes = seperator.join(include_dirs)
 

Function Documentation

◆ find_binding_files()

def shiboken_helper.find_binding_files (   dir)

Finds the files necessary for the bindings.

Searches the given directory for files ending with '.h' or '.xml'. Only the first occurences are returned!

Parameters
dir The absolute path to the directory containig the files.
Returns
tuple Contains the first found '.h' file and the first found '.xml' file.

◆ find_project_includes()

def shiboken_helper.find_project_includes (   root_dir)

Find include directories in the given directory.

Searches the given directory for directories called 'include'. Returns a list of paths to the directories found.

Parameters
root_dir The absolute path to the directory that shall be searched for include directories.
Returns
list A list containing the paths to the include directories.

◆ generate_sources()

def shiboken_helper.generate_sources (   project_path,
  module_dir,
  module_name,
  include_directories,
  use_pyside = False 
)

Generate source files using shiboken2.

This triggers the shiboken process to generate source files for python bindings. Therefore the include paths of the project are gathered, so that they can be included in the shiboken command. Next, the paths to the necessary header and xml files for the bindings are gathered. After then running the shiboken2 process a list containing the generated sources is created and returnd as a string.

Parameters
project_path The absolute path to the project root directory. module_dir The absolute path to the module containing the src folder. module_name The name of the module. include_directories A list containing the names of the project directories containing include directories. use_pyside Whether the bindings shall use pyside extensions.
Returns
string The generated source files. The entries are seperated by a whitespace.

◆ get_generated_sources()

def shiboken_helper.get_generated_sources (   directory,
  subdirectory 
)

Gets the generated '.cpp' files.

Searches in '<directory>/generated/<subdirectory>' for '.cpp' files.

Parameters
directory The absolute path to the directory containing the direactory called 'generated'. subdirectory The name of the directory containing the '.cpp' files.
Returns
list A list containing the relative paths to the '.cpp' files'.

◆ get_project_includes()

def shiboken_helper.get_project_includes (   project_root,
  directories 
)

Gets a list of paths to include directories.

For each directory in the list of directories the method 'find_project_includes' is called. Returns a string containing the paths to the include directories seperated by ':'.

Parameters
project_root The absolute path to the project root directory. directories A list containing the names of the project directories containing include directories.
Returns
string Contains the paths to the include directories seperated by ':'.

◆ run_shiboken()

def shiboken_helper.run_shiboken (   header_file,
  typesystem_file,
  include_paths,
  project_root,
  module_dir,
  use_pyside 
)

Calls shiboken2 to generate the python bindings.

This method calles the shiboken command. The project root path is needed because some pre- viously generated header files, contained in the build directory, need to be added to the include paths. Otherwise clang will throw an error.

Parameters
header_file The absolute path to the header file. typesystem_file The absolute path to the typesystem file. include_paths The include paths. Each path is seperated by ':'. project_root The root directory of the project. module_dir The path to the module directory. use_pyside Whether the bindings shall use pyside extensions.

Variable Documentation

◆ binding_files

def shiboken_helper.binding_files = find_binding_files("./src")

◆ include_dirs

list shiboken_helper.include_dirs = []

◆ include_roots

list shiboken_helper.include_roots = ["datatransfer", "datavisualisation", "imagehandling", "utils"]

◆ includes

string shiboken_helper.includes = seperator.join(include_dirs)

◆ seperator

string shiboken_helper.seperator = ":"