diff --git a/start.bat b/start.bat index 2f14878..acbee45 100644 --- a/start.bat +++ b/start.bat @@ -5,13 +5,27 @@ cd "%~dp0" +where uv >nul 2>&1 +if %errorlevel% equ 0 ( + echo "HAS UV" + set HAS_UV=1 +) else ( + set HAS_UV=0 +) + :: Don't create a venv if a conda environment is active if exist "%CONDA_PREFIX%" ( echo It looks like you're in a conda environment. Skipping venv check. ) else ( if not exist "venv\" ( echo Venv doesn't exist! Creating one for you. - python -m venv venv + + if %HAS_UV% equ 1 ( + echo "It looks like you're using uv. Running appropriate commands." + uv venv venv -p 3.12 + ) else ( + python -m venv venv + ) if exist "start_options.json" ( echo Removing old start_options.json diff --git a/start.py b/start.py index 2d30454..6b41bc7 100644 --- a/start.py +++ b/start.py @@ -9,7 +9,13 @@ import subprocess import sys import traceback from shutil import copyfile +from typing import List +has_uv = subprocess.run( + ["uv", "--version"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL +).returncode == 0 start_options = {} @@ -151,8 +157,14 @@ def migrate_start_options(start_options: dict): return migrated +def run_pip(command: List[str]): + if has_uv: + command.insert(0, "uv") + + subprocess.run(command) + + if __name__ == "__main__": - subprocess.run(["pip", "-V"]) # Create an argparser and add extra startup script args # Try creating a full argparser if pydantic is installed @@ -174,6 +186,10 @@ if __name__ == "__main__": add_start_args(parser) args, _ = parser.parse_known_args() + + # Log pip version + run_pip(["pip", "-V"]) + script_ext = "bat" if platform.system() == "Windows" else "sh" do_start_options_write = False @@ -224,7 +240,7 @@ if __name__ == "__main__": # pip install .[features] print(f"Running install command: {' '.join(install_command)}") - subprocess.run(install_command) + run_pip(install_command) print() if first_run: diff --git a/start.sh b/start.sh index 5c4a7b3..2374e4e 100755 --- a/start.sh +++ b/start.sh @@ -2,12 +2,24 @@ cd "$(dirname "$0")" || exit +if command -v uv >/dev/null 2>&1; then + HAS_UV=1 +else + HAS_UV=0 +fi + if [ -n "$CONDA_PREFIX" ]; then echo "It looks like you're in a conda environment. Skipping venv check." else if [ ! -d "venv" ]; then echo "Venv doesn't exist! Creating one for you." - python3 -m venv venv + + if [ "$HAS_UV" -eq 1 ]; then + echo "It looks like you're using uv. Running appropriate commands." + uv venv venv -p 3.12 + else + python3 -m venv venv + fi if [ -f "start_options.json" ]; then echo "Removing old start_options.json"