forked from twitter-archive/commons
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pants
executable file
·70 lines (62 loc) · 2.48 KB
/
pants
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
#!/bin/bash
# ==================================================================================================
# Copyright 2011 Twitter, Inc.
# --------------------------------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==================================================================================================
MY_DIR=$(dirname $0)
VIRTUAL_PYTHON=$MY_DIR/.python/bootstrap
PANTS_EXE=$MY_DIR/src/python/twitter/pants/bin/pants_exe.py
PANTS_BOOTSTRAP_ARGS=${PANTS_BOOTSTRAP_ARGS:-''}
MARKDOWN_EGG=$MY_DIR/3rdparty/python/Markdown-2.1.1-py2.6.egg
PYGMENTS_EGG=$MY_DIR/3rdparty/python/Pygments-1.4-py2.6.egg
PYSTACHE_EGG=$MY_DIR/3rdparty/python/pystache-0.5.3-py2.6.egg
PYTHON_DAEMON_EGG=$MY_DIR/3rdparty/python/python_daemon-1.5.5-py2.6.egg
function run_pants_bare() {
source $VIRTUAL_PYTHON/bin/activate
PYTHONPATH=$MARKDOWN_EGG:$PYGMENTS_EGG:$PYSTACHE_EGG:$PYTHON_DAEMON_EGG:$MY_DIR/src/python \
python $PANTS_BOOTSTRAP_ARGS $PANTS_EXE "$@"
result=$?
deactivate
return $((result))
}
if [ ! -e $VIRTUAL_PYTHON/bin/python ]; then
$MY_DIR/build-support/python/setup.sh
rc=$?
if [[ $rc != 0 ]]; then
echo "Unable to bootstrap a sane Python virtual environment for pants!"
rm -rf $VIRTUAL_PYTHON
exit $rc
fi
source $VIRTUAL_PYTHON/bin/activate
deactivate
fi
if [ -z "${PANTS_DEV}" -a ! -e $MY_DIR/pants.pex ]; then
run_pants_bare src/python/twitter/pants:pants
if [ ! -e $MY_DIR/dist/pants.pex ]; then
echo "Unable to build pants! Cannot continue!"
exit 1
else
mv $MY_DIR/dist/pants.pex $MY_DIR/pants.pex
cp $MY_DIR/pants.pex $VIRTUAL_PYTHON/pants.pex
fi
fi
if [ ! -z "${PANTS_DEV}" ]; then
# TODO(John Sirois): ideally this would just use pants.pex to run the pants target in py mode:
# ./pants.pex py src/python/twitter/pants "$@"
echo "*** running pants in dev mode from $PANTS_EXE ***" 1>&2
run_pants_bare "$@"
exit $ret
else
${MY_DIR}/pants.pex "$@"
fi