import importlib.util
import sys
spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py")
foo = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = foo
spec.loader.exec_module(foo)
foo.MyClass()
#: References:
#: - https://stackoverflow.com/questions/67631/how-do-i-import-a-module-given-the-full-path/67692#67692
#: - https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
#: - https://stackoverflow.com/questions/67631/how-do-i-import-a-module-given-the-full-path/50395128#50395128
#: - https://stackoverflow.com/questions/69005998/how-can-i-make-python-import-util-module-from-spec-work-more-like-import/69123260#69123260
#: - https://blog.gtmanfred.com/talks/plugins/pages/50-loading-application.html#import-a-source-file-directly