-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnative_runtime_bundle.py
More file actions
24 lines (21 loc) · 920 Bytes
/
Copy pathnative_runtime_bundle.py
File metadata and controls
24 lines (21 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations
from collections.abc import Iterable
from pathlib import Path, PurePosixPath
def build_native_runtime_required_module_files(
template_dir: Path,
module_names: Iterable[str],
) -> tuple[tuple[Path, str], ...]:
"""Build a validated source/name registry for exported native modules."""
root = Path(template_dir)
result: list[tuple[Path, str]] = []
seen: set[str] = set()
for value in module_names:
name = str(value or "").strip()
pure_name = PurePosixPath(name)
if not name or "/" in name or "\\" in name or pure_name.name != name or not name.endswith(".py"):
raise ValueError(f"Invalid native Runtime module name: {value!r}")
if name in seen:
raise ValueError(f"Duplicate native Runtime module name: {name}")
seen.add(name)
result.append((root / name, name))
return tuple(result)