File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 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
2525FROM ${TARGET_IMAGE} AS target
2626
2727FROM python:3.12-slim AS extractor
@@ -30,7 +30,10 @@ COPY extractors/helpers/dpkg_helper.py /helpers/dpkg_helper.py
3030COPY extractors/helpers/python_helper.py /helpers/python_helper.py
3131RUN --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
3538FROM scratch
3639COPY --from=extractor /output/ /
Original file line number Diff line number Diff line change 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 ,
Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments