Skip to content

Commit 80e8cfc

Browse files
authored
[Fix]Add PLATFORM reminder (#526)
1 parent 1bfb325 commit 80e8cfc

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

setup.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# SOFTWARE.
2323
#
2424

25+
import atexit
2526
import os
2627
import subprocess
2728
import sys
@@ -34,6 +35,37 @@
3435
ENABLE_SPARSE = os.getenv("ENABLE_SPARSE")
3536

3637

38+
_warning_printed = False
39+
40+
41+
def print_platform_warning():
42+
global _warning_printed
43+
if not PLATFORM and not _warning_printed:
44+
_warning_printed = True
45+
RED = "\033[91m"
46+
YELLOW = "\033[93m"
47+
BOLD = "\033[1m"
48+
RESET = "\033[0m"
49+
50+
warning_msg = f"""
51+
{RED}{'=' * 80}
52+
{BOLD}⚠️ WARNING: PLATFORM environment variable is not set! ⚠️{RESET}
53+
{RED}{'=' * 80}{RESET}
54+
{YELLOW}Please set PLATFORM to one of: cuda, ascend, musa, maca{RESET}
55+
Example:
56+
{BOLD}export PLATFORM=cuda{RESET} # For CUDA platform
57+
{YELLOW}In CI scenarios only, you don't need to specify PLATFORM. If it's not a CI scenario, please uninstall and then reinstall with PLATFORM specified.{RESET}
58+
{RED}{'=' * 80}{RESET}
59+
"""
60+
# Use write and flush to ensure output even without -v flag
61+
sys.stderr.write(warning_msg)
62+
sys.stderr.flush()
63+
64+
65+
if not PLATFORM:
66+
atexit.register(print_platform_warning)
67+
68+
3769
def enable_sparse() -> bool:
3870
return ENABLE_SPARSE is not None and ENABLE_SPARSE.lower() == "true"
3971

0 commit comments

Comments
 (0)