forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pants
executable file
·73 lines (59 loc) · 2.49 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
#!/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.
#
# The script defaults to running with either Python 3.7 or Python 3.8. To use another Python version,
# prefix the script with `PY=python3.8`.
set -eo pipefail
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Exposes:
# + determine_python: Determine which interpreter version to use.
# shellcheck source=build-support/common.sh
source "${HERE}/build-support/common.sh"
PY="$(determine_python)"
export PY
if is_macos_arm; then
export PANTS_PYTHON_INTERPRETER_CONSTRAINTS="${PANTS_PYTHON_INTERPRETER_CONSTRAINTS:-"['==3.9.*']"}"
fi
# Exposes:
# + activate_pants_venv: Activate a virtualenv for pants requirements, creating it if needed.
# shellcheck source=build-support/pants_venv
source "${HERE}/build-support/pants_venv"
# Exposes:
# + bootstrap_native_code: Builds target-specific native engine binaries.
# shellcheck source=build-support/bin/rust/bootstrap_code.sh
source "${HERE}/build-support/bin/rust/bootstrap_code.sh"
function exec_pants_bare() {
PANTS_NATIVE_EXE="${HERE}/.pants"
PANTS_PY_EXE="${HERE}/src/python/pants/bin/pants_loader.py"
PANTS_SRCPATH="${HERE}/src/python"
# Redirect activation and native bootstrap to ensure that they don't interfere with stdout.
activate_pants_venv 1>&2
bootstrap_native_code 1>&2
if [ -n "${USE_NATIVE_PANTS}" ]; then
set +e
"${PANTS_NATIVE_EXE}" "$@"
result=$?
# N.B.: The native pants client currently relies on pantsd being up. If it's not, it will fail
# with exit code 75 (EX_TEMPFAIL in /usr/include/sysexits.h) and we should fall through to the
# python pants client which knows how to start up pantsd. This failure takes O(1ms); so has no
# appreciable impact on --no-pantsd runs.
if ((result != 75)); then
exit ${result}
fi
set -e
fi
if [ -n "${PANTS_DEBUG}" ]; then
if [[ "$*" != *"--no-pantsd"* ]]; then
echo "Error! Must pass '--no-pantsd' when using PANTS_DEBUG"
exit 1
fi
DEBUG_ARGS="-m debugpy --listen 127.0.0.1:5678 --wait-for-client"
echo "Will launch debugpy server at '127.0.0.1:5678' waiting for client connection."
fi
# shellcheck disable=SC2086
PYTHONPATH="${PANTS_SRCPATH}:${PYTHONPATH}" RUNNING_PANTS_FROM_SOURCES=1 \
exec ${PANTS_PREPEND_ARGS:-} "$(venv_dir)/bin/python" ${DEBUG_ARGS} "${PANTS_PY_EXE}" "$@"
}
exec_pants_bare "$@"