Wrapping and Linking

Note that codepy accesses a file called .aksetup-defaults.py in your home directory (mind the dot!) and /etc/aksetup-defaults.py to determine a few configuration values, notably:

  • BOOST_INC_DIR
  • BOOST_LIB_DIR
  • BOOST_PYTHON_LIBNAME
  • BOOST_COMPILER (used in the default libnames)
  • CUDA_ROOT

For lack of better documentation at this moment, please see this wiki page.

codepy.jit – Compilation and Linking of C Source Code

codepy.jit.guess_toolchain()
codepy.jit.extension_file_from_string(toolchain, ext_file, source_string, source_name='module.cpp', debug=False)

Using toolchain, build the extension file named ext_file from the source code in source_string, which is saved to a temporary file named source_name. Raise CompileError in case of error.

If debug is True, show commands involved in the build.

codepy.jit.extension_from_string(toolchain, name, source_string, source_name='module.cpp', cache_dir=None, debug=False, wait_on_error=None, debug_recompile=True)

Return a reference to the extension module name, which can be built from the source code in source_string if necessary. Raise CompileError in case of error.

Compiled code is cached in cache_dir and available immediately if it has been compiled at some point in the past. Compiler and Python API versions as well as versions of include files are taken into account when examining the cache. If cache_dir is None, a default location is assumed. If it is False, no caching is performed. Proper locking is performed on the cache directory. Simultaneous use of the cache by multiple processes works as expected, but may lead to delays because of locking.

The code in source_string will be saved to a temporary file named source_name if it needs to be compiled.

If debug is True, commands involved in the build are printed.

If wait_on_error is True, the full path name of the temporary in which a CompileError occurred is shown and the user is expected to press a key before the temporary file gets deleted. If wait_on_error is None, it is taken to be the same as debug.

If debug_recompile, messages are printed indicating whether a recompilation is taking place.

Errors

exception codepy.jit.CompileError

codepy.bpl – Support for Boost.Python

Convenience interface for using CodePy with Boost.Python.

class codepy.bpl.BoostPythonModule(name='module', max_arity=None, use_private_namespace=True)
add_codepy_include()
add_function(func)

Add a function to be exposed. func is expected to be a cgen.FunctionBody.

add_raw_function(func)

Add a function to be exposed using boost::python::raw_function. func is expected to be a cgen.FunctionBody.

add_raw_function_include()
add_struct(struct, py_name=None, py_member_name_transform=<function <lambda> at 0x505fc08>, by_value_members=set([]))
add_to_init(body)

Add the blocks or statements contained in the iterable body to the module initialization function.

add_to_module(body)

Add the cgen.Generable instances in the iterable body to the body of the module self.

add_to_preamble(pa)
compile(toolchain, **kwargs)

Return the extension module generated from the code described by self. If necessary, build the code using toolchain with codepy.jit.extension_from_string(). Any keyword arguments accept by that latter function may be passed in kwargs.

expose_vector_type(name, py_name=None)
generate()

Generate (i.e. yield) the source code of the module line-by-line.

Table Of Contents

Previous topic

Welcome to CodePy’s documentation!

Next topic

License

This Page