Kicad-winbuilder and wxPython

Hi,

Since the build system for the Windows nightlies is down, I decided to get kicad-winbuilder from GitHub and make my own. After some initial growing pains (for some reason there is a hardcoded path to C:\building, and the compilation process fails if the top dir is somewhere else…), I was able to complete a build and get the installer package. Or so I thought.

The KiCad project manager and Eeschema start fine without any problems, but pcbnew pops up an error message on startup:

2:31:30 PM: ***** Error importing the wxPython API! *****
2:31:30 PM: pcbnewInitPythonScripting() failed.

I can click the message away and try working, but any functionality depending on python causes the app too crash. After searching the net for answers I tried a couple of things that helped me narrow down the problem:

  • I added the %< kicad_install_dir >%\bin to the system’s PATH, also added %< kicad_install_dir >%\lib\python2.7, %< kicad_install_dir >%\lib\python2.7\site-packages, and %< kicad_install_dir >%\lib\python2.7\site-packages\wx-3.0-msw.
  • I added the same folders to the environment as PYTHONPATH

Still, same error. Then I started python and tried importing wx to see if that worked. Here is the output:

Python 2.7.14 (default, Sep 18 2017, 09:17:44)  [GCC 7.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\opt\KiCad\lib\python2.7\site-packages\wx-3.0-msw/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "c:\opt\KiCad\lib\python2.7\site-packages\wx-3.0-msw/wx/_core.py", line 4, in <module>
    import _core_
ImportError: DLL load failed: The specified procedure could not be found.
>>>

So it seems that it didn’t find a DLL, but that didn’t make any sense. So I tried to recomplile kicad again and that is when I realized that the build process did not compile wxPython as dependency of kicad - it took the already compiled version provided by msys2.

Unfortunately this version is only working in a bash-like environment as the msys2 shell. Because Windows uses a semi-colon ( ; ) for path separator instead of colon, it seems python is having problems finding it’s DLLs. When cmake was populating the sources, it also prepared wxPython for building, and I found a few patches that seem to deal with exactly this issue. But when I compared with the installed py files for wxPython, I did not find the changes. This is what actually prompted my conclusion.

Is there a way to tell the build process to force a fresh build of wxPython before kicad is compiled? Or to build just the wxPython package and replace the msys2 provided one before I rebuild kicad?

Thanks to anyone who could help me figure it out!