returnn.util.py_ext_mod_compiler

Python extension module compiler

class returnn.util.py_ext_mod_compiler.PyExtModCompiler(include_paths=(), **kwargs)[source]

Python extension module compiler

Parameters:
  • base_name – base name for the module, e.g. “zero_out”

  • code_version – check for the cache whether to reuse

  • code – the source code itself

  • is_cpp – if False, C is assumed

  • c_macro_defines – e.g. {“TENSORFLOW”: 1}

  • ld_flags – e.g. [“-lblas”]

  • include_paths

  • include_deps – if provided and an existing lib file, we will check if any dependency is newer and we need to recompile. we could also do it automatically via -MD but that seems overkill and too slow.

  • static_version_name – normally, we use …/base_name/hash as the dir but this would use …/base_name/static_version_name.

  • should_cleanup_old_all – whether we should look in the cache dir and check all ops if we can delete some old ones which are older than some limit (self._cleanup_time_limit_days)

  • should_cleanup_old_mydir – whether we should delete our op dir before we compile there.

  • log_stream – file stream for print statements

  • verbose – be slightly more verbose

CacheDirName = 'returnn_py_ext_mod_cache'[source]
load_py_module()[source]
Returns:

Python extension module