test/common: add new 'pywrap' script
This is meant to be used as an alternate interpreter path which runs a Python script in an environment with the bots checked out and the PYTHONPATH correctly configured. This provides an alternate mechanism to our `import parent` hacks, which are now considered deprecated.
This commit is contained in:
parent
89db1c68a9
commit
d97ddebca2
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Run a Python script, setting up PYTHONPATH for access to test/common and the
|
||||
# python libraries in bots/. Checks out the bots first, if necessary.
|
||||
|
||||
set -eu
|
||||
|
||||
realpath="$(realpath "$0")"
|
||||
top_srcdir="${realpath%/*}/../.."
|
||||
|
||||
# Check out the bots if required
|
||||
test -d "${top_srcdir}/bots" || "${top_srcdir}/test/common/make-bots"
|
||||
|
||||
# Prepend the path
|
||||
PYTHONPATH="${top_srcdir}/test/common:${top_srcdir}/bots:${top_srcdir}/bots/machine${PYTHONPATH:+:${PYTHONPATH}}"
|
||||
export PYTHONPATH
|
||||
|
||||
# Run the script
|
||||
exec python3 "$@"
|
Loading…
Reference in New Issue