File size: 1,456 Bytes
b727f11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Record the submodule revision and export public-only runtime dependencies."""

import json
import re
from pathlib import Path
import subprocess
import tomllib

ROOT = Path(__file__).resolve().parents[1]


def main():
    commit = subprocess.check_output(["git", "-C", str(ROOT / "core"), "rev-parse", "HEAD"], text=True).strip()
    if subprocess.check_output(["git", "-C", str(ROOT / "core"), "status", "--porcelain"], text=True).strip():
        raise SystemExit("Commit core changes before pinning the submodule.")
    subprocess.run(["git", "add", "core"], cwd=ROOT, check=True)
    module = tomllib.loads((ROOT / "core/pyproject.toml").read_text())
    data = {"repository": "https://github.com/edmcman/decompile-verify.git", "commit": commit,
            "version": module["project"]["version"]}
    project = ROOT / "pyproject.toml"
    project.write_text(re.sub(r'"decompile-verify==[^" ]+"',
                              f'"decompile-verify=={data["version"]}"', project.read_text()))
    (ROOT / "core-revision.json").write_text(json.dumps(data, indent=2) + "\n")
    subprocess.run(["uv", "lock"], cwd=ROOT, check=True)
    subprocess.run(["uv", "export", "--locked", "--no-dev", "--group", "bootstrap",
                    "--no-emit-project", "--no-emit-package", "decompile-verify",
                    "--output-file", "requirements-runtime.txt"], cwd=ROOT, check=True, stdout=subprocess.DEVNULL)


if __name__ == "__main__":
    main()