Skip to content

Commit 4d95cea

Browse files
ranrubinclaude
andcommitted
ci(compliance): address review comments
- Fix --builder help text: --platform is optional, defaults to linux/amd64 - Dockerfile.extract: surface extractor errors and fail build if dpkg.tsv is empty to prevent silent failures - python_helper.py: add /opt/*/lib/python* glob paths for conda/virtualenv layouts common in ML containers - dpkg_helper.py/python_helper.py: rename legacy mode -> local mode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 47e78a3 commit 4d95cea

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

container/compliance/Dockerfile.extract

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# dpkg_err.txt - stderr from dpkg extraction (for debugging)
2222
# python_err.txt - stderr from python extraction (for debugging)
2323

24-
ARG TARGET_IMAGE
24+
ARG TARGET_IMAGE=scratch
2525
FROM ${TARGET_IMAGE} AS target
2626

2727
FROM python:3.12-slim AS extractor
@@ -30,7 +30,10 @@ COPY extractors/helpers/dpkg_helper.py /helpers/dpkg_helper.py
3030
COPY extractors/helpers/python_helper.py /helpers/python_helper.py
3131
RUN --mount=type=bind,from=target,target=/target \
3232
python3 /helpers/dpkg_helper.py --root /target > /output/dpkg.tsv 2>/output/dpkg_err.txt ; \
33-
python3 /helpers/python_helper.py --root /target > /output/python.tsv 2>/output/python_err.txt
33+
python3 /helpers/python_helper.py --root /target > /output/python.tsv 2>/output/python_err.txt ; \
34+
if [ -s /output/dpkg_err.txt ]; then echo "dpkg extraction errors:" >&2; cat /output/dpkg_err.txt >&2; fi ; \
35+
if [ -s /output/python_err.txt ]; then echo "python extraction errors:" >&2; cat /output/python_err.txt >&2; fi ; \
36+
[ -s /output/dpkg.tsv ] || { echo "ERROR: dpkg extraction produced no output" >&2; exit 1; }
3437

3538
FROM scratch
3639
COPY --from=extractor /output/ /

container/compliance/extractors/helpers/dpkg_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
# This script runs INSIDE the container (legacy mode) or against a mounted
4+
# This script runs INSIDE the container (local mode) or against a mounted
55
# filesystem root (--root /target mode for BuildKit extraction).
66
# It must be fully self-contained with zero external dependencies (only Python stdlib).
77

@@ -149,7 +149,7 @@ def main():
149149
license_id = get_license_for_package(pkg, root)
150150
print(f"{pkg}\t{version}\t{license_id}")
151151
else:
152-
# Legacy mode: run dpkg-query inside the container
152+
# Local mode: run dpkg-query inside the container
153153
result = subprocess.run(
154154
["dpkg-query", "-W", "-f=${Package}\t${Version}\n"],
155155
capture_output=True,

container/compliance/extractors/helpers/python_helper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
# This script runs INSIDE the container (legacy mode) or against a mounted
4+
# This script runs INSIDE the container (local mode) or against a mounted
55
# filesystem root (--root /target mode for BuildKit extraction).
66
# It must be fully self-contained with zero external dependencies (only Python stdlib).
77

@@ -117,9 +117,12 @@ def main():
117117
search_paths += glob.glob(f"{root}/usr/lib/python*/site-packages")
118118
search_paths += glob.glob(f"{root}/usr/local/lib/python*/dist-packages")
119119
search_paths += glob.glob(f"{root}/usr/local/lib/python*/site-packages")
120+
# conda / virtualenv layouts common in ML containers (e.g. /opt/conda)
121+
search_paths += glob.glob(f"{root}/opt/*/lib/python*/site-packages")
122+
search_paths += glob.glob(f"{root}/opt/*/lib/python*/dist-packages")
120123
dists = importlib.metadata.distributions(path=search_paths)
121124
else:
122-
# Legacy mode: enumerate distributions in the running Python environment
125+
# Local mode: enumerate distributions in the running Python environment
123126
dists = importlib.metadata.distributions()
124127

125128
seen = set()

container/compliance/generate_attributions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def extract_all_buildx(
200200
f"TARGET_IMAGE={image}",
201201
"--output",
202202
f"type=local,dest={tmpdir}",
203+
"--pull", # always re-resolve target image digest from registry
203204
"-f",
204205
str(_EXTRACT_DOCKERFILE),
205206
str(_SCRIPT_DIR),
@@ -295,7 +296,8 @@ def parse_args() -> argparse.Namespace:
295296
default="",
296297
help=(
297298
"docker buildx builder name. When set, uses BuildKit filesystem extraction "
298-
"(no docker run) instead of docker run. Requires --platform."
299+
"(no docker run) instead of docker run. Use --platform to target a specific "
300+
"architecture (defaults to linux/amd64)."
299301
),
300302
)
301303
parser.add_argument(

0 commit comments

Comments
 (0)