aboutsummaryrefslogtreecommitdiff
blob: 901277c96cb58ac7023915d63f78d1eb1eff3309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# Copyright 2010-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

export __PORTAGE_HELPER_CWD=${PWD}

if [[ ${0##*/} == "ebuild-pyhelper" ]]; then
	echo "ebuild-pyhelper: must be called via symlink" &>2
	exit 1
fi

# Use safe cwd, avoiding unsafe import for bug #469338.
cd "${PORTAGE_PYM_PATH}" || exit 1
for path in "${PORTAGE_BIN_PATH}/${0##*/}"{.py,}; do
	if [[ -x "${path}" ]]; then
		PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
			exec "${PORTAGE_PYTHON:-/usr/bin/python}" "${path}" "$@"
	fi
done
echo "File not found: ${path}" >&2
exit 127