Files
nixpkgs/pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch
2025-08-26 11:57:04 +02:00

30 lines
870 B
Diff

diff --git a/unsloth_zoo/__init__.py b/unsloth_zoo/__init__.py
index 2332907..2eed5e9 100644
--- a/unsloth_zoo/__init__.py
+++ b/unsloth_zoo/__init__.py
@@ -64,8 +64,6 @@ pass
from importlib.util import find_spec
-if find_spec("unsloth") is None:
- raise ImportError("Please install Unsloth via `pip install unsloth`!")
pass
del find_spec
@@ -75,12 +73,13 @@ def get_device_type():
return "cuda"
elif hasattr(torch, "xpu") and torch.xpu.is_available():
return "xpu"
+ else:
+ # Allow import during tests
+ return None
raise NotImplementedError("Unsloth currently only works on NVIDIA GPUs and Intel GPUs.")
pass
DEVICE_TYPE : str = get_device_type()
-if not ("UNSLOTH_IS_PRESENT" in os.environ):
- raise ImportError("Please install Unsloth via `pip install unsloth`!")
pass
try: