Caffe2 - Python API
A deep learning, cross platform ML framework
module_loader.py
1 import sys
2 
3 
4 def import_module(name, path):
5  if sys.version_info >= (3, 5):
6  import importlib.util
7  spec = importlib.util.spec_from_file_location(name, path)
8  module = importlib.util.module_from_spec(spec)
9  spec.loader.exec_module(module)
10  return module
11  elif sys.version_info >= (3, 0):
12  from importlib.machinery import SourceFileLoader
13  return SourceFileLoader(name, path).load_module()
14  else:
15  import imp
16  return imp.load_source(name, path)