Package instant :: Module build
[hide private]
[frames] | no frames]

Module build

source code

This module contains the main part of Instant, the build_module function.

Functions [hide private]
 
assert_is_str(x) source code
 
assert_is_bool(x) source code
 
assert_is_str_list(x) source code
 
strip_strings(x) source code
 
arg_strings(x) source code
 
copy_files(source, dest, files)
Copy a list of files from a source directory to a destination directory.
source code
 
recompile(modulename, module_path, setup_name, new_compilation_checksum)
Recompile module if the new checksum is different from the one in the checksum file in the module directory.
source code
 
copy_to_cache(module_path, cache_dir, modulename)
Copy module directory to cache.
source code
 
build_module(modulename=None, source_directory='.', code='', init_code='', additional_definitions='', additional_declarations='', sources=[], wrap_headers=[], local_headers=[], system_headers=[], include_dirs=['.'], library_dirs=[], libraries=[], swigargs=['-c++', '-fcompact', '-O', '-I.', '-small'], cppargs=['-O2'], lddargs=[], object_files=[], arrays=[], generate_interface=True, generate_setup=True, signature=None, cache_dir=None)
Generate and compile a module from C/C++ code using SWIG.
source code
Function Details [hide private]

copy_files(source, dest, files)

source code 
Copy a list of files from a source directory to a destination directory. This may seem a bit complicated, but a lot of this code is error checking.

build_module(modulename=None, source_directory='.', code='', init_code='', additional_definitions='', additional_declarations='', sources=[], wrap_headers=[], local_headers=[], system_headers=[], include_dirs=['.'], library_dirs=[], libraries=[], swigargs=['-c++', '-fcompact', '-O', '-I.', '-small'], cppargs=['-O2'], lddargs=[], object_files=[], arrays=[], generate_interface=True, generate_setup=True, signature=None, cache_dir=None)

source code 
Generate and compile a module from C/C++ code using SWIG.

Arguments:

The keyword arguments are as follows:
  • modulename:
    • The name you want for the module. If specified, the module will not be cached. If missing, a name will be constructed based on a checksum of the other arguments, and the module will be placed in the global cache. String.
  • source_directory:
    • The directory where used supplied files reside.
  • code:
    • A string containing C or C++ code to be compiled and wrapped.
  • init_code:
    • Code that should be executed when the instant module is imported.
  • additional_definitions:
    • A list of additional definitions (typically needed for inheritance).
  • additional_declarations:
    • A list of additional declarations (typically needed for inheritance).
  • sources:
    • A list of source files to compile and link with the module.
  • wrap_headers:
    • A list of local header files that should be wrapped by SWIG.
  • local_headers:
    • A list of local header files required to compile the wrapped code.
  • system_headers:
    • A list of system header files required to compile the wrapped code.
  • include_dirs:
    • A list of directories to search for header files.
  • library_dirs:
    • A list of directories to search for libraries (-l).
  • libraries:
    • A list of libraries needed by the instant module.
  • swigargs:
    • List of arguments to swig, e.g. ["-lpointers.i"] to include the SWIG pointers.i library.
  • cppargs:
    • List of arguments to the compiler, e.g. ["-D", "-U"].
  • lddargs:
    • List of arguments to the linker, e.g. ["-D", "-U"].
  • object_files:
    • If you want to compile the files yourself. TODO: Not yet supported.
  • arrays:
    • A list of the C arrays to be made from NumPy arrays. FIXME: Describe this correctly. Tests pass arrays of arrays of strings.
  • generate_interface:
    • A bool to indicate if you want to generate the interface files.
  • generate_setup:
    • A bool to indicate if you want to generate the setup.py file.
  • signature:
    • A signature string to identify the form instead of the source code.
  • cache_dir:
    • A directory to look for cached modules and place new ones. If missing, a default directory is used. Note that the module will not be cached if modulename is specified. The cache directory should not be used for anything else.