Skip to content

Commit abae375

Browse files
committed
don't require cmake/nvcc etc just for getting dlpack header
1 parent edaeaa5 commit abae375

2 files changed

Lines changed: 61 additions & 85 deletions

File tree

.github/workflows/check-c-abi.yaml

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,23 @@ jobs:
3636
with:
3737
python-version: '3.11'
3838

39-
- name: Install system dependencies
40-
run: |
41-
sudo apt-get update
42-
sudo apt-get install -y \
43-
libclang-dev \
44-
clang \
45-
cmake \
46-
ninja-build
47-
4839
- name: Install Python dependencies
4940
run: |
5041
pip install --upgrade pip
5142
pip install -e ci/check_c_abi
5243
53-
- name: Build C++ project to get dependencies (dlpack)
44+
- name: Get dlpack dependency
5445
run: |
55-
mkdir -p cpp/build
56-
cd cpp/build
57-
cmake .. \
58-
-GNinja \
59-
-DCMAKE_BUILD_TYPE=Debug \
60-
-DBUILD_TESTS=OFF \
61-
-DBUILD_EXAMPLES=OFF
62-
echo "Build directory created and dependencies fetched"
46+
git clone https://github.com/dmlc/dlpack
6347
6448
- name: Extract ABI from main branch
6549
run: |
6650
mkdir -p baseline
6751
check-c-abi extract \
6852
--header-path c/include \
6953
--include-file cuvs/core/all.h \
70-
--output-file baseline/c_abi.json.gz
54+
--output-file baseline/c_abi.json.gz \
55+
--dlpack-include-path dlpack/include
7156
echo "ABI extracted from main branch (commit: ${{ github.sha }})"
7257
7358
- name: Store commit-specific baseline
@@ -99,30 +84,14 @@ jobs:
9984
with:
10085
python-version: '3.11'
10186

102-
- name: Install system dependencies
103-
run: |
104-
sudo apt-get update
105-
sudo apt-get install -y \
106-
libclang-dev \
107-
clang \
108-
cmake \
109-
ninja-build
110-
11187
- name: Install Python dependencies
11288
run: |
11389
pip install --upgrade pip
11490
pip install ci/check_c_abi
11591
116-
- name: Build C++ project to get dependencies (dlpack)
92+
- name: Get dlpack dependency
11793
run: |
118-
mkdir -p cpp/build
119-
cd cpp/build
120-
cmake .. \
121-
-GNinja \
122-
-DCMAKE_BUILD_TYPE=Debug \
123-
-DBUILD_TESTS=OFF \
124-
-DBUILD_EXAMPLES=OFF
125-
echo "Build directory created and dependencies fetched"
94+
git clone https://github.com/dmlc/dlpack
12695
12796
- name: Find merge base commit
12897
id: merge-base
@@ -159,19 +128,13 @@ jobs:
159128
echo "⚠️ No baseline artifacts found, extracting from main branch..."
160129
echo "This is slower but ensures we always have a baseline for comparison."
161130
git worktree add ../cuvs-main main
162-
mkdir -p ../cuvs-main/cpp/build
163-
cd ../cuvs-main/cpp/build
164-
cmake .. \
165-
-GNinja \
166-
-DCMAKE_BUILD_TYPE=Debug \
167-
-DBUILD_TESTS=OFF \
168-
-DBUILD_EXAMPLES=OFF
169-
cd ../../..
170131
mkdir -p baseline
171132
check-c-abi extract \
172133
--header-path ../cuvs-main/c/include \
173134
--include-file cuvs/core/all.h \
174-
--output-file baseline/c_abi.json.gz
135+
--output-file baseline/c_abi.json.gz \
136+
--dlpack-include-path dlpack/include
137+
175138
echo "✓ Baseline ABI extracted from main branch"
176139
177140
- name: Report baseline source
@@ -189,7 +152,8 @@ jobs:
189152
check-c-abi analyze \
190153
--abi-file baseline/c_abi.json.gz \
191154
--header-path c/include \
192-
--include-file cuvs/core/all.h
155+
--include-file cuvs/core/all.h \
156+
--dlpack-include-path dlpack/include
193157
194158
- name: Comment on PR with results
195159
if: failure() && github.event_name == 'pull_request'

ci/check_c_abi/check_c_abi/main.py

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ def main_cli():
3535
break
3636
current_path = current_path.parent
3737

