nixpkgs/pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch

31 lines
902 B
Diff

diff --git a/unsloth_zoo/__init__.py b/unsloth_zoo/__init__.py
index a629854..06014b1 100644
--- a/unsloth_zoo/__init__.py
+++ b/unsloth_zoo/__init__.py
@@ -17,8 +17,6 @@
__version__ = "2025.5.11"
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
@@ -28,13 +26,14 @@ 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()
import os
-if not ("UNSLOTH_IS_PRESENT" in os.environ):
- raise ImportError("Please install Unsloth via `pip install unsloth`!")
pass
try: