summaryrefslogtreecommitdiff
path: root/tools/perf/tests/shell/lib/setup_python.sh
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-27 13:39:09 +0100
committerMark Brown <broonie@kernel.org>2026-07-27 13:39:09 +0100
commitc52a755c5f20c1915745342036aacc1cdcdcb8a2 (patch)
treead96e606aa8b9f75474e43504e1e9fccf31661fc /tools/perf/tests/shell/lib/setup_python.sh
parent13c5e0be61b75c5a54d8df95def1bfedbcbf2673 (diff)
parentda85966dfd23a3b03e00ee3bce6ad301f0a2b229 (diff)
downloadlinux-next-c52a755c5f20c1915745342036aacc1cdcdcb8a2.tar.gz
linux-next-c52a755c5f20c1915745342036aacc1cdcdcb8a2.zip
Merge branch 'perf-tools-next' of https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
Diffstat (limited to 'tools/perf/tests/shell/lib/setup_python.sh')
-rw-r--r--tools/perf/tests/shell/lib/setup_python.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/lib/setup_python.sh b/tools/perf/tests/shell/lib/setup_python.sh
index a58e5536f2ed..2173215a0517 100644
--- a/tools/perf/tests/shell/lib/setup_python.sh
+++ b/tools/perf/tests/shell/lib/setup_python.sh
@@ -14,3 +14,16 @@ then
echo Skipping test, python not detected please set environment variable PYTHON.
exit 2
fi
+
+# Set PYTHONPATH to find the in-tree built perf.so first, avoiding system-wide perf.so
+if [ -n "$PERF_EXEC_PATH" ] && [ -d "$PERF_EXEC_PATH/python" ]; then
+ PYTHONPATH_DIR="$PERF_EXEC_PATH/python"
+elif [ -d "$(dirname "$0")/../../python" ]; then
+ PYTHONPATH_DIR="$(dirname "$0")/../../python"
+elif [ -d "$(dirname "$0")/../python" ]; then
+ PYTHONPATH_DIR="$(dirname "$0")/../python"
+fi
+
+if [ -n "$PYTHONPATH_DIR" ]; then
+ export PYTHONPATH="$PYTHONPATH_DIR${PYTHONPATH:+:$PYTHONPATH}"
+fi