diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 11afdbd..1e79e18 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -32,13 +32,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Create Python toolcache directory (macOS) + if: matrix.platform == 'macos' + run: sudo mkdir -p /Users/runner && sudo chown $USER /Users/runner + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install Python build tools - run: pip install --upgrade pip setuptools wheel + run: python -m pip install --upgrade pip setuptools wheel - name: Build sidecar working-directory: python diff --git a/python/build_sidecar.py b/python/build_sidecar.py index 3b855ad..1eb0b0e 100644 --- a/python/build_sidecar.py +++ b/python/build_sidecar.py @@ -68,32 +68,33 @@ def create_venv_and_install(cpu_only: bool) -> Path: print(f"[build] Creating venv at {venv_dir}") subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True) - # Determine pip and python paths inside venv + # Determine python path inside venv — use `python -m pip` instead of + # calling pip directly to avoid permission errors on Windows if sys.platform == "win32": - pip = str(venv_dir / "Scripts" / "pip") python = str(venv_dir / "Scripts" / "python") else: - pip = str(venv_dir / "bin" / "pip") python = str(venv_dir / "bin" / "python") + def pip_install(*args: str) -> None: + subprocess.run([python, "-m", "pip", *args], check=True) + # Upgrade pip - subprocess.run([pip, "install", "--upgrade", "pip"], check=True) + pip_install("install", "--upgrade", "pip", "setuptools", "wheel") # Install torch (CPU-only to avoid bundling ~2GB of CUDA libs) if cpu_only: print("[build] Installing PyTorch (CPU-only)") - subprocess.run( - [pip, "install", "torch", "torchaudio", - "--index-url", "https://download.pytorch.org/whl/cpu"], - check=True, + pip_install( + "install", "torch", "torchaudio", + "--index-url", "https://download.pytorch.org/whl/cpu", ) else: print("[build] Installing PyTorch (default, may include CUDA)") - subprocess.run([pip, "install", "torch", "torchaudio"], check=True) + pip_install("install", "torch", "torchaudio") # Install project and dev deps (includes pyinstaller) print("[build] Installing project dependencies") - subprocess.run([pip, "install", "-e", f"{SCRIPT_DIR}[dev]"], check=True) + pip_install("install", "-e", f"{SCRIPT_DIR}[dev]") return Path(python)