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
tosys.path
, so that local imports infile_name
work as expected.- Parameters:
file_name (str) – the name of the file containing the module.
- Returns:
the loaded module.