Forcefully ignore PYTHONPATH env variable on Windows

Fix https://gitlab.com/kicad/code/kicad/-/issues/11328
This commit is contained in:
Marek Roszko 2022-04-04 22:10:59 -04:00
parent 092e4635a9
commit 44296dfea2
1 changed files with 8 additions and 1 deletions

View File

@ -110,7 +110,6 @@ if modulename in sys.modules:
bool SCRIPTING::scriptingSetup() bool SCRIPTING::scriptingSetup()
{ {
#if defined( __WINDOWS__ ) #if defined( __WINDOWS__ )
#ifdef _MSC_VER #ifdef _MSC_VER
// Under vcpkg/msvc, we need to explicitly set the python home or else it'll start consuming // Under vcpkg/msvc, we need to explicitly set the python home or else it'll start consuming
// system python registry keys and the like instead of the Python distributed with KiCad. // system python registry keys and the like instead of the Python distributed with KiCad.
@ -126,6 +125,14 @@ bool SCRIPTING::scriptingSetup()
// MUST be called before Py_Initialize so it will to create valid default lib paths // MUST be called before Py_Initialize so it will to create valid default lib paths
if( !wxGetEnv( wxT( "KICAD_USE_EXTERNAL_PYTHONHOME" ), nullptr ) ) if( !wxGetEnv( wxT( "KICAD_USE_EXTERNAL_PYTHONHOME" ), nullptr ) )
{ {
// Global config flag to ignore PYTHONPATH & PYTHONHOME
Py_IgnoreEnvironmentFlag = 1;
// Extra insurance to ignore PYTHONPATH and PYTHONHOME
wxSetEnv( wxT( "PYTHONPATH" ), wxEmptyString );
wxSetEnv( wxT( "PYTHONHOME" ), wxEmptyString );
// Now initialize Python Home via capi
Py_SetPythonHome( pyHome.GetFullPath().c_str() ); Py_SetPythonHome( pyHome.GetFullPath().c_str() );
} }
#else #else