Shift the msvc specific pythonhome init

This commit is contained in:
Marek Roszko 2021-06-08 23:37:40 -04:00
parent d946d6e68f
commit 0ffabf5e70
1 changed files with 20 additions and 18 deletions

View File

@ -58,24 +58,6 @@ SCRIPTING::SCRIPTING()
{
scriptingSetup();
#ifdef _MSC_VER
// 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
// We are going to follow the "unix" layout for the msvc/vcpkg distributions so exes in /root/bin
// And the python lib in /root/lib/python3(/Lib,/DLLs)
wxFileName pyHome;
pyHome.Assign( Pgm().GetExecutablePath() );
pyHome.Normalize();
// MUST be called before Py_Initialize so it will to create valid default lib paths
if( !wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{
Py_SetPythonHome( pyHome.GetFullPath().c_str() );
}
#endif
pybind11::initialize_interpreter();
// Save the current Python thread state and release the
@ -118,6 +100,25 @@ if modulename in sys.modules:
bool SCRIPTING::scriptingSetup()
{
#if defined( __WINDOWS__ )
#ifdef _MSC_VER
// 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
// We are going to follow the "unix" layout for the msvc/vcpkg distributions so exes in /root/bin
// And the python lib in /root/lib/python3(/Lib,/DLLs)
wxFileName pyHome;
pyHome.Assign( Pgm().GetExecutablePath() );
pyHome.Normalize();
// MUST be called before Py_Initialize so it will to create valid default lib paths
if( !wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{
Py_SetPythonHome( pyHome.GetFullPath().c_str() );
}
#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
wxString kipython = FindKicadFile( "python.exe" );
@ -141,6 +142,7 @@ bool SCRIPTING::scriptingSetup()
kipython << wxT( ";" ) << ppath;
wxSetEnv( wxT( "PATH" ), kipython );
}
#endif
#elif defined( __WXMAC__ )