Building WX with CheckInstall

CheckInstall is an alternative easy way to build and install packages.

The advantage is that this method uses the current distribution packaging facilities, so you can:

For more info see CheckInstall on Ubuntu howto

This method is reported to be working for wxPython 2.9.4.1 and 3.0.0.0 on:

It could work in other distros too.

Download sources

First, you need to grab the wxPython source code from Sourceforge.

Steps:

In a console (terminal, CTRL+ALT+T on Ubuntu), execute:

cd ~
wget "http://downloads.sourceforge.net/project/wxpython/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.bz2"
wget "http://downloads.sourceforge.net/project/wxpython/wxPython/2.9.4.0/wxPython-src-2.9.4.1.patch" 
tar xvjf wxPython-src-2.9.4.0.tar.bz2
patch -p 0 -d wxPython-src-2.9.4.0/ < wxPython-src-2.9.4.1.patch
mkdir wxPython-src-2.9.4.0/bld

Install dependencies

You will need to install the required packages with development tools (c++ compiler, python) and related libraries (gtk2 and optionally webkit, jpg, tiff, opengl, etc. if you need that support)

For Debian 6.0 do:

su apt-get install dpkg-dev build-essential swig python-dev libwebkit-dev libjpeg-dev libtiff-dev checkinstall freeglut3 freeglut3-dev libgtk2.0-dev  libsdl1.2-dev libgstreamer-plugins-base0.10-dev 

For Ubuntu 12.04 do:

sudo apt-get install dpkg-dev build-essential swig python2.7-dev libwebkitgtk-dev libjpeg-dev libtiff-dev checkinstall ubuntu-restricted-extras freeglut3 freeglut3-dev libgtk2.0-dev  libsdl1.2-dev libgstreamer-plugins-base0.10-dev 

For Ubuntu 12.10 do:

sudo apt-get install dpkg-dev build-essential swig python2.7-dev libwebkitgtk-dev libjpeg-dev libtiff-dev checkinstall ubuntu-restricted-extras freeglut3 freeglut3-dev libgtk2.0-dev  libsdl1.2-dev libgstreamer-plugins-base0.10-dev 

Configure and Build wxWidgets 2.9

Switch to the build directory created before, and call configure (/usr/local is the default prefix, use it to avoid having to change LD and PATH):

cd ~/wxPython-src-2.9.4.0/bld
../configure --prefix=/usr/local

Create a basic description for the package (this will show up on Software Center and similar tools):

cat << EOF > description-pak
wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
EOF

Build with checkinstall!

For Debian 6.0:

su checkinstall -y --pkgname=wxwidgets --pkgversion=2.9.4 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxwidgets.org/ --maintainer=reingart@gmail.com --requires=libatk1.0-0,libc6,libexpat1,libfontconfig1,libfreetype6,libgcc1,libgl1,libgtk2.0-0,libjpeg62,libpango1.0-0,libpng12-0,libsm6,libstdc++6,libtiff4,libxinerama1,zlib1g -D make install

For Ubuntu 12.04:

sudo checkinstall -y --pkgname=wxwidgets --pkgversion=2.9.4 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxwidgets.org/ --maintainer=reingart@gmail.com --requires=libc6,libgcc1,libgdk-pixbuf2.0-0,libgl1,libglib2.0-0,libgstreamer-plugins-base0.10-0,libgstreamer0.10-0,libgtk2.0-0,libjpeg8,libpango1.0-0,libpng12-0,libsm6,libstdc++6,libtiff4,libxinerama1 -D make install

For Ubuntu 12.10:

sudo checkinstall -y --pkgname=wxwidgets --pkgversion=2.9.4 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxwidgets.org/ --maintainer=reingart@gmail.com --requires=libc6,libgcc1,libgdk-pixbuf2.0-0,libgl1,libglib2.0-0,libgstreamer-plugins-base0.10-0,libgstreamer0.10-0,libgtk2.0-0,libjpeg8,libpango1.0-0,libpng12-0,libsm6,libstdc++6,libtiff5,libxinerama1,libxxf86vm1 -D make install

If everything went ok, you'll get a nice message saying that you package was build correctly, and you can install it with (select the one according your CPU architecture, 64 or 32 bits):

sudo dpkg -i wxwidgets_2.9.4-1_amd64.deb
sudo dpkg -i wxwidgets_2.9.4-1_i386.deb

You can uninstall it with your package manager (i.e. Synaptic) or simply:

sudo dpkg -r wxwidgets

Build wxPython 2.9

