From 35e1017e3ea0a3ad9ec28c9b447200a70a65c0ae Mon Sep 17 00:00:00 2001 From: Akiba Date: Fri, 16 Dec 2022 20:43:09 +0800 Subject: fix: xformers --- modules/import_hook.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/import_hook.py (limited to 'modules/import_hook.py') diff --git a/modules/import_hook.py b/modules/import_hook.py new file mode 100644 index 00000000..eb10e4fd --- /dev/null +++ b/modules/import_hook.py @@ -0,0 +1,18 @@ +import builtins +import sys + +old_import = builtins.__import__ +IMPORT_BLACKLIST = [] + + +if "xformers" not in "".join(sys.argv): + IMPORT_BLACKLIST.append("xformers") + + +def import_hook(*args, **kwargs): + if args[0] in IMPORT_BLACKLIST: + raise ImportError("Import of %s is blacklisted" % args[0]) + return old_import(*args, **kwargs) + + +builtins.__import__ = import_hook -- cgit v1.2.1