dyn_import — Utilities for dynamically importing Python modules

This module contains somme common utility functions for dynamically importing Python source files as modules.

valjean.dyn_import.split_module_path(file_name)[source]

Split a path to a Python module into a path and a module name.

Parameters:

path (str or path-like object) – A path to a Python file.

Returns:

a (path, name) tuple.

valjean.dyn_import.dyn_import(file_name)[source]

Load a Python module from the given file name.

Note that this function adds the path to file_name to sys.path, so that local imports in file_name work as expected.

Parameters:

file_name (str) – the name of the file containing the module.

Returns:

the loaded module.