diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index b25c10110c..52ae682de8 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -287,7 +287,7 @@ static bool scriptingSetup() if( !path.DirExists() && !path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) wxLogError( "Warning: could not create user scripting path %s", path.GetPath() ); - if( !pcbnewInitPythonScripting( TO_UTF8( PyScriptingPath() ) ) ) + if( !pcbnewInitPythonScripting( TO_UTF8( PyScriptingPath() ), TO_UTF8( PyScriptingPath( true ) ) ) ) { wxLogError( "pcbnewInitPythonScripting() failed." ); return false; @@ -305,7 +305,8 @@ void PythonPluginsReloadBase() // and load new plugins char cmd[1024]; - snprintf( cmd, sizeof( cmd ), "pcbnew.LoadPlugins(\"%s\")", TO_UTF8( PyScriptingPath() ) ); + snprintf( cmd, sizeof( cmd ), "pcbnew.LoadPlugins(\"%s\", \"%s\")", TO_UTF8( PyScriptingPath() ), + TO_UTF8( PyScriptingPath( true ) ) ); PyLOCK lock; diff --git a/pcbnew/swig/python_scripting.cpp b/pcbnew/swig/python_scripting.cpp index 06556f969f..e7a44fd301 100644 --- a/pcbnew/swig/python_scripting.cpp +++ b/pcbnew/swig/python_scripting.cpp @@ -158,7 +158,7 @@ PyThreadState* g_PythonMainTState; * * This initializes all the wxPython interface and returns the python thread control structure */ -bool pcbnewInitPythonScripting( const char * aUserScriptingPath ) +bool pcbnewInitPythonScripting( const char* aStockScriptingPath, const char* aUserScriptingPath ) { int retv; char cmd[1024]; @@ -242,7 +242,8 @@ bool pcbnewInitPythonScripting( const char * aUserScriptingPath ) snprintf( cmd, sizeof( cmd ), "import sys, os, traceback\n" "sys.path.append(\".\")\n" "import pcbnew\n" - "pcbnew.LoadPlugins(\"%s\")", aUserScriptingPath ); + "pcbnew.LoadPlugins(\"%s\", \"%s\")", + aStockScriptingPath, aUserScriptingPath ); retv = PyRun_SimpleString( cmd ); if( retv != 0 ) diff --git a/pcbnew/swig/python_scripting.h b/pcbnew/swig/python_scripting.h index a9f8a7e1c2..1c1790f20d 100644 --- a/pcbnew/swig/python_scripting.h +++ b/pcbnew/swig/python_scripting.h @@ -58,8 +58,8 @@ /** * Initialize the Python engine inside pcbnew. */ -bool pcbnewInitPythonScripting( const char * aUserScriptingPath ); -void pcbnewFinishPythonScripting(); +bool pcbnewInitPythonScripting( const char* aStockScriptingPath, const char* aUserScriptingPath ); +void pcbnewFinishPythonScripting(); /** * Collect the list of python scripts which could not be loaded. diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index 8c8db8beb8..c559ebac36 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -137,7 +137,7 @@ def LoadPluginModule(Dirname, ModuleName, FileName): FULL_BACK_TRACE += traceback.format_exc() -def LoadPlugins(bundlepath=None): +def LoadPlugins(bundlepath=None, userpath=None): """ Initialise Scripting/Plugin python environment and load plugins. @@ -191,6 +191,9 @@ def LoadPlugins(bundlepath=None): plugin_directories.append(os.path.join(config_path, 'scripting')) plugin_directories.append(os.path.join(config_path, 'scripting', 'plugins')) + if userpath: + plugin_directories.append(userpath) + plugin_directories.append(os.path.join(userpath, 'plugins')) global PLUGIN_DIRECTORIES_SEARCH PLUGIN_DIRECTORIES_SEARCH=""