2024-03-05 13:52:37 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2024-03-08 12:54:35 -06:00
|
|
|
__import__("sys").path.append("src") # noqa
|
|
|
|
|
2024-03-08 12:57:04 -06:00
|
|
|
import shutil
|
|
|
|
import sys
|
2024-07-19 14:10:33 -05:00
|
|
|
from pathlib import Path
|
2024-03-08 12:57:04 -06:00
|
|
|
|
2024-03-05 13:52:37 -06:00
|
|
|
import swydd as s
|
|
|
|
|
|
|
|
|
2024-03-08 12:57:04 -06:00
|
|
|
@s.task
|
|
|
|
def bootstrap():
|
|
|
|
"""setup swydd dev environment"""
|
|
|
|
if not shutil.which("pdm"):
|
|
|
|
sys.exit("pdm necessary for swydd development")
|
|
|
|
s.sh("pdm install")
|
|
|
|
s.sh("pdm run pre-commit install")
|
|
|
|
|
|
|
|
|
2024-03-05 13:52:37 -06:00
|
|
|
@s.task
|
2024-03-13 11:09:41 -05:00
|
|
|
@s.option("no-mypy", "skip mypy")
|
|
|
|
def check(no_mypy: bool = False):
|
2024-03-05 13:52:37 -06:00
|
|
|
"""run pre-commit (and mypy)"""
|
|
|
|
s.sh("pre-commit run --all")
|
2024-03-13 11:09:41 -05:00
|
|
|
if not no_mypy:
|
2024-03-05 13:52:37 -06:00
|
|
|
s.sh("mypy src/")
|
|
|
|
|
|
|
|
|
2024-07-19 14:10:33 -05:00
|
|
|
def write_docs_src(tag):
|
|
|
|
src_text = s.Exec(f"git show {tag}:src/swydd/__init__.py", output=True).get().stdout
|
|
|
|
(verdir := (Path(__file__).parent / "docs" / tag)).mkdir(exist_ok=True)
|
|
|
|
(verdir / "swydd.py").write_text(src_text)
|
|
|
|
|
|
|
|
|
|
|
|
@s.task
|
|
|
|
def docs():
|
|
|
|
"""build docs"""
|
|
|
|
p = s.Exec("git tag --list", output=True).get()
|
|
|
|
versions = [line for line in p.stdout.splitlines() if line.startswith("v")]
|
|
|
|
for ver in versions:
|
|
|
|
write_docs_src(ver)
|
|
|
|
shutil.copyfile(
|
|
|
|
Path(__file__).parent / "src" / "swydd" / "__init__.py",
|
|
|
|
Path(__file__).parent / "docs" / "swydd.py",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-03-05 13:52:37 -06:00
|
|
|
s.cli()
|