diff --git a/pyproject.toml b/pyproject.toml index c6d98df..1089966 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,5 @@ install-cpu = { composite = ["install-base", "install-cpu"] } install-gpu = { composite = ["install-base", "install-gpu"] } lock-base = { shell = "cd packages/nonebot-plugin-nailongremove-base && pdm lock && cd ../.." } + +pub-all = { call = "scripts.pub_all:main" } diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/pub_all.py b/scripts/pub_all.py new file mode 100644 index 0000000..d997fda --- /dev/null +++ b/scripts/pub_all.py @@ -0,0 +1,10 @@ +from .utils import PACKAGES_PATH, system_no_fail + + +def main(): + for p in PACKAGES_PATH.iterdir(): + system_no_fail("pdm", "publish", cwd=p) + + +if __name__ == "__main__": + main() diff --git a/scripts/render.py b/scripts/render.py index 1bcd0f5..22de581 100644 --- a/scripts/render.py +++ b/scripts/render.py @@ -7,8 +7,8 @@ import httpx import tomllib from packaging.version import Version -ROOT_PATH = Path(__file__).parent.parent -PACKAGES_PATH = ROOT_PATH / "packages" +from .utils import PACKAGES_PATH + SUFFIX = ".template.toml" TORCH_BASE = "https://download.pytorch.org" TORCH_INDEX = f"{TORCH_BASE}/whl/cu124" diff --git a/scripts/utils.py b/scripts/utils.py new file mode 100644 index 0000000..b096c9b --- /dev/null +++ b/scripts/utils.py @@ -0,0 +1,18 @@ +from pathlib import Path +from subprocess import run +from typing import Any + +ROOT_PATH = Path(__file__).parent.parent +PACKAGES_PATH = ROOT_PATH / "packages" + + +def system(*args: str, **kwargs: Any): + kwargs.setdefault("cwd", str(ROOT_PATH)) + r = run(args, **kwargs) # noqa: S603 + return r.returncode + + +def system_no_fail(*args: str, **kwargs: Any): + c = system(*args, **kwargs) + if c: + raise RuntimeError(f"command {args} failed with code {c}")