38+
parent_parser = argparse.ArgumentParser(
39+
add_help=False, description="Common arguments for all subcommands"
40+
)
41+
parent_parser.add_argument(
42+
"--header-path",
43+
help="Path of C headers to analyze (default: %(default)s)",
44+
default=str(default_c_header_path),
45+
)
46+
parent_parser.add_argument(
47+
"--include-file",
48+
help="root header file to examine (default: %(default)s)",
49+
default="cuvs/core/all.h",
50+
)
51+
parent_parser.add_argument(
52+
"--dlpack-include-path", help="path of dlpack header include"
53+
)
54+
3855
parser = argparse.ArgumentParser(
3956
description="Analyze C headers for breaking ABI changes"
4057
)
@@ -43,44 +60,28 @@ def main_cli():
4360
)
4461

4562
parser_extract = subparsers.add_parser(
46-
"extract", help="Extract the ABI from a set of header files"
63+
"extract",
64+
parents=[parent_parser],
65+
help="Extract the ABI from a set of header files",
4766
)
4867
parser_extract.add_argument(
4968
"--output-file",
5069
type=str,
5170
help="The file to output the ABI into (default: %(default)s)",
5271
default="c_abi.json.gz",
5372
)
54-
parser_extract.add_argument(
55-
"--header-path",
56-
help="Path of C headers to extract the ABI from (default: %(default)s)",
57-
default=str(default_c_header_path),
58-
)
59-
parser_extract.add_argument(
60-
"--include-file",
61-
help="root header file to examine (default: %(default)s)",
62-
default="cuvs/core/all.h",
63-
)
6473

6574
parser_analyze = subparsers.add_parser(
66-
"analyze", help="Analyze a set of header files for breaking changes"
75+
"analyze",
76+
parents=[parent_parser],
77+
help="Analyze a set of header files for breaking changes",
6778
)
6879
parser_analyze.add_argument(
6980
"--abi-file",
7081
type=str,
7182
help="The extracted ABI file to compare against (default: %(default)s)",
7283
default="c_abi.json.gz",
7384
)
74-
parser_analyze.add_argument(
75-
"--header-path",
76-
help="Path of C headers to analyze (default: %(default)s)",
77-
default=str(default_c_header_path),
78-
)
79-
parser_analyze.add_argument(
80-
"--include-file",
81-
help="root header file to examine (default: %(default)s)",
82-
default="cuvs/core/all.h",
83-
)
8485

8586
args = parser.parse_args()
8687
if not args.command:
@@ -89,23 +90,34 @@ def main_cli():
8990

9091
header_path = pathlib.Path(args.header_path)
9192

92-
# TODO: better way of specifying the dlpack header source, since missing the dlpack.h
93-
# header means that we all dlpack types get treated as 'int' which could be misleading
94-
# when looking for differences in the ABI (like if we change a field from `DLDataType` to
95-
# `int` without specifying the dlpack include directory, we won't know that the type has
96-
# changed)
97-
dlpack_header_path = (
98-
header_path.parent.parent
99-
/ "cpp"
100-
/ "build"
101-
/ "_deps"
102-
/ "dlpack-src"
103-
/ "include"
104-
)
105-
if not dlpack_header_path.is_dir():
106-
raise ValueError(f"dlpack header {dlpack_header_path} not found")
93+
if args.dlpack_include_path:
94+
dlpack_include_path = pathlib.Path(args.dlpack_include_path).resolve()
95+
96+
else:
97+
# try getting from the cmake build directory dependencies if we
98+
# haven't specified the include directory
99+
dlpack_include_path = (
100+
header_path.parent.parent
101+
/ "cpp"
102+
/ "build"
103+
/ "_deps"
104+
/ "dlpack-src"
105+
/ "include"
106+
)
107+
108+
if not dlpack_include_path.is_dir():
109+
raise ValueError(
110+
f"dlpack header path '{dlpack_include_path}' not found"
111+
)
112+
113+
if not (dlpack_include_path / "dlpack" / "dlpack.h").is_file():
114+
raise ValueError(
115+
f"dlpack header 'dlpack/dlpack.h' not found in '{dlpack_include_path}'"
116+
)
117+
118+
print(f"using dlpack from {dlpack_include_path}")
107119

108-
extra_clang_args = [f"-I{str(dlpack_header_path)}"]
120+
extra_clang_args = [f"-I{str(dlpack_include_path)}"]
109121

110122
if args.command == "extract":
111123
abi = Abi.from_include_path(

0 commit comments

Comments
 (0)