forked from RL-Align/RL-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvs.py
More file actions
28 lines (21 loc) · 915 Bytes
/
Copy pathenvs.py
File metadata and controls
28 lines (21 loc) · 915 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
25
26
27
28
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 RL-Kernel Contributors
"""Environment variable parsing helpers for build scripts.
This module is intentionally import-safe for setup.py: keep it free of torch or
other heavy runtime imports.
"""
import os
def env_flag(name: str, default: bool = False) -> bool:
value = os.environ.get(name)
if not value or value.strip() == "":
return default
normalized = value.strip().lower()
if normalized in {"1", "true", "yes", "on"}:
return True
if normalized in {"0", "false", "no", "off"}:
return False
raise ValueError(f"{name} must be a boolean flag, got {value!r}")
KERNEL_ALIGN_USE_FAST_MATH = "KERNEL_ALIGN_USE_FAST_MATH"
KERNEL_ALIGN_NCU_LINEINFO = "KERNEL_ALIGN_NCU_LINEINFO"
KERNEL_ALIGN_ALLOW_UNSUPPORTED_MSVC = "KERNEL_ALIGN_ALLOW_UNSUPPORTED_MSVC"
KERNEL_ALIGN_FORCE_SM90 = "KERNEL_ALIGN_FORCE_SM90"