perf: strip OpenCV ffmpeg DLL and PyWin32 help from portable build
Some checks failed
Lint & Test / test (push) Failing after 14s

- 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.
This commit is contained in:
2026-03-22 03:49:55 +03:00
parent 14adc8172b
commit 4aa209f7d1

View File

@@ -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