Pcbnew: fix outdated environment vars settings for Kicad python on Windows:
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:
parent
7051b6d21f
commit
f53cfe58bd
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
|
@ -203,40 +203,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 );
|
||||
}
|
||||
|
||||
// wizard plugins are stored in ../share/kicad/scripting/plugins.
|
||||
|
@ -298,7 +287,7 @@ static bool scriptingSetup()
|
|||
// determined by the python pcbnew.py initialisation code.
|
||||
if( !pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
|
||||
{
|
||||
wxLogError( wxT( "pcbnewInitPythonScripting() failed." ) );
|
||||
wxLogError( "pcbnewInitPythonScripting() failed." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue