Pcbnew: fix outdated environment vars settings for Kicad python on Windows (from master branch):

On Windows, previously, Pcbnew try to set env vars PYTHONPATH, if <kicad>/bin/python27_us folder is found.
Now, if python.exe is found in kicad bin folder (therefore if our python executable and libs are
installed in Kicad), PYTHONPATH and PYTHONHOME are set to an empty string.
( the default python path work fine with our standard python install )
This commit is contained in:
jean-pierre charras 2016-11-14 08:35:12 +01:00
parent 65fe561a4b
commit 8023c7a794
1 changed files with 15 additions and 26 deletions

View File

@ -205,40 +205,29 @@ static bool scriptingSetup()
{
wxString path_frag;
#if defined( __MINGW32__ )
// force python environment under Windows:
const wxString python_us( wxT( "python27_us" ) );
#if defined( __WINDOWS__ )
// If our python.exe (in kicad/bin) exists, force our kicad python environment
wxString kipython = FindKicadFile( "python.exe" );
// Build our python path inside kicad
wxString kipython = FindKicadFile( python_us + wxT( "/python.exe" ) );
//we need only the path:
wxFileName fn( kipython );
// we need only the path:
wxFileName fn( kipython );
kipython = fn.GetPath();
// If our python install is existing inside kicad, use it
// Note: this is usefull only when an other python version is installed
if( wxDirExists( kipython ) )
{
// clear any PYTHONPATH and PYTHONHOME env var definition: the default
// values work fine inside Kicad:
wxSetEnv( wxT( "PYTHONPATH" ), wxEmptyString );
wxSetEnv( wxT( "PYTHONHOME" ), wxEmptyString );
// Add our python executable path in first position:
wxString ppath;
wxGetEnv( wxT( "PATH" ), &ppath );
if( !wxGetEnv( wxT( "PYTHONPATH" ), &ppath ) || !ppath.Contains( python_us ) )
{
ppath << kipython << wxT( "/pylib;" );
ppath << kipython << wxT( "/lib;" );
ppath << kipython << wxT( "/dll" );
wxSetEnv( wxT( "PYTHONPATH" ), ppath );
// DBG( std::cout << "set PYTHONPATH to " << TO_UTF8( ppath ) << "\n"; )
// Add python executable path:
wxGetEnv( wxT( "PATH" ), &ppath );
if( !ppath.Contains( python_us ) )
{
kipython << wxT( ";" ) << ppath;
wxSetEnv( wxT( "PATH" ), kipython );
// DBG( std::cout << "set PATH to " << TO_UTF8( kipython ) << "\n"; )
}
}
kipython << wxT( ";" ) << ppath;
wxSetEnv( wxT( "PATH" ), kipython );
}
// TODO: make this path definable by the user, and set more than one path