Debian Codegraph @

test/common/pywrap

raw
1 #!/bin/sh
2
3 # Run a Python script, setting up PYTHONPATH for access to test/common and the
4 # python libraries in bots/. Checks out the bots first, if necessary.
5
6 # This is intended to be used from the interpreter line of executable Python
7 # scripts, referring to it with a relative path. The interpreter line should
8 # look something like so:
9
10 #!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../test/common/pywrap", sys.argv)
11
12 # with the `/../test/common/` part determined by the location of the script
13 # relative to this script.
14
15 set -eu
16
17 realpath="$(realpath "$0")"
18 top_srcdir="${realpath%/*}/../.."
19
20 # Check out the bots if required
21 test -d "${top_srcdir}/bots" || "${top_srcdir}/test/common/make-bots"
22
23 # Prepend the path
24 PYTHONPATH="${top_srcdir}/test/common:${top_srcdir}/bots:${PYTHONPATH:+:${PYTHONPATH}}"
25 export PYTHONPATH
26
27 # Run the script
28 # -B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x
29 # -P : don't prepend a potentially unsafe path to sys.path -- but not available in RHEL 8/9 yet, use once we can
30 exec python3 -B "$@"