fix
This commit is contained in:
37
scripts/unsloth_install.py
Normal file → Executable file
37
scripts/unsloth_install.py
Normal file → Executable file
@@ -1,7 +1,8 @@
|
||||
"""Emit the uv commands needed to install Unsloth without touching torch."""
|
||||
"""Emit the install commands for Unsloth without altering torch."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import sys
|
||||
from shlex import quote
|
||||
|
||||
@@ -14,16 +15,34 @@ from packaging.version import Version as V
|
||||
|
||||
MIN_TORCH = V("2.6.0")
|
||||
|
||||
python_version = V(torch.__version__.split("+")[0])
|
||||
if python_version < MIN_TORCH:
|
||||
if V(torch.__version__.split("+")[0]) < MIN_TORCH:
|
||||
raise RuntimeError(
|
||||
f"Torch {torch.__version__} detected, but Unsloth requires >= {MIN_TORCH}."
|
||||
)
|
||||
|
||||
python_path = quote(sys.executable)
|
||||
commands = (
|
||||
f"uv pip install --python {python_path} --no-deps unsloth-zoo==2025.9.12 && "
|
||||
f'uv pip install --python {python_path} --no-deps "unsloth[huggingface]==2025.9.9"'
|
||||
)
|
||||
USE_UV_FLAG = "--uv" in sys.argv[1:]
|
||||
USE_PIP_FLAG = "--pip" in sys.argv[1:]
|
||||
|
||||
print(commands)
|
||||
if USE_UV_FLAG and USE_PIP_FLAG:
|
||||
raise SystemExit("Specify only one of --uv or --pip")
|
||||
|
||||
if USE_PIP_FLAG:
|
||||
use_uv = False
|
||||
elif USE_UV_FLAG:
|
||||
use_uv = True
|
||||
else:
|
||||
use_uv = shutil.which("uv") is not None
|
||||
|
||||
python_exe = quote(sys.executable or shutil.which("python3") or "python")
|
||||
|
||||
if use_uv:
|
||||
installer = "uv pip install --system --no-deps"
|
||||
else:
|
||||
installer = f"{python_exe} -m pip install --no-deps"
|
||||
|
||||
commands = [
|
||||
f"{installer} unsloth-zoo==2025.9.12",
|
||||
f'{installer} "unsloth[huggingface]==2025.9.9"',
|
||||
]
|
||||
|
||||
print(" && ".join(commands))
|
||||
|
||||
Reference in New Issue
Block a user