09 March 2016

Getting WikidPad running on Mac OS-X El Capitan

WikidPad, the excellent personal wiki tool and my knowledge-base of choice hasn't been working on my mac ever since my fresh install of El-Capitan, some time ago. There was some issue with the package installer for wxPython not running on El-Capitan, and just too much real work demanding my attention ... 

So I made do with the version on my Ubuntu desktop, and by accessing the sync'd plain text wiki files directly from my text editor - Sublime Text - on my mac. Good enough to survive with - but just barely so.

Today I decided that the time had come to end the pain, and so here is a brief log of the fix - to help anyone else that needs this, including quite possibly my future-self.

Instructions:

To start off with I chose to use an older version 2.8 of wxPython, because of numerous reports I'd seen on the WikidPad forums of errors while running under wxPython3
And as always, I use the latest release of Wikidpad - in this case version 2.3beta13_01.

- I used wxPython2.8-osx-unicode-2.8.12.0-universal-py2.7.dmg

2) Change security on your mac to installs from all developers. You get a weird message saying that the package doesn't exist if you don't. 

3) The wxPython installer package now runs a little further before failing with another weird error to the same effect: 
The Installer could not install the software because there was no software found to install.

This apparently happens because wxPython is using a legacy script, and the bundled installers were deprecated and are (as of El Capitan release) unsupported. 
The solution was found on the following stack-overflow page: http://stackoverflow.com/questions/34402303/install-wxpython-in-osx-10-11

I'll repeat the instructions here. Use the name of your wxPython file in place of wxPython-ABC below (for the file we chose above replace wxPython-ABC with wxPython2.8-osx-unicode-2.8.12.0-universal-py2.7)

3.0) Let's assume that you have already mounted the dmg and you have moved the pkg folder to a working folder ~/repack_wxpython.
cd ~/repack_wxpython
cp -r /Volumes/wxPython/wxPython-ABC.pkg .
3.1) Use the pax utility to extract the payload file (pax.gz) from Contents/Resources to a folder that will become the root of your new package.
mkdir pkg_root
cd pkg_root
pax -f ../wxPython-ABC.pkg/Contents/Resources/wxPython-ABC.pax.gz -z -r
cd ..
3.2) Rename the bundle's preflight/postflight scripts, to preinstall/postinstall scripts, as required for flat packages, in a scripts folder.
mkdir scripts
cp wxPython-ABC.pkg/Contents/Resources/preflight scripts/preinstall
cp wxPython-ABC.pkg/Contents/Resources/postflight scripts/postinstall
3.3) Create the flat package using the pkgbuild tool:
pkgbuild --root ./pkg_root --scripts ./scripts --identifier com.wxwidgets.wxpython wxPython-ABC-output.pkg

4) Once that is complete, install wxPython from the new output package. If you use the version I did, that will be wxPython2.8-osx-unicode-universal-py2.7-output.pkg. Finally, wxPython should install!
5) Now, download WikidPad source from http://wikidpad.sourceforge.net/. The direct link for the version I used is http://downloads.sourceforge.net/wikidpad/WikidPad-2.3beta13_01-src.zip

6) Run WikidPad from source:
cd to directory where you unzipped the source - in my case:
cd ~/apps/wikidpad/WikidPad23 
then launch WikidPad with the following:
arch -i386 python2.7 WikidPad.py 

7) At this stage I got a python error from wxPython:
File "/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 3917, in Bind
    assert callable(handler)
AssertionError

8) Instead of tracking this down properly, I used a temporary fix by commenting out the assert: 
- open "/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 3917
- comment out line 3917
  assert callable(handler) 

9) Wikidpad opens and runs! .. but will only work on wikis using the Gadfly db - No SQLite wikis run. I saw the following error when trying to open my wiki:
ERROR: required data handler "original_sqlite" unknown to WikidPad

10) To fix this, I had to use homebrew to install sqlite3 with universal support:
brew install sqlite3 --universal

11) Then soft link the sqlite3 dynamic library into the WikidPad source folder
cd ~/apps/wikidpad/WikidPad23/
sudo ln -s /usr/lib/libsqlite3.dylib libsqlite3.0.dylib

12) Try running again from source ....
cd ~/apps/wikidpad/WikidPad23
arch -i386 python2.7 WikidPad.py

... and WikidPad should launch fine now.

No comments :