Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: Add suggested fixes for known build issues #376

Open
wants to merge 1 commit into
base: branch-24.03
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,33 @@
import subprocess
import sys
from distutils import sysconfig
from typing import Callable, Optional, Tuple

# Flush output on newlines
sys.stdout.reconfigure(line_buffering=True)


class bcolors:
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could imitate the API I've used elsewhere for consistency

https://github.com/nv-legate/legate.core/blob/5a73122b7516f6b8e786d0c649522223aedc20fe/legate/driver/ui.py#L67-L68

(just manually, w/o using colorama)



CUDA_PATH_ERROR_RE = (
r"The\s+following\s+variables\s+are\s+used\s+in\s+this\s+project,\s+but"
r"\s+they\s+are\s+set\s+to\s+NOTFOUND.\s+Please\s+set\s+them\s+or\s+make"
r"\s+sure\s+they\s+are\s+set\s+and\s+tested\s+correctly\s+in\s+the\s+CMake"
r"\s+files:\s+CUDA_CUDA_LIBRARY\s+\(ADVANCED"
)

CUDA_PATH_ERROR_MESSAGE = """
The most likely error is Legion's FindCUDA failing to find the CUDA libraries.
This can usually be fixed by setting CUDA_PATH in the environment.
For most systems, this will be CUDA_PATH=/usr/local/cuda/lib64/stubs.
"""


class BooleanFlag(argparse.Action):
def __init__(
self,
Expand Down Expand Up @@ -69,10 +91,21 @@ def __call__(self, parser, namespace, values, option_string):
setattr(namespace, self.dest, not option_string.startswith("--no"))


def execute_command(args, verbose, **kwargs):
def execute_command(
args, verbose, suggested_fixes: Optional[Tuple[Callable]] = None, **kwargs
):
if verbose:
print('Executing: "', " ".join(args), '" with ', kwargs)
subprocess.check_call(args, **kwargs)
try:
output = subprocess.check_output(
args, stderr=subprocess.STDOUT, **kwargs
).decode("utf-8")
for fix in suggested_fixes:
fix(output)
except subprocess.CalledProcessError as e:
for fix in suggested_fixes:
fix(e.output.decode("utf-8"))
raise


def find_active_python_version_and_path():
Expand Down Expand Up @@ -200,6 +233,14 @@ def install_legion_python_bindings(
)


def check_cuda_paths_error(output):
import re

match = re.compile(CUDA_PATH_ERROR_RE).search(output)
if match:
print(bcolors.FAIL + CUDA_PATH_ERROR_MESSAGE + bcolors.ENDC)


def install(
gasnet,
cuda,
Expand Down Expand Up @@ -430,7 +471,13 @@ def validate_path(path):
)

# execute python -m pip install <args> .
execute_command(pip_install_cmd, verbose, cwd=legate_core_dir, env=cmd_env)
execute_command(
pip_install_cmd,
verbose,
suggested_fixes=(check_cuda_paths_error,),
cwd=legate_core_dir,
env=cmd_env,
)

if not editable:
install_legion_python_bindings(
Expand Down