Commits

Giacomo Lacava committed 4b7728d

Added script to create virtualenv environments with pyobjc

Comments (0)

Files changed (1)

make_pyobjc_env.sh

+#!/bin/bash
+# This script is @ Giacomo Lacava 2012 <g.lacava@gmail.com>
+# and is released under terms of the General Public License v.3.
+
+# This script will create a new virtualenv environment and install PyObjC in it.
+# Note that it will not try to setup any integration with Xcode; for all intents
+# and purposes, Xcode support for PyObjC seems to have gone for good, and related
+# modules don't even compile in Mountain Lion.
+#
+# Prerequisites:
+# - virtualenv
+# - pyobjc sources ( hg clone https://bitbucket.org/ronaldoussoren/pyobjc )
+#
+# you can set $PYOBJCSRC yourself or hardcode it in the very next line:
+if [ -z "$PYOBJCSRC" ]; then export PYOBJCSRC=/path/to/your/src/pyobjc ; fi
+
+# --- don't edit anything below this line ---
+
+# help msg
+if [  -z "$1" ] ;
+then
+  echo -e "\n\t Usage: make_pyobjc_env.sh <new-virtualenv-dir>\n";
+  exit 1
+fi
+if [  "$1" == "--help" ] ;
+then
+  echo -e "\n\t Usage: make_pyqt_env.sh <new-virtualenv-dir>\n";
+  exit 1
+fi
+
+# checking pyobjcsrc is valid
+if [ ! -d "$PYOBJCSRC" ]
+then
+	echo "Your PYOBJCSRC variable is not set, and the hardcoded path is incorrect\n"
+	echo "Please set PYOBJCSRC to the path holding all pyobjc sources (not just pyobjc-core)\n"
+	exit 1
+fi
+
+# checking your pyobjc src is good
+for d in {"pyobjc-core","pyobjc-framework-Cocoa","pyobjc-framework-Quartz","pyobjc-framework-CoreData"}
+do	
+	if [ ! -d "$PYOBJCSRC/$d" ]
+	then
+		echo "Your PyObjC sources seem incomplete: missing $d . \n"
+		echo "To guarantee a successful run, you should have at least pyobjc-core, pyobjc-framework-Cocoa, pyobjc-framework-Quartz and pyobjc-framework-CoreData .\n"
+		exit 1
+	fi
+done
+
+
+# create target virtualenv directory
+virtualenv $1
+# following line breaks setuptools / pip for some reason
+#virtualenv --relocatable $1
+
+# get into new env and activate it
+cd $1
+export ENV_DIR=`pwd`
+source $ENV_DIR/bin/activate
+
+# now let's compile pyobjc
+
+# first core
+cd $PYOBJCSRC/pyobjc-core
+python setup.py install
+cd ..
+
+# then packages that other packages require as dependencies
+# note: order is significant!
+for d in {"Cocoa","Quartz","CoreData"}
+do
+	cd pyobjc-framework-$d
+	python setup.py install 
+	cd ..
+done
+
+# then everything else
+for d in pyobjc-framework-*
+do
+	case "$d" in
+		pyobjc-framework-Cocoa) echo "skipping $d" ;;
+		pyobjc-framework-CoreData) echo "skipping $d" ;;
+		pyobjc-framework-Quartz) echo "skipping $d" ;;
+		*) 
+			cd $d
+			python setup.py install
+			cd ..
+			;;
+	esac
+done
+
+# go back to the new virtualenv and source again, 
+# because it looks like we lose the modded prompt during compilations
+cd $ENV_DIR
+source $ENV_DIR/bin/activate