source: orange/install-scripts/mac/bundle-build-hg.sh @ 11775:531e077742b2

Revision 11775:531e077742b2, 6.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 5 months ago (diff)

Use pip to install PIL (needs a flat installation for PIL namespace).

  • Property exe set to *
Line 
1#!/bin/bash -e
2#
3# Build the orange Mac OSX bundle
4#
5# ./bundle-build-hg.sh work_dir revision bundle_output_file
6# ./bundle-build-hg.sh /private/tmp tip /private/tmp/orange-bundle-hg-tip.dmg
7#
8
9WORK_DIR=$1
10REVISION=$2
11BUNDLE=$3
12
13TMP_BUNDLE_DIR=${WORK_DIR}/bundle
14REPOS_DIR=${WORK_DIR}/repos
15
16# Remove leftovers if any
17if [ -e $TMP_BUNDLE_DIR ]; then
18    rm -rf $TMP_BUNDLE_DIR
19fi
20
21echo "Preaparing the bundle template"
22TEMPLATE_VERSION=$(curl --silent http://orange.biolab.si/download/bundle-templates/CURRENT.txt)
23curl --silent http://orange.biolab.si/download/bundle-templates/Orange-template-${TEMPLATE_VERSION}.tar.gz | tar -xz -C $WORK_DIR
24
25# Make repos dir if it does not yet exist
26if [ ! -e $REPOS_DIR ]; then
27    mkdir $REPOS_DIR
28fi
29
30APP=${TMP_BUNDLE_DIR}/Orange.app
31
32# Python interpreter in the bundle
33PYTHON=${APP}/Contents/MacOS/python
34
35# Python version
36PY_VER=`$PYTHON -c "import sys; print sys.version[:3]"`
37
38SITE_PACKAGES=${APP}/Contents/Frameworks/Python.framework/Versions/${PY_VER}/lib/python${PY_VER}/site-packages/
39
40# easy_install script in the bundle
41EASY_INSTALL=${APP}/Contents/MacOS/easy_install
42
43# pip script in the bundle
44PIP=${APP}/Contents/MacOS/pip
45
46DISTRIBUTE_VERSION="0.6.49"
47echo "Updating distribute to $DISTRIBUTE_VERSION"
48$EASY_INSTALL -U distribute==$DISTRIBUTE_VERSION
49
50# Link Python.app startup script to top bundle
51ln -fs ../Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python ${APP}/Contents/MacOS/PythonAppStart
52
53echo "Preparing startup scripts"
54
55# Create an enironment startup script
56cat <<-'EOF' > $APP/Contents/MacOS/ENV
57    # Create an environment for running python from the bundle
58    # Should be run as "source ENV"
59
60    BUNDLE_DIR=`dirname "$0"`/../
61    BUNDLE_DIR=`perl -MCwd=realpath -e 'print realpath($ARGV[0])' "$BUNDLE_DIR"`/
62    FRAMEWORKS_DIR="$BUNDLE_DIR"Frameworks/
63    RESOURCES_DIR="$BUNDLE_DIR"Resources/
64
65    PYVERSION="2.7"
66
67    PYTHONEXECUTABLE="$FRAMEWORKS_DIR"Python.framework/Resources/Python.app/Contents/MacOS/Python
68    PYTHONHOME="$FRAMEWORKS_DIR"Python.framework/Versions/"$PYVERSION"/
69
70    DYLD_FRAMEWORK_PATH="$FRAMEWORKS_DIR"${DYLD_FRAMEWORK_PATH:+:$DYLD_FRAMEWORK_PATH}
71
72    export PYTHONEXECUTABLE
73    export PYTHONHOME
74    export PYTHONNOUSERSITE=1
75
76    export DYLD_FRAMEWORK_PATH
77
78    # Some non framework libraries are put in $FRAMEWORKS_DIR by macho_standalone
79    export DYLD_LIBRARY_PATH="$FRAMEWORKS_DIR"${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
80EOF
81
82# Create Orange application startup script
83cat <<-'EOF' > ${APP}/Contents/MacOS/Orange
84    #!/bin/bash
85
86    DIRNAME=$(dirname "$0")
87    source "$DIRNAME"/ENV
88
89    # LaunchServices passes the Carbon process identifier to the application with
90    # -psn parameter - we do not want it
91    if [[ $1 == -psn_* ]]; then
92        shift 1
93    fi
94
95    exec -a "$0" "$DIRNAME"/PythonAppStart -m Orange.OrangeCanvas.main "$@"
96EOF
97
98chmod +x ${APP}/Contents/MacOS/Orange
99
100
101echo "Checkouting and building orange"
102echo "==============================="
103./bundle-inject-hg.sh https://bitbucket.org/biolab/orange orange $REVISION $REPOS_DIR ${APP}
104
105echo "Specifically building orangeqt"
106echo "------------------------------"
107
108pushd $REPOS_DIR/orange/source/orangeqt
109echo "Fixing sip/pyqt configuration"
110
111sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/PyQt4/pyqtconfig.py
112sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/sipconfig.py
113export PATH=$APP/Contents/Resources/Qt4/bin:$PATH
114$PYTHON setup.py install
115
116popd
117
118echo "Fixing Qt plugins search path"
119echo "[Paths]
120Plugins = ../../../../../Resources/Qt4/plugins/" > $APP/Contents/Frameworks/Python.framework/Resources/Python.app/Contents/Resources/qt.conf
121
122echo "[Paths]
123Plugins = Resources/Qt4/plugins/" > $APP/Contents/Resources/qt.conf
124
125
126echo "Checkouting and building bioinformatics addon"
127echo "============================================="
128./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-bioinformatics bioinformatics tip $REPOS_DIR ${APP}
129
130echo "Checkouting and building text addon"
131echo "==================================="
132./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-text text tip $REPOS_DIR ${APP}
133
134echo "Instaling slumber library"
135echo "+++++++++++++++++++++++++"
136$EASY_INSTALL slumber
137
138echo "Installing PIL"
139echo "++++++++++++++"
140$PIP install PIL
141
142
143echo "Removing unnecessary files."
144find $TMP_BUNDLE_DIR \( -name '*~' -or -name '*.bak' -or -name '*.pyc' -or -name '*.pyo' -or -name '*.pyd' \) -exec rm -rf {} ';'
145
146ln -s ../Frameworks/Python.framework/Versions/Current/lib/python${PY_VER}/site-packages/Orange ${APP}/Contents/Resources/Orange
147
148   
149echo "Preparing the .dmg image"
150echo "========================"
151
152# Makes a link to Applications folder
153ln -s /Applications/ $TMP_BUNDLE_DIR/Applications
154
155echo "Fixing bundle permissions."
156
157{ chown -Rh root:wheel $TMP_BUNDLE_DIR; } || { echo "Could not fix bundle permissions"; }
158
159echo "Creating temporary image with the bundle."
160
161TMP_BUNDLE=${WORK_DIR}/bundle.dmg
162rm -f $TMP_BUNDLE
163
164hdiutil detach /Volumes/Orange -force || true
165hdiutil create -format UDRW -volname Orange -fs HFS+ -fsargs "-c c=64,a=16,e=16" -srcfolder $TMP_BUNDLE_DIR $TMP_BUNDLE
166MOUNT_OUTPUT=`hdiutil attach -readwrite -noverify -noautoopen $TMP_BUNDLE | egrep '^/dev/'`
167DEV_NAME=`echo -n "$MOUNT_OUTPUT" | head -n 1 | awk '{print $1}'`
168MOUNT_POINT=`echo -n "$MOUNT_OUTPUT" | tail -n 1 | awk '{print $3}'`
169
170# Makes the disk image window open automatically when mounted
171bless -openfolder "$MOUNT_POINT"
172# Hides background directory even more
173/Developer/Tools/SetFile -a V "$MOUNT_POINT/.background/"
174# Sets the custom icon volume flag so that volume has nice Orange icon after mount (.VolumeIcon.icns)
175/Developer/Tools/SetFile -a C "$MOUNT_POINT"
176
177# Might mot have permissions to do this
178{ rm -rf "$MOUNT_POINT/.Trashes/"; } || { echo "Could not remove $MOUNT_POINT/.Trashes/"; }
179
180{ rm -rf "$MOUNT_POINT/.fseventsd/"; } || { echo "Could not remove $MOUNT_POINT/.fseventsd/"; }
181
182hdiutil detach "$DEV_NAME" -force
183
184echo "Converting temporary image to a compressed image."
185
186if [ -e $BUNDLE ]; then
187    rm -f $BUNDLE
188fi
189
190hdiutil convert $TMP_BUNDLE -format UDZO -imagekey zlib-level=9 -o $BUNDLE
191
192echo "Cleaning up."
193rm -f $TMP_BUNDLE
194rm -rf $TMP_BUNDLE_DIR
195
196true
Note: See TracBrowser for help on using the repository browser.