Skip to content
Snippets Groups Projects

Introduce Nox for Local and CI Test Automation. Start Writing a Contributors Guide.

Merged Frederik Hennig requested to merge fhennig/nox into v2.0-dev
1 file
+ 9
14
Compare changes
  • Side-by-side
  • Inline
+ 9
14
@@ -4,26 +4,21 @@ from typing import Sequence
@@ -4,26 +4,21 @@ from typing import Sequence
import os
import os
import nox
import nox
import subprocess
import subprocess
import re
nox.options.sessions = ["lint", "typecheck", "testsuite"]
nox.options.sessions = ["lint", "typecheck", "testsuite"]
def get_cuda_version() -> None | tuple[int, ...]:
def get_cuda_version() -> None | tuple[int, ...]:
query_args = ["nvcc", "--version"]
smi_args = ["nvidia-smi", "--version"]
try:
try:
query_result = subprocess.run(query_args, capture_output=True)
result = subprocess.run(smi_args, capture_output=True)
except FileNotFoundError:
except FileNotFoundError:
return None
return None
matches = re.findall(r"release \d+\.\d+", str(query_result.stdout))
smi_output = str(result.stdout).splitlines()
if matches:
cuda_version = smi_output[-1].split(":")[1].strip()
match = matches[0]
return tuple(int(v) for v in cuda_version.split("."))
version_string = match.split()[-1]
return tuple(int(v) for v in version_string.split("."))
else:
return None
def editable_install(session: nox.Session, opts: Sequence[str] = ()):
def editable_install(session: nox.Session, opts: Sequence[str] = ()):
@@ -55,13 +50,13 @@ def typecheck(session: nox.Session):
@@ -55,13 +50,13 @@ def typecheck(session: nox.Session):
def testsuite(session: nox.Session, cupy_version: str | None):
def testsuite(session: nox.Session, cupy_version: str | None):
if cupy_version is not None:
if cupy_version is not None:
cuda_version = get_cuda_version()
cuda_version = get_cuda_version()
if cuda_version is None or cuda_version[0] < 11:
if cuda_version is None or cuda_version[0] not in (11, 12):
session.skip(
session.skip(
"No compatible installation of CUDA found - Need at least CUDA 11"
"No compatible installation of CUDA found - Need either CUDA 11 or 12"
)
)
cuda_major = cuda_version[0]
cuda_major = cuda_version[0]
cupy_package = f"cupy-cuda{cuda_major}=={cupy_version}"
cupy_package = f"cupy-cuda{cuda_major}x=={cupy_version}"
session.install(cupy_package)
session.install(cupy_package)
editable_install(session, ["alltrafos", "use_cython", "interactive", "testsuite"])
editable_install(session, ["alltrafos", "use_cython", "interactive", "testsuite"])
Loading