From 13ee30dcfc2c4248b6cc2fb8bd5ca5cbf038f064 Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Sat, 17 May 2014 20:30:29 +0200 Subject: [PATCH] OS X build. --- packaging/darwin-py2app.sh | 63 ++++++++++++++++++++++++++++++++++++++ setup.py | 15 +++++---- 2 files changed, 72 insertions(+), 6 deletions(-) create mode 100755 packaging/darwin-py2app.sh diff --git a/packaging/darwin-py2app.sh b/packaging/darwin-py2app.sh new file mode 100755 index 0000000..8af8829 --- /dev/null +++ b/packaging/darwin-py2app.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Copyright 2009 Jeremy Thurgood +# GPL - see COPYING for details +# +# Usage: darwin-py2app + +GAME_NAME=`sed -ne 's/NAME_STR = "\(.*\)"/\1/p' setup.py` +GAME_VERSION=`sed -ne 's/VERSION_STR = "\(.*\)"/\1/p' setup.py` +BUILD_NAME="${GAME_NAME}-${GAME_VERSION}" +BUILD_FOLDER="build/${BUILD_NAME}" +DMG_NAME="${BUILD_NAME}.dmg" +PY2APP_LOG="py2app.log" + +BASEDIR=`pwd` + +echo "=== Setting up build environment ===" + +python setup.py sdist > /dev/null +mkdir build +(cd build; tar xzf ../dist/${BUILD_NAME}.tar.gz) + +echo "[${BUILD_FOLDER}]" +cd ${BUILD_FOLDER} +echo "$PWD" + +echo "" +echo "=== Running python setup.py ===" +echo " ${GAME_NAME} version: ${GAME_VERSION}" +echo " Writing log to ${PY2APP_LOG}" + +python setup.py py2app >${PY2APP_LOG} 2>&1 + +echo "" +echo "=== Removing useless cruft that just takes up space ===" +echo "" + +for dir in docs examples tests; do + find "dist/" -path "*/Resources/lib/*/pygame/${dir}/*" -delete +done + +echo "=== Adding magic icon ===" +echo "" + +cp data/icons/*.icns dist/${GAME_NAME}.app/Contents/Resources/ + +echo "=== Building DMG ===" +echo "" + +cd ${BASEDIR} + +pwd +rm dist/${DMG_NAME} > /dev/null + +echo -e "For some reason the game starts without a foreground window. Click on the icon in the dock (or minimize and restore from the menu) to get it back.\n\nIf this doesn't work, please let me () know, especially if you have any ideas about how to fix it.\n\nYou should also be able to use the unix tarball available at the same place you got this dmg.\n\nThanks." > ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt + +hdiutil create -volname ${GAME_NAME} -srcfolder ${BUILD_FOLDER}/dist/*.app/ -srcfolder ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt dist/${DMG_NAME} + +echo "" +echo "=== Done ===" +echo "" +du -sh dist/* | sed 's/^/ /' +echo "" + diff --git a/setup.py b/setup.py index 49e8fff..abbfcb4 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,11 @@ try: except ImportError: pass + # This should probably be pulled from constants.py +# These two constants are used by darwin-py2app.sh. VERSION_STR = "0.1" +NAME_STR = "robolock-II" class NajaSdist(sdist): @@ -33,7 +36,7 @@ class NajaInstall(install): setup( - name="robolock-II", + name=NAME_STR, version=VERSION_STR, description="Robolock II - a puzzle game", @@ -114,10 +117,10 @@ setup( 'pygame', ], 'excludes': [ - 'numpy', 'pygame.sdlmain_osx', 'winreg', 'AppKit', 'Foundation', - 'Numeric', 'OpenGL.GL', '_scproxy', '_sysconfigdata', - 'copyreg', 'dummy.Process', 'pkg_resources', 'queue', - 'win32evtlog', 'win32evtlogutil', + 'numpy', 'pygame.sdlmain_osx', 'winreg', 'AppKit', + 'Foundation', 'Numeric', 'OpenGL.GL', '_scproxy', + '_sysconfigdata', 'copyreg', 'dummy.Process', 'pkg_resources', + 'queue', 'win32evtlog', 'win32evtlogutil', ], 'ignores': [ # all database modules @@ -136,7 +139,7 @@ setup( 'py2app': { 'app': ['run_game.py'], 'argv_emulation': True, - 'iconfile': 'data/icons/program/icon.icns', + 'iconfile': 'data/icons/robolock.icns', 'packages': [ 'logging', 'encodings', 'pygame', 'naja', 'data', ], -- 2.34.1