Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions ci/tools/check_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import re
import sys
from pathlib import Path

COMPONENT_TO_PACKAGE: dict[str, str] = {
"cuda-core": "cuda_core",
Expand Down Expand Up @@ -63,7 +64,7 @@ def is_post_release(version: str) -> bool:


def load_backport_branch(repo_root: str = ".") -> str | None:
path = os.path.join(repo_root, "ci", "versions.yml")
path = Path(repo_root, "ci", "versions.yml")
try:
with open(path, encoding="utf-8") as f:
for line in f:
Expand All @@ -85,7 +86,7 @@ def is_backport_version(version: str, backport_branch: str) -> bool:


def notes_path(package: str, version: str) -> str:
return os.path.join(package, "docs", "source", "release", f"{version}-notes.rst")
return str(Path(package, "docs", "source", "release", f"{version}-notes.rst"))


def check_release_notes(git_tag: str, component: str, repo_root: str = ".") -> list[tuple[str, str]]:
Expand All @@ -105,10 +106,10 @@ def check_release_notes(git_tag: str, component: str, repo_root: str = ".") -> l
return []

path = notes_path(COMPONENT_TO_PACKAGE[component], version)
full = os.path.join(repo_root, path)
if not os.path.isfile(full):
full = Path(repo_root, path)
if not full.is_file():
return [(path, "missing")]
if os.path.getsize(full) == 0:
if full.stat().st_size == 0:
return [(path, "empty")]
return []

Expand Down
4 changes: 2 additions & 2 deletions ci/tools/tests/test_check_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from __future__ import annotations

import os
import sys
from pathlib import Path

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, str(Path(__file__).parent.parent))
from check_release_notes import (
check_release_notes,
is_post_release,
Expand Down
7 changes: 3 additions & 4 deletions toolshed/build_static_bitcode_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
import os
import sys
import textwrap
from pathlib import Path

import llvmlite.binding # HINT: pip install llvmlite

from cuda.bindings import nvvm


def get_minimal_nvvmir_txt_template():
cuda_bindings_tests_dir = os.path.normpath("cuda_bindings/tests")
assert os.path.isdir(cuda_bindings_tests_dir), (
"Please run this helper script from the cuda-python top-level directory."
)
cuda_bindings_tests_dir = Path("cuda_bindings/tests")
assert cuda_bindings_tests_dir.is_dir(), "Please run this helper script from the cuda-python top-level directory."
sys.path.insert(0, os.path.abspath(cuda_bindings_tests_dir))
import test_nvvm

Expand Down
2 changes: 2 additions & 0 deletions toolshed/check_generated_file_seals.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def main(args):

returncode = 0
for filepath in args:
# os.path.isfile, not Path.is_file: this skips anything that is not a
# readable regular file, and Path.is_file raises on e.g. EACCES.
if not os.path.isfile(filepath):
continue
if not validate_generated_file_seal(filepath, previously_sealed_paths):
Expand Down
5 changes: 2 additions & 3 deletions toolshed/check_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
# SPDX-License-Identifier: Apache-2.0

import datetime
import os
import re
import subprocess
import sys
from pathlib import PureWindowsPath
from pathlib import Path, PureWindowsPath

import pathspec

Expand Down Expand Up @@ -39,7 +38,7 @@


def load_spdx_ignore():
if os.path.exists(SPDX_IGNORE_FILENAME):
if Path(SPDX_IGNORE_FILENAME).exists():
with open(SPDX_IGNORE_FILENAME, encoding="utf-8") as f:
lines = f.readlines()
else:
Expand Down
6 changes: 3 additions & 3 deletions toolshed/dump_cutile_b64.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

import base64
import glob
import os
import sys
from pathlib import Path

import cupy

Expand Down Expand Up @@ -54,13 +54,13 @@ def main():
raise

# Find the .cutile file in current directory
cutile_files = glob.glob("./*.cutile")
cutile_files = list(Path().glob("*.cutile"))
if not cutile_files:
print("No .cutile file found in current directory", file=sys.stderr)
sys.exit(1)

# Use the most recently modified one if multiple exist
cutile_path = max(cutile_files, key=os.path.getmtime)
cutile_path = max(cutile_files, key=lambda path: path.stat().st_mtime)

# Read the binary content
with open(cutile_path, "rb") as f:
Expand Down
Loading