Unable to compile Kicad with scripting but without wxPython dependency

Bug #1760200 reported by Mario
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

Using latest GIT version (https://aur.archlinux.org/packages/kicad-git) we stumbled upon "wxPython/wxWidgets release number mismatch" which would cause Pcbnew to freeze on startup and closing it would crash Kicad process. So we tried to disable wxPython via -DKICAD_SCRIPTING_WXPYTHON=OFF cmake option.

The problem is CreatePythonShellWindow() function in pcbnew/swig/python_scripting.cpp seem to import kicad_pyshell which internally imports "wx" using Python "import" keyword.

It looks like this function shouldn't load kicad_pyshell if KICAD_SCRIPTING_WXPYTHON is not set.

Revision history for this message
jean-pierre charras (jp-charras) wrote :

-DKICAD_SCRIPTING_WXPYTHON=OFF works fine for me.

Try to build Kicad from a pristine Build folder (or delete cmakecache file)

Revision history for this message
Mario (k3a) wrote :

You are right, CreatePythonShellWindow() won't be called when -DKICAD_SCRIPTING_WXPYTHON=OFF. But /usr/share/kicad/scripting/kicad_pyshell/__init__.py still somehow gets loaded at runtime which would import wxPython! I don't know Python well but maybe when KiCad intitializes Python scripting, it loads everything __init__.py from scripting directory.

If that is so, then KiCad shouldn't install kicad_pyshell when -DKICAD_SCRIPTING_WXPYTHON=OFF in pcbnew/CMakeLists.txt (see the attached patch).

Revision history for this message
Wayne Stambaugh (stambaughw) wrote : Re: [Bug 1760200] Re: Unable to compile Kicad with scripting but without wxPython dependency

This patch looks correct to me. The wxPython console (kicad_pyshell)
should not be installed when KICAD_SCRIPTING_WXPYTHON=OFF. Anyone else
see any issues with this patch?

On 4/3/2018 5:51 AM, Mario wrote:
> You are right, CreatePythonShellWindow() won't be called when
> -DKICAD_SCRIPTING_WXPYTHON=OFF. But
> /usr/share/kicad/scripting/kicad_pyshell/__init__.py still somehow gets
> loaded at runtime which would import wxPython! I don't know Python well
> but maybe when KiCad intitializes Python scripting, it loads everything
> __init__.py from scripting directory.
>
> If that is so, then KiCad shouldn't install kicad_pyshell when
> -DKICAD_SCRIPTING_WXPYTHON=OFF in pcbnew/CMakeLists.txt (see the
> attached patch).
>
> ** Patch added: "kicad-wxpython.patch"
> https://bugs.launchpad.net/kicad/+bug/1760200/+attachment/5099601/+files/kicad-wxpython.patch
>

Revision history for this message
Seth Hillbrand (sethh) wrote :

Looks good.

The shell was being loaded by pcbnew.LoadPlugins (python_scripting.cpp:196) that loads everything in the PyScriptingPath() return.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Mario, would you please either send me your email address so I can set you as the author of this patch when I merge it (git requires the author signature to have the name <email-address> format) or commit your patch to your local repo and create a new patch using `git format-patch` (which is the preferred method) so I can get your patch merged?

Revision history for this message
Mario (k3a) wrote :

Sending you the patch in git format. Name and email is part of the patch. Thanks!

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Mario, this is better but it looks like you've left a debugging
printf() statement in pcbnew/pcb_edit_frame.cpp. Please remove this or
use wxLogDebug so that it doesn't get added for release builds. Do no
not use printf() for debugging because it has no meaning on windows.
wxLogDebug will handle debugging output appropriately. Also, please add
the bug report information to your commit message per the commit message
policy[1] so that the bug report status automatically gets updated.

[1]: http://docs.kicad-pcb.org/doxygen/commit_messages.html

On 04/07/2018 01:12 PM, Mario wrote:
> Sending you the patch in git format. Name and email is part of the
> patch. Thanks!
>
> ** Patch added: "0001-don-t-copy-python-shell-when-wxWidget-support-is-dis.patch"
> https://bugs.launchpad.net/kicad/+bug/1760200/+attachment/5105912/+files/0001-don-t-copy-python-shell-when-wxWidget-support-is-dis.patch
>

Revision history for this message
Mario (k3a) wrote :

Sorry, I forgot them there. I am new to external git diffs.
Of course they were my dirty temporary logging lines and thanks for mentioning wxLogDebug.

The correct patch is attached. Sorry again for that previous mistake.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision efa2a13eaa4e8b7090ef978ab5e203ae3c32668c
https://git.launchpad.net/kicad/patch/?id=efa2a13eaa4e8b7090ef978ab5e203ae3c32668c

Changed in kicad:
status: New → Fix Committed
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I merged you patch along with an amended commit message to include the missing bug report information. Thank you for your contribution to KiCad.

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.