forked from hypothetical-inc/GafferDeadline
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gaffer_env
315 lines (239 loc) · 9.76 KB
/
gaffer_env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#! /bin/bash
##########################################################################
#
# Copyright (c) 2011-2012, John Haddon. All rights reserved.
# Copyright (c) 2011-2012, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################
# Wrapper script for gaffer. This ensures that relevant environment
# variables are set appropriately and then runs gaffer.py in the
# correct python interpreter.
##########################################################################
# set -e
# Remove -psn_0 argument that the OS X launcher adds on annoyingly.
##########################################################################
if [[ $1 == -psn_0_* ]] ; then
shift
fi
# Work around OCIO bug that causes parsing to fail for certain locales.
# See https://github.com/imageworks/OpenColorIO/issues/297
##########################################################################
export LC_NUMERIC=C
# # Find where this script is located, resolving any symlinks that were used
# # to invoke it. Set GAFFER_ROOT based on the script location.
# ##########################################################################
# pushd . &> /dev/null
# # resolve symlinks
# thisScript=$0
# while [[ -L $thisScript ]]
# do
# cd "`dirname "$thisScript"`"
# thisScript=`basename "$thisScript"`
# thisScript=`readlink "$thisScript"`
# done
# # find the bin directory we're in
# cd "`dirname "$thisScript"`"
# binDir=`pwd -P`
# export GAFFER_ROOT="`dirname "$binDir"`"
# popd &> /dev/null
# Make sure resource paths are set appropriately
##########################################################################
# Prepend a directory to a path if it is not
# already there.
#
# $1 is the value to include in the path
# $2 is the name of the path to edit
#
# e.g. prependToPath "$HOME/bin" PATH
function prependToPath {
if [[ ":${!2}:" != *":$1:"* ]] ; then
if [[ ${!2} ]] ; then
eval "export $2=\"$1:${!2}\""
else
eval "export $2=\"$1\""
fi
fi
}
function appendToPath {
if [[ ":${!2}:" != *":$1:"* ]] ; then
if [[ ${!2} ]] ; then
eval "export $2=\"${!2}:$1\""
else
eval "export $2=\"$1\""
fi
fi
}
prependToPath "$GAFFER_ROOT/glsl" IECOREGL_SHADER_PATHS
prependToPath "$GAFFER_ROOT/glsl" IECOREGL_SHADER_INCLUDE_PATHS
prependToPath "$GAFFER_ROOT/fonts" IECORE_FONT_PATHS
prependToPath "$HOME/gaffer/ops:$GAFFER_ROOT/ops" IECORE_OP_PATHS
prependToPath "$HOME/gaffer/opPresets:$GAFFER_ROOT/opPresets" IECORE_OP_PRESET_PATHS
prependToPath "$HOME/gaffer/procedurals:$GAFFER_ROOT/procedurals" IECORE_PROCEDURAL_PATHS
prependToPath "$HOME/gaffer/proceduralPresets:$GAFFER_ROOT/proceduralPresets" IECORE_PROCEDURAL_PRESET_PATHS
if [[ -z $CORTEX_POINTDISTRIBUTION_TILESET ]] ; then
export CORTEX_POINTDISTRIBUTION_TILESET="$GAFFER_ROOT/resources/cortex/tileset_2048.dat"
fi
prependToPath "$HOME/gaffer/apps:$GAFFER_ROOT/apps" GAFFER_APP_PATHS
prependToPath "$HOME/gaffer/startup" GAFFER_STARTUP_PATHS
appendToPath "$GAFFER_ROOT/startup" GAFFER_STARTUP_PATHS
prependToPath "$HOME/gaffer/startup" CORTEX_STARTUP_PATHS
appendToPath "$GAFFER_ROOT/startup" CORTEX_STARTUP_PATHS
prependToPath "$GAFFER_ROOT/graphics" GAFFERUI_IMAGE_PATHS
if [[ -e $GAFFER_ROOT/bin/oslc ]] ; then
export OSLHOME=$GAFFER_ROOT
fi
## \todo: should we rename this to "osl" to match our "glsl" folder?
prependToPath "$HOME/gaffer/shaders:$GAFFER_ROOT/shaders" OSL_SHADER_PATHS
if [[ -z $GAFFEROSL_CODE_DIRECTORY ]] ; then
export GAFFEROSL_CODE_DIRECTORY="$HOME/gaffer/oslCode"
appendToPath "$GAFFEROSL_CODE_DIRECTORY" OSL_SHADER_PATHS
fi
# Get python set up properly
##########################################################################
# Make sure PYTHONHOME is pointing to our internal python build.
# We only do this if Gaffer has been built with an internal version
# of python - otherwise we assume the existing environment is providing
# the right value.
if [[ -e $GAFFER_ROOT/bin/python ]] ; then
if [[ `uname` = "Linux" ]] ; then
export PYTHONHOME="$GAFFER_ROOT"
else
export PYTHONHOME="$GAFFER_ROOT/lib/Python.framework/Versions/Current"
fi
fi
# Get python module path set up
prependToPath "$GAFFER_ROOT/python" PYTHONPATH
# Get library paths set up
##########################################################################
if [[ `uname` = "Linux" ]] ; then
prependToPath "$GAFFER_ROOT/lib" LD_LIBRARY_PATH
else
prependToPath "$GAFFER_ROOT/lib" DYLD_FRAMEWORK_PATH
prependToPath "$GAFFER_ROOT/lib" DYLD_LIBRARY_PATH
# PySide2 installs its libraries next to its python modules,
# and messes up the rpaths such that they can't be relocated.
# Work around this by putting them on the DYLD_LIBRARY_PATH.
prependToPath "$PYTHONHOME/lib/python2.7/site-packages/PySide2" DYLD_LIBRARY_PATH
prependToPath /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Resources/ DYLD_LIBRARY_PATH
fi
if [[ -e $GAFFER_ROOT/qt/plugins ]] ; then
export QT_QPA_PLATFORM_PLUGIN_PATH="$GAFFER_ROOT/qt/plugins"
fi
# Get the executable path set up, for running child processes from Gaffer
##########################################################################
prependToPath "$GAFFER_ROOT/bin" PATH
# Set up Appleseed
##########################################################################
if [[ -z $APPLESEED && -d $GAFFER_ROOT/appleseed ]] ; then
export APPLESEED="$GAFFER_ROOT/appleseed"
fi
if [[ $APPLESEED ]] ; then
if [[ `uname` = "Linux" ]] ; then
prependToPath "$APPLESEED/lib" LD_LIBRARY_PATH
else
prependToPath "$APPLESEED/lib" DYLD_LIBRARY_PATH
fi
# Using a glob to keep the wrapper agnostic of python version.
for appleseedPython in "$APPLESEED"/lib/python* ; do
prependToPath "$appleseedPython" PYTHONPATH
done
prependToPath "$APPLESEED/shaders/gaffer" OSL_SHADER_PATHS
prependToPath "$APPLESEED/shaders/appleseed" OSL_SHADER_PATHS
prependToPath "$GAFFER_ROOT/appleseedDisplays" APPLESEED_SEARCHPATH
prependToPath "$OSL_SHADER_PATHS" APPLESEED_SEARCHPATH
prependToPath "$APPLESEED/bin" PATH
fi
# Set up Arnold
##########################################################################
prependToPath "$GAFFER_ROOT/arnold/plugins" ARNOLD_PLUGIN_PATH
if [[ $ARNOLD_ROOT ]] ; then
if [[ `uname` = "Linux" ]] ; then
appendToPath "$ARNOLD_ROOT/bin" LD_LIBRARY_PATH
else
appendToPath "$ARNOLD_ROOT/bin" DYLD_LIBRARY_PATH
fi
appendToPath "$ARNOLD_ROOT/bin" PATH
appendToPath "$ARNOLD_ROOT/python" PYTHONPATH
fi
# Set up 3Delight
##########################################################################
if [[ -n $DELIGHT ]] ; then
if [[ `uname` = "Linux" ]] ; then
appendToPath "$DELIGHT/lib" LD_LIBRARY_PATH
else
appendToPath "$DELIGHT/lib" DYLD_LIBRARY_PATH
fi
appendToPath "$DELIGHT/bin" PATH
appendToPath "$DELIGHT/python" PYTHONPATH
appendToPath "$DELIGHT/shaders" DL_SHADERS_PATH
appendToPath "$DELIGHT/displays" DL_DISPLAYS_PATH
appendToPath "$DELIGHT" OSL_SHADER_PATHS
appendToPath "$GAFFER_ROOT/renderMan/displayDrivers" DL_RESOURCES_PATH
fi
appendToPath "/Volumes/pipeline" PYTHONPATH
appendToPath "/Volumes/pipeline/gafferStartup" GAFFER_STARTUP_PATHS
# Set up 3rd Party extensions
##########################################################################
IFS=:
for extension in $GAFFER_EXTENSION_PATHS; do
if [[ `uname` = "Linux" ]] ; then
appendToPath "$extension/lib" LD_LIBRARY_PATH
else
appendToPath "$extension/lib" DYLD_LIBRARY_PATH
fi
appendToPath "$extension/bin" PATH
appendToPath "$extension/python" PYTHONPATH
appendToPath "$extension/apps" GAFFER_APP_PATHS
appendToPath "$extension/graphics" GAFFERUI_IMAGE_PATHS
appendToPath "$extension/glsl" IECOREGL_SHADER_PATHS
appendToPath "$extension/glsl" IECOREGL_SHADER_INCLUDE_PATHS
appendToPath "$extension/shaders" OSL_SHADER_PATHS
prependToPath "$extension/startup" GAFFER_STARTUP_PATHS
done
unset IFS
# Run gaffer itself
##########################################################################
# if [[ -n $GAFFER_DEBUG ]] ; then
# if [[ -z $GAFFER_DEBUGGER ]] ; then
# if [[ `uname` = "Linux" ]] ; then
# export GAFFER_DEBUGGER="gdb --args"
# else
# export GAFFER_DEBUGGER="lldb -- "
# fi
# fi
# # Using `which` because lldb doesn't seem to respect $PATH
# exec $GAFFER_DEBUGGER `which python` "$GAFFER_ROOT/bin/gaffer.py" "$@"
# else
# exec python "$GAFFER_ROOT/bin/gaffer.py" "$@"
# fi
code