perf/pipeline-improvements #2
@@ -32,13 +32,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Install Python build tools
|
- name: Install Python build tools
|
||||||
run: pip install --upgrade pip setuptools wheel
|
run: python -m pip install --upgrade pip setuptools wheel
|
||||||
|
|
||||||
- name: Build sidecar
|
- name: Build sidecar
|
||||||
working-directory: python
|
working-directory: python
|
||||||
|
|||||||
@@ -68,32 +68,33 @@ def create_venv_and_install(cpu_only: bool) -> Path:
|
|||||||
print(f"[build] Creating venv at {venv_dir}")
|
print(f"[build] Creating venv at {venv_dir}")
|
||||||
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
|
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":
|
if sys.platform == "win32":
|
||||||
pip = str(venv_dir / "Scripts" / "pip")
|
|
||||||
python = str(venv_dir / "Scripts" / "python")
|
python = str(venv_dir / "Scripts" / "python")
|
||||||
else:
|
else:
|
||||||
pip = str(venv_dir / "bin" / "pip")
|
|
||||||
python = str(venv_dir / "bin" / "python")
|
python = str(venv_dir / "bin" / "python")
|
||||||
|
|
||||||
|
def pip_install(*args: str) -> None:
|
||||||
|
subprocess.run([python, "-m", "pip", *args], check=True)
|
||||||
|
|
||||||
# Upgrade pip
|
# 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)
|
# Install torch (CPU-only to avoid bundling ~2GB of CUDA libs)
|
||||||
if cpu_only:
|
if cpu_only:
|
||||||
print("[build] Installing PyTorch (CPU-only)")
|
print("[build] Installing PyTorch (CPU-only)")
|
||||||
subprocess.run(
|
pip_install(
|
||||||
[pip, "install", "torch", "torchaudio",
|
"install", "torch", "torchaudio",
|
||||||
"--index-url", "https://download.pytorch.org/whl/cpu"],
|
"--index-url", "https://download.pytorch.org/whl/cpu",
|
||||||
check=True,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("[build] Installing PyTorch (default, may include CUDA)")
|
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)
|
# Install project and dev deps (includes pyinstaller)
|
||||||
print("[build] Installing project dependencies")
|
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)
|
return Path(python)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user