mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 18:44:41 +01:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Select declared CPU release extras from the exact target project."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
try:
|
|
import tomllib
|
|
except ModuleNotFoundError: # Python 3.10: installed by the locked pytest extra.
|
|
import tomli as tomllib
|
|
|
|
|
|
def release_extras(project: Path) -> list[str]:
|
|
metadata = tomllib.loads(project.read_text(encoding="utf-8"))
|
|
extras = metadata["project"]["optional-dependencies"]
|
|
if not isinstance(extras, dict) or "dev" not in extras:
|
|
raise ValueError("target project must declare its dev test extra")
|
|
return [name for name in ("dev", "recovery", "mcp") if name in extras]
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--project", type=Path, required=True)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
extras = release_extras(args.project)
|
|
args.output.write_text("".join(f"--extra\n{name}\n" for name in extras), encoding="utf-8")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|