okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
66bc88907
main
1#!/bin/sh 2# Strata for Linux: the first run installs everything and starts the model; later runs just start it. 3# Needs only an NVIDIA driver (or, for an AMD Radeon card, the kernel's amdgpu driver: see docs/AMD_HIP.md). 4# Python (with venv) is installed through apt/dnf if it is missing (asks for sudo). 5# NixOS (or STRATA_UV=1) with uv installed: uv makes the project venv; every other Linux uses the standard venv. 6cd " $( dirname " $ 0" ) " ||exit 1 7# A bundled Python runtime (the python/ folder of the terminal archive) is used when it is there: nothing to find, 8# install or download. update.sh runs this file, so it uses it too. 9if [ -x python/bin/python3 ];then 10PYTHONNOUSERSITE =1;export PYTHONNOUSERSITE 11unset PYTHONHOME PYTHONPATH 12exec python/bin/python3 setup.py" $ @" 13fi 14# Python 3.10+ that can make a venv WITH pip: Debian/Ubuntu ship `venv` without `ensurepip` (that is the separate 15# python3-venv package), and a venv made without it has no pip 16ok_py () {" $ 1 " -c 'import sys, venv, ensurepip; sys.exit(0 if sys.version_info >= (3, 10) else 1)' 2 > /dev/null; } 17# a .venv from an earlier run that failed half-way has a python but no pip: start it again 18if [ -x .venv/bin/python ]&& !.venv/bin/python -m pip--version > /dev/null2 >&1;then 19rm -rf .venv 20fi 21if [ ! -x .venv/bin/python ];then 22# uv's own Python only on NixOS (its Python cannot load pip wheels' libraries), or when asked: STRATA_UV=1. 23# Everywhere else the standard venv stays the default (#662: a silent toolchain change was not wanted). 24UV ="" 25if [" ${ STRATA_UV :-} " ="1" ] ||grep -qi '^ID=nixos' /etc/os-release2 > /dev/null;then 26UV =" $( command -v uv 2 > /dev/null || true ) " 27fi 28PY ="" 29if [ -n" $ UV " ];then 30# Prefer uv's own interpreter: unlike Nix's Python, it works naturally with pip wheels using dlopen. 31PY =3.12 32else 33for c in python3 python;do 34if command -v $ c > /dev/null2 >&1&& ok_py $ c ;then 35PY =$ c ;break 36fi 37done 38fi 39# macOS: the system Python is 3.9; a standalone Python 3.12 goes into .python (no sudo, no Homebrew; pinned) 40if [ -z" $ PY " ]&& [" $( uname -s ) " = Darwin ];then 41if [ ! -x .python/python/bin/python3 ];then 42PBS ="https://github.com/astral-sh/python-build-standalone/releases/download/20261009/cpython-3.12.15%2B20261009-aarch64-apple-darwin-install_only.tar.gz" 43echo "Python 3.10+ is needed; downloading a standalone Python 3.12 into .python (25 MB) ..." 44mkdir -p .python&& curl -fL --retry 3-o .python/python.tar.gz" $ PBS " || {echo "could not download Python" ;exit 1; } 45if [" $( shasum -a 256 .python/python.tar.gz | cut -d " " -f1 ) " !="83dcb04777c798bd95f3687acf9ae84b09860272ee6bdfb05be8bcf9447f75b8" ];then 46rm -f .python/python.tar.gz;echo "the Python download does not match its pinned SHA-256" ;exit 1 47fi 48tar xzf .python/python.tar.gz-C .python&& rm -f .python/python.tar.gz 49fi 50PY =.python/python/bin/python3 51fi 52if [ -z" $ PY " ];then 53echo "Python 3.10+ with venv is needed; installing it (sudo will ask for your password) ..." 54if command -v apt-get> /dev/null2 >&1;then 55sudo apt-get update&& sudo apt-get install-y python3 python3-venv python3-pip 56elif command -v dnf> /dev/null2 >&1;then 57sudo dnf install-y python3 python3-pip 58elif command -v pacman> /dev/null2 >&1;then 59sudo pacman-S --noconfirm python python-pip 60fi 61PY =python3 62if !ok_py $ PY ;then 63echo "Please install Python 3.10 or newer with venv (Ubuntu/Debian: sudo apt install python3-venv), then run" 64echo "./setup.sh again. On NixOS, add uv to environment.systemPackages." 65exit 1 66fi 67fi 68if [ -n" $ UV " ];then 69# Force an uv-managed interpreter: pip wheels may dlopen libraries outside the Nix store. 70" $ UV " venv--managed-python --seed --python " $ PY " .venv || {echo "Could not create the uv environment in .venv." ;exit 1; } 71else 72# a private environment inside this folder (system Python stays untouched; newer distros refuse global pip) 73$ PY -m venv .venv || {rm -rf .venv;echo "could not create .venv: sudo apt install python3-venv" ;exit 1; } 74fi 75fi 76exec .venv/bin/python setup.py" $ @"