forked from HypothesisWorks/hypothesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·51 lines (36 loc) · 1.54 KB
/
build.sh
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
#!/usr/bin/env bash
# This script is here to bootstrap the Hypothesis build process into a working
# version of Python, then hand over to the actual Hypothesis build runner (which
# is written in Python instead of bash).
if [ -n "${CI:-}" ] ; then echo "::group::Build setup" ; fi
set -o xtrace
set -o errexit
set -o nounset
ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
export HYPOTHESIS_ROOT="$ROOT"
SCRIPTS="$ROOT/tooling/scripts"
# shellcheck source=tooling/scripts/common.sh
source "$SCRIPTS/common.sh"
if [ -n "${GITHUB_ACTIONS-}" ] || [ -n "${CODESPACES-}" ] ; then
# We're on GitHub Actions or Codespaces and already set up a suitable Python
PYTHON=$(command -v python)
else
# Otherwise, we install it from scratch
# NOTE: tooling keeps this version in sync with ci_version in tooling
"$SCRIPTS/ensure-python.sh" 3.10.15
PYTHON=$(pythonloc 3.10.15)/bin/python
fi
TOOL_REQUIREMENTS="$ROOT/requirements/tools.txt"
TOOL_HASH=$("$PYTHON" "$SCRIPTS/tool-hash.py" < "$TOOL_REQUIREMENTS")
TOOL_VIRTUALENV="$VIRTUALENVS/build-$TOOL_HASH"
TOOL_PYTHON="$TOOL_VIRTUALENV/bin/python"
export PYTHONPATH="$ROOT/tooling/src"
if ! "$TOOL_PYTHON" -m hypothesistooling check-installed ; then
rm -rf "$TOOL_VIRTUALENV"
"$PYTHON" -m pip install --upgrade pip
"$PYTHON" -m pip install --upgrade virtualenv
"$PYTHON" -m virtualenv "$TOOL_VIRTUALENV"
"$TOOL_PYTHON" -m pip install --no-warn-script-location -r requirements/tools.txt
fi
if [ -n "${CI:-}" ] ; then echo "::endgroup::" ; fi
"$TOOL_PYTHON" -m hypothesistooling "$@"