From fe54a2ec0fe983ccec3656b366272e7426855477 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 5 Jun 2025 23:12:32 -0400 Subject: [PATCH] Append python Scripts directory to PATH env on windows --- common/paths.cpp | 2 +- scripting/python_scripting.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/paths.cpp b/common/paths.cpp index 018f7f5c5b..d67b85d44a 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -136,7 +136,7 @@ wxString PATHS::GetDefault3rdPartyPath() tmp.AppendDir( wxT( "3rdparty" ) ); - return tmp.GetPath(); + return tmp.GetAbsolutePath(); } diff --git a/scripting/python_scripting.cpp b/scripting/python_scripting.cpp index b36630c1cd..89c2aaf228 100644 --- a/scripting/python_scripting.cpp +++ b/scripting/python_scripting.cpp @@ -249,6 +249,19 @@ bool SCRIPTING::scriptingSetup() // Now initialize Python Home via capi Py_SetPythonHome( pyHome.GetFullPath().c_str() ); } + + // Allow executing the python pip installed scripts on windows easily + wxString envPath; + if( wxGetEnv( wxT( "PATH" ), &envPath ) ) + { + wxFileName pythonThirdPartyBin( PATHS::GetDefault3rdPartyPath() ); + pythonThirdPartyBin.AppendDir( wxString::Format( wxT( "Python%d%d" ), PY_MAJOR_VERSION, PY_MINOR_VERSION ) ); + pythonThirdPartyBin.AppendDir( wxT( "Scripts" ) ); + + envPath = pythonThirdPartyBin.GetAbsolutePath() + ";" + envPath; + + wxSetEnv( wxT( "PATH" ), envPath ); + } #else // Intended for msys2 but we could probably use the msvc equivalent code too // If our python.exe (in kicad/bin) exists, force our kicad python environment