@@ -11,6 +11,7 @@ Options:
1111 -b, --base The base image to diff against.
1212 -t, --target The image to diff against the base image.
1313 Default is the locally built image.
14+ -p, --package Only show diff for this package and its dependencies.
1415EOF
1516}
1617
@@ -19,6 +20,7 @@ BASE_IMAGE_TAG='gcr.io/kaggle-images/python:latest'
1920BASE_IMAGE_TAG_OVERRIDE=' '
2021TARGET_IMAGE_TAG=' kaggle/python-build'
2122TARGET_IMAGE_TAG_OVERRIDE=' '
23+ PACKAGE_NAME=' '
2224
2325while : ; do
2426 case " $1 " in
@@ -48,6 +50,15 @@ while :; do
4850 TARGET_IMAGE_TAG_OVERRIDE=" $2 "
4951 shift # skip the flag value
5052 ;;
53+ -p|--package)
54+ if [[ -z " $2 " ]]; then
55+ usage
56+ printf ' ERROR: No PACKAGE specified after the %s flag.\n' " $1 " >&2
57+ exit
58+ fi
59+ PACKAGE_NAME=" $2 "
60+ shift # skip the flag value
61+ ;;
5162 -?* )
5263 usage
5364 printf ' ERROR: Unknown option: %s\n' " $1 " >&2
@@ -78,11 +89,18 @@ if [[ "$BASE_IMAGE_TAG" == "gcr.io/"* ]]; then
7889 docker pull " $BASE_IMAGE_TAG "
7990fi
8091
81- CMDS=(' dpkg-query --show -f "${Package}==${Version}\n"' ' pip freeze' )
92+
93+ if [[ -n " $PACKAGE_NAME " ]]; then
94+ echo " Package: $PACKAGE_NAME "
95+ CMDS=(" python /tools/pip_list_versions.py $PACKAGE_NAME | sort" )
96+ else
97+ CMDS=(' dpkg-query --show -f "${Package}==${Version}\n"' ' pip freeze' )
98+ fi
99+
82100for cmd in " ${CMDS[@]} " ; do
83101 echo " == Comparing $cmd =="
84102 diff --suppress-common-lines --side-by-side \
85- <( docker run -- rm " $BASE_IMAGE_TAG " $cmd ) \
86- <( docker run -- rm " $TARGET_IMAGE_TAG " $cmd ) \
103+ <( docker run -v $PWD /tools:/tools -- rm " $BASE_IMAGE_TAG " /bin/bash -c " $cmd " ) \
104+ <( docker run -v $PWD /tools:/tools -- rm " $TARGET_IMAGE_TAG " /bin/bash -c " $cmd " ) \
87105 && echo ' No diff' || true
88106done
0 commit comments