From e6e08c111b002300b1d8c1e111306e0f19673b72 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Mon, 13 Nov 2023 23:08:53 -0500 Subject: [PATCH] Set PYTHONPATH internally for macOS run from build dir --- cmake/config.h.cmake | 2 ++ scripting/python_scripting.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 3a41b34f24..55562605ad 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -83,6 +83,8 @@ /// Allows scripts install directory to be referenced by the program code. #define PYTHON_DEST "@PYTHON_DEST@" +#define PYTHON_SITE_PACKAGE_PATH "@PYTHON_SITE_PACKAGE_PATH@" + /// Allows scripts install directory to be referenced by the program code. #define KICAD_DATA "@KICAD_DATA@" diff --git a/scripting/python_scripting.cpp b/scripting/python_scripting.cpp index 16d3766c24..7cbb25ab6b 100644 --- a/scripting/python_scripting.cpp +++ b/scripting/python_scripting.cpp @@ -281,6 +281,13 @@ bool SCRIPTING::scriptingSetup() pypath = wxString( wxGetenv( wxT( "PYTHONPATH" ) ) ) + wxT( ":" ) + pypath; } + // Hack for run from build dir option + if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + { + pypath = wxString( wxT( PYTHON_SITE_PACKAGE_PATH ) ) + wxT( "/../:" ) + + wxT( PYTHON_SITE_PACKAGE_PATH ) + wxT( ":" ) + wxT( PYTHON_DEST ); + } + // set $PYTHONPATH wxSetEnv( wxT( "PYTHONPATH" ), pypath );