Hi all,
I have built KiCad from source, and it worked.
Then I wanted to try python plugins in Pcbnew tools, because I want to try https://github.com/HiGregSmith/KiCommand - so I rebuilt with KICAD_SCRIPTING_ACTION_MENU, as noted in Pcbnew external plugin? and HOWTO: Register a python plugin inside pcbnew Tools menu ; this is my KiCad version info:
Application: kicad
Version: (2017-11-13 revision d98fc85)-master, release build
Libraries:
wxWidgets 3.0.2
libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Platform: Linux 4.4.0-104-generic i686, 32 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
Boost: 1.54.0
Curl: 7.35.0
Compiler: GCC 4.8.4 with C++ ABI 1002
Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=OFF
KICAD_SPICE=OFF
This is on Ubuntu 14.04, 32-bit:
$ echo $(cat /etc/issue) $(lsb_release -idrc); uname -a
Ubuntu 14.04.5 LTS \n \l Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
Linux myPC 4.4.0-104-generic #127~14.04.1-Ubuntu SMP Mon Dec 11 12:44:57 UTC 2017 i686 i686 i686 GNU/Linux
The problem is that; while I do get the new menu item in Pcbnew/Tools/External Plugins, there is only āRefresh Pluginsā inside, and the list never gets populated, regardless of how manu times I click āRefresh Pluginsā:
One possible problem can be, is that Iām not installing in the system directories once I build from source, but in an āout of treeā, that is āportableā folder, as in:
make -j 4
make install DESTDIR=/media/disk/mybin/kicad
As such, I copied the KiCommand folder in plugins/
within that install directory:
cp -a KiCommand_git/kicommand /media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins/
So, I added some debugging statements, which can be seen in this diff - and then rebuilt again:
diff --git a/pcbnew/class_action_plugin.cpp b/pcbnew/class_action_plugin.cpp
index 171e0f2..61c94ee 100644
--- a/pcbnew/class_action_plugin.cpp
+++ b/pcbnew/class_action_plugin.cpp
@@ -102,6 +102,8 @@ int ACTION_PLUGINS::GetActionsCount()
void ACTION_PLUGINS::register_action( ACTION_PLUGIN* aAction )
{
+ printf("ACTION_PLUGINS::register_action aA %p nm %s\n", aAction, (const char*)aAction->GetName().mb_str());
+
// Search for this entry do not register twice this action:
for( int ii = 0; ii < GetActionsCount(); ii++ )
{
diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp
index ef18cde..2b5f08f 100644
--- a/pcbnew/swig/pcbnew_action_plugins.cpp
+++ b/pcbnew/swig/pcbnew_action_plugins.cpp
@@ -156,7 +156,7 @@ void* PYTHON_ACTION_PLUGIN::GetObject()
void PYTHON_ACTION_PLUGINS::register_action( PyObject* aPyAction )
{
PYTHON_ACTION_PLUGIN* fw = new PYTHON_ACTION_PLUGIN( aPyAction );
-
+ printf("PYTHON_ACTION_PLUGINS::register_action %p\n", aPyAction);
fw->register_action();
}
@@ -380,6 +380,8 @@ void PCB_EDIT_FRAME::RebuildActionPluginMenus()
{
wxMenu* actionMenu = GetMenuBar()->FindItem( ID_TOOLBARH_PCB_ACTION_PLUGIN )->GetSubMenu();
+ printf("PCB_EDIT_FRAME::RebuildActionPluginMenus actionMenu %p\n",
+ actionMenu);
if( !actionMenu ) // Should not occur.
return;
@@ -410,6 +412,9 @@ void PCB_EDIT_FRAME::RebuildActionPluginMenus()
actionMenu->Delete( item );
}
+ printf("PCB_EDIT_FRAME::RebuildActionPluginMenus av_mn_sz %d gactcnt %d\n",
+ available_menus.size(), ACTION_PLUGINS::GetActionsCount());
+
for( int ii = 0; ii < ACTION_PLUGINS::GetActionsCount(); ii++ )
{
wxMenuItem* item;
diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i
index 1dfaa16..388824e 100644
--- a/scripting/kicadplugins.i
+++ b/scripting/kicadplugins.i
@@ -219,6 +219,8 @@ def LoadPlugins(bundlepath=None):
plugin_directories.append(os.path.join(os.environ['HOME'],'.kicad','scripting'))
plugin_directories.append(os.path.join(os.environ['HOME'],'.kicad','scripting','plugins'))
+ print("plugin_directories: {}".format(plugin_directories))
+
global PLUGIN_DIRECTORIES_SEARCH
PLUGIN_DIRECTORIES_SEARCH=""
for plugins_dir in plugin_directories: # save search path list for later use
@@ -241,6 +243,7 @@ def LoadPlugins(bundlepath=None):
sys.path.append(plugins_dir)
for module in os.listdir(plugins_dir):
+ print("module '{}' plugins_dir '{}'".format(module, plugins_dir))
if os.path.isdir(os.path.join(plugins_dir,module)):
LoadOneSubdirPlugin(plugins_dir, module)
continue
@@ -256,6 +259,7 @@ class KiCadPlugin:
pass
def register(self):
+ print("KiCadPlugin: register {}".format(self))
if isinstance(self,FilePlugin):
pass # register to file plugins in C++
So, now when I run kicad, and then start Pcbnew, I get printed in terminal:
plugin_directories: ['/media/disk/mybin/kicad/usr/local/share/kicad/scripting', '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins', u'/home/user/.config/kicad/scripting', u'/home/user/.config/kicad/scripting/plugins', '/home/user/.kicad_plugins', '/home/user/.kicad/scripting', '/home/user/.kicad/scripting/plugins']
module 'kicad_pyshell' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting'
module 'plugins' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting'
module 'zip_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'FootprintWizardBase.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'sdip_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'bga_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qrcode.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'kicommand' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'bga_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qfp_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qrcode_footprint_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'uss39_barcode.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'FootprintWizardBase.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'circular_pad_array_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'FPC_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'uss39_barcode.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'sdip_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'touch_slider_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'microMatch_connectors.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qfn_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'zip_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module '__init__.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qfp_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'touch_slider_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'FPC_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'circular_pad_array_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'PadArray.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'microMatch_connectors.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qrcode_footprint_wizard.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'PadArray.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qrcode.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module '__init__.pyc' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
module 'qfn_wizard.py' plugins_dir '/media/disk/mybin/kicad/usr/local/share/kicad/scripting/plugins'
PCB_EDIT_FRAME::RebuildActionPluginMenus actionMenu 0xb777c18
PCB_EDIT_FRAME::RebuildActionPluginMenus av_mn_sz 0 gactcnt 0
PCB_EDIT_FRAME::RebuildActionPluginMenus actionMenu 0xb76e5e8
PCB_EDIT_FRAME::RebuildActionPluginMenus av_mn_sz 0 gactcnt 0
Pretty much the same printout happens when I run āRefresh Pluginsā (except then I have only two PCB_EDIT_FRAME::RebuildActionPluginMenus
printouts)
So, the directories are not a problem - they are found and inspected for plugins; plugins are found - even module ākicommandā is found; actionMenu
seems instantiated - however:
-
available_menus.size()
andACTION_PLUGINS::GetActionsCount()
are always 0 ? - The print in
kicadplugins.i
indef register
is never printed (although the prints in the same file, indef LoadPlugins
are printed fine) - meaning thatdef register
here never runs ? - Likewise,
ACTION_PLUGINS::register_action
andPYTHON_ACTION_PLUGINS::register_action
never seem to run, as their printouts are also not printed ?
So, if the āregisterā functions donāt run, that explains why GetActionsCount()
would be zero.
But then the question is - why donāt the āregisterā functions run ?!
The only thing Iāve noticed, is that when I change something in the .i
file, and rebuild, I get this at the end of the terminal log:
...
[ 82%] Built target eeschema_kiface
[ 82%] [ 83%] Built target qa_eagle_plugin
Generating pcbnew_wrap.cxx, pcbnew.py
[ 83%] Built target eeschema
/media/disk/src/kicad/kicad_git/pcbnew/../include/geometry/shape_poly_set.h:76: Warning 325: Nested struct not currently supported (VERTEX_INDEX ignored)
/media/disk/src/kicad/kicad_git/pcbnew/../include/geometry/shape_poly_set.h:204: Warning 325: Nested class not currently supported (ITERATOR_TEMPLATE ignored)
/media/disk/src/kicad/kicad_git/pcbnew/../include/geometry/shape_poly_set.h:350: Warning 325: Nested class not currently supported (SEGMENT_ITERATOR_TEMPLATE ignored)
io_mgr.h:122: Warning 325: Nested class not currently supported (PLUGIN_REGISTRY ignored)
io_mgr.h:137: Warning 325: Nested struct not currently supported (REGISTER_PLUGIN ignored)
class_zone.h:839: Warning 325: Nested union not currently supported (WX_VECTOR_CONVERTER ignored)
class_module.h:88: Warning 325: Nested struct not currently supported (VECTOR3D ignored)
/media/disk/src/kicad/kicad_git/pcbnew/../include/class_colors_design_settings.h:48: Warning 401: Nothing known about base class 'SETTINGS'. Ignored.
class_board.h:50: Warning 315: Nothing known about 'std::unique_ptr'.
/media/disk/src/kicad/kicad_git/pcbnew/../include/utf8.h:180: Warning 503: Can't wrap 'operator const std::string&' unless renamed to a valid identifier.
swig_import_helper fixed for /media/disk/src/kicad/kicad_git/build/debugi686/pcbnew/pcbnew.py
Scanning dependencies of target pcbnew_kiface
[ 83%] Building CXX object pcbnew/CMakeFiles/pcbnew_kiface.dir/pcbnew_wrap.cxx.o
Linking CXX shared module _pcbnew.kiface
[100%] Built target pcbnew_kiface
[100%] Creating python's pcbnew native module _pcbnew.so for command line use.
[100%] Built target pcbnew
[100%] Built target qa_geometry
[100%] Built target pcbnew_python_module
In particular, notice that PLUGIN_REGISTRY
and REGISTER_PLUGIN
are āignoredā, because of āWarning 325: Nested class not currently supportedā. I looked up this error, and found:
Compatibility Note: Prior to SWIG-3.0.0, there was limited nested class support. Nested classes were treated as opaque pointers. ā¦ With proper nested class support now available in SWIG-3.0.0, this feature has been deprecated and no longer works requiring code changes.
You therefore ought to use 3.0 or later for support for nested classes. That will allow you to avoid needing to suppress anything, and might fix your other issues too.
But, my swig version is 3.0+ ? :
$ apt-show-versions -r swig
swig3.0:i386/trusty-backports 3.0.2-1ubuntu1~ubuntu14.04.1 uptodate
$ swig3.0 -version
SWIG Version 3.0.2
Compiled with g++ [i686-pc-linux-gnu]
Configured options: +pcre
Please see http://www.swig.org for reporting bugs and further information
So, now Iām really puzzled.
Would anyone know, what do I need to do, in order to have the Pcbnew action plugins, to register in the tools menu?