The usual windows packaging stuff
[tabakrolletjie.git] / packaging / wine-py2exe
diff --git a/packaging/wine-py2exe b/packaging/wine-py2exe
new file mode 100755 (executable)
index 0000000..d87ba4c
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+# wine-py2exe
+#
+# Usage: wine-py2exe
+
+WS_VERSION=`sed -nre 's/( *)version="(.*)",/\2/p' setup.py`
+BUILD_FOLDER="tabakrolletjie-${WS_VERSION}"
+ZIP_NAME="${BUILD_FOLDER}.zip"
+PY2EXE_LOG="py2exe.log"
+
+WINE_PYTHON=`winepath "C:/Python27"`
+WINE_SYS32=`winepath "C:/windows/system32"`
+
+#
+# Run py2exe build under wine
+#
+
+echo "=== Running wine python setup.py ==="
+echo ""
+echo "  Attack of the Giant Space Mould version: ${WS_VERSION}"
+echo "  Writing log to ${PY2EXE_LOG}."
+echo ""
+
+rm -rf "dist/${BUILD_FOLDER}"
+mkdir -p "dist/${BUILD_FOLDER}"
+rm -rf "dist/${ZIP_NAME}"
+
+wine python setup.py py2exe >${PY2EXE_LOG} 2>&1
+
+#
+# Copy dependencies py2exe missed
+#
+
+echo "=== Copying dependencies that py2exe missed ==="
+echo ""
+
+DEST="dist/${BUILD_FOLDER}"
+
+cp -v "${WINE_SYS32}/python27.dll" "${DEST}"
+
+echo "'data' -> '${DEST}/data'"
+cp -R data ${DEST}/data
+
+echo "'${WINE_PYTHON}/Lib/site-packages/pygame' -> '${DEST}'"
+rm -rf "${DEST}/pygame"
+cp -R "${WINE_PYTHON}/Lib/site-packages/pygame" "${DEST}"
+echo "'${WINE_PYTHON}/Lib/site-packages/pymunk' -> '${DEST}'"
+rm -rf "${DEST}/pymunk"
+cp -R "${WINE_PYTHON}/Lib/site-packages/pymunk" "${DEST}"
+# Needed so we'll find it when running
+cp -R "${WINE_PYTHON}/Lib/site-packages/pymunk/chipmunk.dll" "${DEST}"
+rm -rf "${DEST}/pygame/examples" "${DEST}/pygame/tests" "${DEST}/pygame/docs"
+
+#
+# create zip file
+#
+
+echo "=== Creating zip of patched py2exe dist folder ==="
+echo ""
+echo "  Zip file: dist/${ZIP_NAME}"
+echo "  Build folder: dist/${BUILD_FOLDER}"
+echo ""
+
+cd dist
+rm -f "$ZIP_NAME"
+zip -r -q "$ZIP_NAME" "$BUILD_FOLDER"
+cd ..
+
+echo "=== Done ==="
+echo ""
+echo -n "  "; du -sh dist/${ZIP_NAME}
+echo -n "  "; du -sh dist/${BUILD_FOLDER}
+echo ""