forked from cleveragents/cleveragents-core
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Synchronize dependencies and update lock files."""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def run_command(cmd: list[str], check: bool = True) -> subprocess.CompletedProcess:
|
|
"""Run a command and return the result."""
|
|
print(f"Running: {' '.join(cmd)}")
|
|
return subprocess.run(cmd, check=check, capture_output=True, text=True)
|
|
|
|
|
|
def main():
|
|
"""Sync dependencies and create/update lock file."""
|
|
project_root = Path(__file__).parent.parent
|
|
|
|
# Update pip
|
|
print("Updating pip...")
|
|
run_command([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
|
|
|
|
# Generate requirements files for each dependency group
|
|
print("Generating requirements files...")
|
|
|
|
# Base dependencies
|
|
result = run_command(
|
|
[sys.executable, "-m", "pip", "freeze", "--exclude-editable"], check=False
|
|
)
|
|
|
|
if result.returncode == 0:
|
|
requirements_file = project_root / "requirements.txt"
|
|
requirements_file.write_text(result.stdout)
|
|
print(f"Written base requirements to {requirements_file}")
|
|
|
|
# Dev dependencies
|
|
requirements_dev = project_root / "requirements-dev.txt"
|
|
requirements_dev.write_text(
|
|
"# Development dependencies\n"
|
|
"-r requirements.txt\n"
|
|
"ruff>=0.1.0\n"
|
|
"pyright>=1.1.350\n"
|
|
"types-pyyaml>=6.0.0\n"
|
|
"types-aiofiles>=23.0.0\n"
|
|
"pytest>=8.0.0\n"
|
|
"pytest-asyncio>=0.23.0\n"
|
|
"pytest-cov>=4.1.0\n"
|
|
)
|
|
print(f"Written dev requirements to {requirements_dev}")
|
|
|
|
print("Dependency sync complete!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|