This repository has been archived by the owner on Dec 10, 2020. It is now read-only.
forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pants
executable file
·74 lines (64 loc) · 2.26 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
71
72
73
74
#!/usr/bin/env bash
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
# This bootstrap script runs pants from the live sources in this repo.
#
# Further support is added for projects wrapping pants with custom external extensions. In the
# future this will work differently (see: https://github.com/pantsbuild/pants/issues/5), but
# currently pants extenders can invoke this script exporting a few environment variables to include
# the extension source and requirements for development purposes:
# WRAPPER_SRCPATH This is a colon separated list of paths containing extension sourcecode.
# WRAPPER_REQUIREMENTS This is a colon separated list of pip install compatible requirements.txt
# files.
#
# For example, with a wrapping project layed out like so:
# /src/wrapper/
# src/main/python/
# wrapper/
# ...
# dependencies/python/
# BUILD
# requirements.txt
#
# And a pantsbuild/pants clone like so:
# /src/pantsbuild-pants
#
# You could invoke pants in the wrapper with its custom extension enabled using a script like so:
# /src/wrapper/pants
# ==
# #!/usr/bin/env bash
# WRAPPER_REQUIREMENTS="/src/wrapper/dependencies/python/requirements.txt" \
# WRAPPER_SRCPATH=/src/wrapper/src/main/python \
# exec /src/pantsbuild-pants/pants "$@"
#
HERE=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
source ${HERE}/build-support/pants_venv
PANTS_EXE="${HERE}/src/python/pants/bin/pants_exe.py"
PY=${PY:-$(which python2.7)}
if [[ ! -z "${WRAPPER_REQUIREMENTS}" ]]; then
REQUIREMENTS=(
$(echo ${WRAPPER_REQUIREMENTS} | tr : ' ')
${REQUIREMENTS[@]}
)
fi
PANTS_SRCPATH=(
${HERE}/src/python
)
if [[ ! -z "${WRAPPER_SRCPATH}" ]]; then
PANTS_SRCPATH=(
$(echo ${WRAPPER_SRCPATH} | tr : ' ')
${PANTS_SRCPATH[@]}
)
fi
PANTS_SRCPATH="$(echo ${PANTS_SRCPATH[@]} | tr ' ' :)"
function exec_pants_bare() {
activate_pants_venv
PYTHONPATH="${PANTS_SRCPATH}:${PYTHONPATH}" exec python ${PANTS_EXE} "$@"
}
if [[ ! -z "${WRAPPER_REQUIREMENTS}" ]]; then
log "*** Running pants with extra requirements: ${WRAPPER_REQUIREMENTS} ***"
fi
if [[ ! -z "${WRAPPER_SRCPATH}" ]]; then
log "*** Running pants with extra sources ${WRAPPER_SRCPATH} ***"
fi
exec_pants_bare "$@"