piper-sample-generator/script/setup

33 lines
900 B
Text
Raw Permalink Normal View History

2023-10-06 12:10:43 -05:00
#!/usr/bin/env python3
2025-08-29 12:19:25 -05:00
import argparse
2023-10-06 12:10:43 -05:00
import subprocess
import venv
from pathlib import Path
_DIR = Path(__file__).parent
_PROGRAM_DIR = _DIR.parent
_VENV_DIR = _PROGRAM_DIR / ".venv"
2025-08-29 12:19:25 -05:00
parser = argparse.ArgumentParser()
parser.add_argument("--dev", action="store_true", help="Install dev requirements")
args = parser.parse_args()
2023-10-06 12:10:43 -05:00
# Create virtual environment
builder = venv.EnvBuilder(with_pip=True)
context = builder.ensure_directories(_VENV_DIR)
builder.create(_VENV_DIR)
# Upgrade dependencies
pip = [context.env_exe, "-m", "pip"]
subprocess.check_call(pip + ["install", "--upgrade", "pip"])
subprocess.check_call(pip + ["install", "--upgrade", "setuptools", "wheel"])
# Install requirements
2025-08-29 12:19:25 -05:00
subprocess.check_call(pip + ["install", "-e", str(_PROGRAM_DIR)])
if args.dev:
# Install dev requirements
subprocess.check_call(
pip + ["install", "-e", f"{_PROGRAM_DIR}[dev]"]
)