Add package data for GPU rent and update CLI documentation

- Added package data configuration for the 'gpu_rent' package in pyproject.toml.
- Updated README.md to include usage instructions for Windows and Unix launchers.
- Enhanced CLI documentation in cli.md to reflect new commands and their functionalities.
- Revised setup.md to clarify installation steps and environment setup.
- Improved error handling and command descriptions in the CLI implementation.
- Added new functions for model version handling and flavor resolution in the codebase.
- Updated state management to include additional properties for better tracking.
This commit is contained in:
Leonid Pershin
2026-08-21 03:06:51 +03:00
parent 167d07a733
commit 615cf81493
34 changed files with 2733 additions and 117 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Linux / macOS / Git Bash: venv + pip + python -m gpu_rent
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
ok_py() {
local exe="$1"
shift || true
command -v "$exe" >/dev/null 2>&1 || return 1
"$exe" "$@" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' >/dev/null 2>&1
}
PY=()
if ok_py python3.12; then
PY=(python3.12)
elif ok_py python3.11; then
PY=(python3.11)
elif ok_py python3; then
PY=(python3)
elif ok_py python; then
PY=(python)
elif ok_py py -3.12; then
PY=(py -3.12)
elif ok_py py -3.11; then
PY=(py -3.11)
else
echo "gpu-rent: нужен Python 3.11+. Ubuntu: sudo apt install python3 python3-venv python3-pip" >&2
exit 1
fi
if [[ -x "$ROOT/.venv/Scripts/python.exe" ]]; then
VENV_PY="$ROOT/.venv/Scripts/python.exe"
elif [[ -x "$ROOT/.venv/bin/python" ]]; then
VENV_PY="$ROOT/.venv/bin/python"
else
echo "gpu-rent: создаю .venv"
"${PY[@]}" -m venv "$ROOT/.venv"
if [[ -x "$ROOT/.venv/Scripts/python.exe" ]]; then
VENV_PY="$ROOT/.venv/Scripts/python.exe"
else
VENV_PY="$ROOT/.venv/bin/python"
fi
fi
STAMP="$ROOT/.venv/.gpu-rent-installed"
if [[ ! -f "$STAMP" || "$ROOT/pyproject.toml" -nt "$STAMP" ]]; then
echo "gpu-rent: ставлю пакет в .venv"
"$VENV_PY" -m pip install -U pip
"$VENV_PY" -m pip install -e "$ROOT"
date -u +"%Y-%m-%dT%H:%M:%SZ" >"$STAMP"
fi
GPU_HOME="${HOME}/.gpu-rent"
if [[ ! -f "$GPU_HOME/.env" && -f "$ROOT/env.example" ]]; then
mkdir -p "$GPU_HOME"
cp "$ROOT/env.example" "$GPU_HOME/.env"
echo "gpu-rent: created $GPU_HOME/.env - fill OS_* (see docs/setup.md)"
fi
exec "$VENV_PY" -m gpu_rent "$@"