# Sourced by the shell scripts in tools/: sets KPY (a Python that can `import pcbnew`) and
# KC (kicad-cli). Set either in the environment to override the detection.
#
# KICAD_PYTHON=/usr/bin/python3 KICAD_CLI=/usr/bin/kicad-cli sh tools/pnr.sh run board_dir
_mac=/Applications/KiCad/KiCad.app/Contents
if [ -z "$KICAD_PYTHON" ]; then
if [ -x "$_mac/Frameworks/Python.framework/Versions/Current/bin/python3" ]; then
KICAD_PYTHON=$_mac/Frameworks/Python.framework/Versions/Current/bin/python3
elif [ -x "$_mac/Frameworks/Python.framework/Versions/3.9/bin/python3" ]; then
KICAD_PYTHON=$_mac/Frameworks/Python.framework/Versions/3.9/bin/python3
else
KICAD_PYTHON=python3 # Linux: the system Python has pcbnew when KiCad is installed from packages
fi
fi
if [ -z "$KICAD_CLI" ]; then
if command -v kicad-cli >/dev/null 2>&1; then KICAD_CLI=kicad-cli
else KICAD_CLI=$_mac/MacOS/kicad-cli; fi
fi
KPY=$KICAD_PYTHON
KC=$KICAD_CLI
export KPY KC