First, go to the wxPython subdirectory:

cd ~/wxPython-src-2.9.4.0/wxPython

Again, create a file description for the package, this time for wxPython itself:

cat << EOF > description-pak
wxWidgets Cross-platform C++ GUI toolkit (wxPython binding)
EOF

Then, build it!

Debian 6.0:

su checkinstall -y --pkgname=wxpython --pkgversion=2.9.4 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxpython.org/ --maintainer=reingart@gmail.com --requires=python-wxversion,python,libc6,libgcc1,libstdc++6,wxwidgets -D python setup.py install 

Ubuntu 12.10 and 12.04:

sudo checkinstall -y --pkgname=wxpython --pkgversion=2.9.4 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxpython.org/ --maintainer=reingart@gmail.com --requires=python-wxversion,python2.7,python,libc6,libgcc1,libstdc++6,wxwidgets -D python setup.py install 

If everything went ok, you'll get a nice message saying that you package was build correctly, and you can install it with (select the one according your CPU architecture, 64 or 32 bits):

sudo dpkg -i wxpython_2.9.4-1_amd64.deb
sudo dpkg -i wxpython_2.9.4-1_i386.deb

You can unistall it with:

sudo dpkg -r wxpython

wxPython 3.0.0

Download, uncompress and create build directory:

wget http://downloads.sourceforge.net/wxpython/wxPython-src-3.0.0.0.tar.bz2
tar xvjf wxPython-src-3.0.0.0.tar.bz2
cd wxPython-src-3.0.0.0/
mkdir bld
cd wxPython/

Build and install:

sudo checkinstall -y --pkgname=wxpython --pkgversion=3.0.0 --pkgrelease=1 --pkglicense=wxWidgets --pkgsource=http://www.wxpython.org/ --maintainer=reingart@gmail.com --requires=python-wxversion,python2.7,python -D  python build-wxpython.py --build_dir=../bld --install

Check your installation

In a terminal, you can test it:

reingart@s5ultra:~$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'2.9.4.1 gtk2 (classic)'

Note that with this method, it will import wx2.9 by default. If you use other applications that uses older wxPython version, you should read MultiVersionInstalls

Fresh-Install Dependencies

If you install the package (.deb) in a clean machine, you will need to install some packages at last to met the required dependencies. Python will be installed by default, but you may need to install webkit, opengl and other shared libraries if you use them.

Also, install python-wxversion if you use other wx versions (or remove that dependency from the checkinstall build). Luckily, the packaging system will show you unmet dependencies:

root@debian-vm:/home/reingart# dpkg -i wxpython_2.9.4-1_i386.deb
Seleccionando el paquete wxpython previamente no seleccionado.
(Leyendo la base de datos ... 135014 ficheros o directorios instalados actualmente.)
Desempaquetando wxpython (de wxpython_2.9.4-1_i386.deb) ...
dpkg: problemas de dependencias impiden la configuración de wxpython:
 wxpython depende de python-wxversion; sin embargo:
  El paquete `python-wxversion' no está instalado.
dpkg: error al procesar wxpython (--install):
root@debian-vm:/home/reingart# apt-get install python-wxversion
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
Configurando python-wxversion (2.8.10.1-3) ...
Procesando disparadores para python-central ...
Configurando wxpython (2.9.4-1) ...
root@debian:/home/reingart# dpkg -i wxpython_2.9.4-1_i386.deb
(Leyendo la base de datos ... 136806 ficheros o directorios instalados actualmente.)
Preparando para reemplazar wxpython 2.9.4-1 (usando wxpython_2.9.4-1_i386.deb) ...
Desempaquetando el reemplazo de wxpython ...
Configurando wxpython (2.9.4-1) ...

Shared Libraries (ldconfig)

IMPORTANT: you may need to run ldconfig the first time after installing the package, or you will get a "cannot open shared object file" when trying to import wx:

reingart@debian-vm:~$ su
Contraseña: 
root@debian-vm:/home/reingart# python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/wx-2.9.4-gtk2/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "/usr/local/lib/python2.6/dist-packages/wx-2.9.4-gtk2/wx/_core.py", line 4, in <module>
    import _core_
ImportError: libwx_gtk2u_xrc-2.9.so.4: cannot open shared object file: No such file or directory
>>> 
root@debian-vm:/home/reingart# ldconfig 
root@debian-vm:/home/reingart# python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'2.9.4.1 gtk2 (classic)' 

CheckInstall (last edited 2014-01-15 07:46:46 by 190-50-174-60)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.