diff options
Diffstat (limited to 'tools/kicad_env.sh')
| -rw-r--r-- | tools/kicad_env.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/kicad_env.sh b/tools/kicad_env.sh new file mode 100644 index 0000000..f4947f0 --- /dev/null +++ b/tools/kicad_env.sh @@ -0,0 +1,22 @@ +# 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 |
