This commit is contained in:
Dan Saunders
2025-10-02 10:57:09 -04:00
parent 0250e5f87c
commit f912d1bb97
4 changed files with 39 additions and 38 deletions

View File

@@ -1,40 +1,22 @@
"""Emit the install command for the Axolotl cut-cross-entropy fork."""
"""Print the pip command to install Axolotl's cut_cross_entropy fork."""
from __future__ import annotations
import shutil
import sys
try:
import torch
except ImportError as exc: # pragma: no cover - defensive
except ImportError as exc: # pragma: no cover
raise ImportError("Install torch via `pip install torch`") from exc
from packaging.version import Version as V
USE_UV_FLAG = "--uv" in sys.argv[1:]
USE_PIP_FLAG = "--pip" in sys.argv[1:]
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
if V(torch.__version__) < V("2.4.0"):
if V(torch.__version__.split("+")[0]) < V("2.6.0"):
print("")
sys.exit(0)
# No need to uninstall in CI runs; the environment is fresh. Just emit the install command.
installer = "uv pip install --system" if use_uv else "pip install"
command = (
f"{installer} "
print(
"python -m pip install "
'"cut-cross-entropy[transformers] '
'@ git+https://github.com/axolotl-ai-cloud/ml-cross-entropy.git@147ea28"'
)
print(command)