project init

This commit is contained in:
2025-03-24 22:13:13 +08:00
commit d2df459709
4 changed files with 123 additions and 0 deletions

22
src/speccpu/__init__.py Normal file
View File

@@ -0,0 +1,22 @@
import copy
import os
from pathlib import Path
def get_spec_env(spec_dir: Path):
new_env = copy.deepcopy(os.environ)
new_env["SPEC"] = str(spec_dir)
new_env["PATH"] = os.pathsep.join(
[
str(spec_dir / "bin"),
*new_env["PATH"].split(os.pathsep),
]
)
return new_env
def find_build(build_dir: Path) -> Path:
entries = list(sorted(os.listdir(build_dir)))
for entry in entries:
if entry.startswith("build"):
return build_dir / entry
raise RuntimeError(f"SPEC build directory not found at {build_dir}")