instant.build

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``'``]`, swig_include_dirs=`[``]`, 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

Variables | [hide private]
| __package__ = ``'``instant``'``

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``'``]`, swig_include_dirs=`[``]`, 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 user supplied files reside. The files given in sources, wrap_headers, and local_headers are expected to exist in this directory. String. code: A string containing C or C++ code to be compiled and wrapped. String. init_code: Code that should be executed when the Instant module is imported. This code is inserted in the SWIG interface file, and is used for instance for calling `import_array()` used for the initialization of NumPy arrays. String. additional_definitions: Additional definitions (typically needed for inheritance) for interface file. These definitions should be given as triple-quoted strings in the case they span multiple lines, and are placed both in the initial block for C/C++ code (`%{,%}`-block), and the main section of the interface file. String. additional_declarations: Additional declarations (typically needed for inheritance) for interface file. These declarations should be given as triple-quoted strings in the case they span multiple lines, and are plaves in the main section of the interface file. String. sources: Source files to compile and link with the module. These files are compiled togehter with the SWIG-generated wrapper file into the final library file. Should reside in directory specified in source_directory. List of strings. wrap_headers: Local header files that should be wrapped by SWIG. The files specified will be included both in the initial block for C/C++ code (with a C directive) and in the main section of the interface file (with a SWIG directive). Should reside in directory specified in source_directory. List of strings. local_headers: Local header files required to compile the wrapped code. The files specified will be included in the initial block for C/C++ code (with a C directive). Should reside in directory specified in source_directory. List of strings. system_headers: System header files required to compile the wrapped code. The files specified will be included in the initial block for C/C++ code (with a C directive). List of strings. include_dirs: Directories to search for header files for building the extension module. Needs to be absolute path names. List of strings. library_dirs: Directories to search for libraries (`-l`) for building the extension module. Needs to be absolute paths. List of strings. libraries: Libraries needed by the Instant module. The libraries will be linked in from the shared object file. The initial `-l` is added automatically. List of strings. swigargs: List of arguments to swig, e.g. `["-lpointers.i"]` to include the SWIG pointers.i library. swig_include_dirs: A list of directories to include in the 'swig' command. cppargs: List of arguments to the compiler, e.g. `["-Wall", "-fopenmp"]`. lddargs: List of arguments to the linker, e.g. `["-E", "-U"]`. object_files: If you want to compile the files yourself. TODO: Not yet supported. arrays: A nested list describing the C arrays to be made from NumPy arrays. If the NumPy array is 1D, the inner list should contain strings with the variable names for length of the array and the array itself. If the NumPy array is a matrix or a tensor, the inner list should contain strings with variable names for the number of dimensions, the length in each dimension, and the array itself, respectively. 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.