fix: xformers use importlib
This commit is contained in:
parent
35e1017e3e
commit
13e0295ab6
|
@ -1,18 +1,5 @@
|
||||||
import builtins
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
old_import = builtins.__import__
|
|
||||||
IMPORT_BLACKLIST = []
|
|
||||||
|
|
||||||
|
|
||||||
if "xformers" not in "".join(sys.argv):
|
if "xformers" not in "".join(sys.argv):
|
||||||
IMPORT_BLACKLIST.append("xformers")
|
sys.modules["xformers"] = None
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user