2024-03-05 13:52:37 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2024-07-22 15:17:58 -05:00
|
|
|
__import__("sys").path.append("src")
|
2024-03-08 12:54:35 -06:00
|
|
|
|
2024-03-08 12:57:04 -06:00
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
|
2024-10-22 11:53:19 -05:00
|
|
|
from swydd import asset, cli, get, option, proc, sub, task
|
2024-03-05 13:52:37 -06:00
|
|
|
|
|
|
|
|
2024-07-22 15:17:58 -05:00
|
|
|
@task
|
2024-03-08 12:57:04 -06:00
|
|
|
def bootstrap():
|
|
|
|
"""setup swydd dev environment"""
|
2024-07-22 15:17:58 -05:00
|
|
|
if not shutil.which("uv"):
|
|
|
|
sys.exit("uv necessary for swydd development")
|
2024-10-22 11:53:19 -05:00
|
|
|
(proc("uv sync").then("uv run pre-commit install").run())
|
2024-03-08 12:57:04 -06:00
|
|
|
|
|
|
|
|
2024-07-22 15:17:58 -05:00
|
|
|
@task
|
|
|
|
def tests():
|
|
|
|
"""run pytest"""
|
2024-10-22 11:53:19 -05:00
|
|
|
sub("uv run pytest")
|
2024-03-05 13:52:37 -06:00
|
|
|
|
|
|
|
|
2024-07-22 15:17:58 -05:00
|
|
|
@task
|
|
|
|
@option("skip-mypy", "skip mypy")
|
|
|
|
def check(skip_mypy: bool = False):
|
|
|
|
"""run pre-commit (and mypy)"""
|
2024-10-22 11:53:19 -05:00
|
|
|
sub("uv run pre-commit run --all")
|
2024-07-22 15:17:58 -05:00
|
|
|
if not skip_mypy:
|
2024-10-22 11:53:19 -05:00
|
|
|
sub("uv run mypy src/")
|
2024-07-19 14:10:33 -05:00
|
|
|
|
|
|
|
|
2024-10-20 13:05:37 -05:00
|
|
|
@task
|
|
|
|
def docs():
|
|
|
|
"""build docs"""
|
2024-10-22 11:53:19 -05:00
|
|
|
tags = get("git tag --list")
|
2024-07-22 15:17:58 -05:00
|
|
|
versions = [line for line in tags.splitlines() if line.startswith("v")]
|
|
|
|
for tag in versions:
|
2024-10-22 11:53:19 -05:00
|
|
|
(
|
|
|
|
asset(f"docs/{tag}/swydd.py").write(
|
|
|
|
get(f"git show {tag}:src/swydd/__init__.py")
|
|
|
|
)
|
2024-07-22 15:17:58 -05:00
|
|
|
)
|
2024-10-22 11:53:19 -05:00
|
|
|
asset("docs/swydd.py").write(asset("src/swydd/__init__.py"))
|
2024-07-19 14:10:33 -05:00
|
|
|
|
|
|
|
|
2024-10-22 13:26:25 -05:00
|
|
|
cli("check")
|