From 148ac193868d91a49ac2ce121e299ee249bb99c1 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 1 Jun 2021 21:37:33 -0400 Subject: [PATCH] Fix launching from the build dir after new_python --- scripting/python_scripting.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripting/python_scripting.cpp b/scripting/python_scripting.cpp index 24d72211c6..c48c6632fd 100644 --- a/scripting/python_scripting.cpp +++ b/scripting/python_scripting.cpp @@ -163,8 +163,16 @@ bool SCRIPTING::scriptingSetup() #else wxString pypath; - // PYTHON_DEST is the scripts install dir as determined by the build system. - pypath = Pgm().GetExecutablePath() + wxT( "../" PYTHON_DEST ); + if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + { + // When running from build dir, python module gets built next to pcbnew binary + pypath = Pgm().GetExecutablePath() + wxT( "../pcbnew" ); + } + else + { + // PYTHON_DEST is the scripts install dir as determined by the build system. + pypath = Pgm().GetExecutablePath() + wxT( "../" PYTHON_DEST ); + } if( !wxIsEmpty( wxGetenv( wxT( "PYTHONPATH" ) ) ) ) pypath = wxString( wxGetenv( wxT( "PYTHONPATH" ) ) ) + wxT( ":" ) + pypath;