From 4aa209f7d1ab74f4fe4539d02d0afc944d4a1bcf Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sun, 22 Mar 2026 03:49:55 +0300 Subject: [PATCH] perf: strip OpenCV ffmpeg DLL and PyWin32 help from portable build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove opencv_videoio_ffmpeg (28MB) — only needed for video file I/O, camera capture uses cv2.VideoCapture which links directly to DirectShow - Remove PyWin32.chm help file (2.6MB) - Keep cv2.pyd intact (needed for resize, cvtColor, camera) Future: migrate non-camera cv2 usage to Pillow, replace winsdk (37MB monolithic binary) with lighter notification API. --- build-dist-windows.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build-dist-windows.sh b/build-dist-windows.sh index 2340cd3..b6102a8 100644 --- a/build-dist-windows.sh +++ b/build-dist-windows.sh @@ -291,16 +291,17 @@ rm -rf "$SITE_PACKAGES"/pip "$SITE_PACKAGES"/pip-* 2>/dev/null || true rm -rf "$SITE_PACKAGES"/setuptools "$SITE_PACKAGES"/setuptools-* "$SITE_PACKAGES"/pkg_resources 2>/dev/null || true rm -rf "$SITE_PACKAGES"/_distutils_hack 2>/dev/null || true -# Remove pythonwin GUI IDE (ships with pywin32 but not needed) +# Remove pythonwin GUI IDE and help file (ships with pywin32 but not needed) rm -rf "$SITE_PACKAGES"/pythonwin 2>/dev/null || true +rm -f "$SITE_PACKAGES"/PyWin32.chm 2>/dev/null || true -# OpenCV: remove unused extra modules and data (~40MB savings) +# OpenCV: remove ffmpeg DLL (28MB, only for video file I/O, not camera), +# Haar cascades (2.6MB), and misc dev files CV2_DIR="$SITE_PACKAGES/cv2" if [ -d "$CV2_DIR" ]; then - # Keep only the core .pyd and python wrapper - find "$CV2_DIR" -name "*.pyd" ! -name "cv2*" -delete 2>/dev/null || true + rm -f "$CV2_DIR"/opencv_videoio_ffmpeg*.dll 2>/dev/null || true rm -rf "$CV2_DIR/data" "$CV2_DIR/gapi" "$CV2_DIR/misc" "$CV2_DIR/utils" 2>/dev/null || true - rm -rf "$CV2_DIR/typing_stubs" 2>/dev/null || true + rm -rf "$CV2_DIR/typing_stubs" "$CV2_DIR/typing" 2>/dev/null || true fi # numpy: remove tests, f2py, typing stubs