WxPythonCygwin

From GNU Radio
Jump to navigation Jump to search

How to Build and Install wxPython for Microsoft Windows under Cygwin

Introduction

This procedure produces a version of wxPython that works with the Cygwin build of Python 2.6 (using the Cygwin C runtime library) and uses native Windows graphics (i.e., direct GDI calls, not X Window calls). This combination is intended to work with a Cygwin version of GNU Radio (one that also uses the Cygwin C runtime library).

These instructions are current as of December 2010 and assume you are using wxPython 2.8.11.0 and current versions of all Cygwin tools and libraries. Updates have been applied to be current as of January 2015 using wxPython 3.0.2.0. These instruction will probably work with later releases as well, but this remains to be seen.

Step-by-Step Instructions.

Feel free to modify this recipe to suit your preferences:

(1) Download the wxWidgets and wxPython source code from the wxPython-src link at http://www.wxpython.org/download.php#sources to /usr/src.

(2) Unpack the source distribution:

cd /usr/src
tar -jxf wxPython-src-2.8.11.0.tar.bz2

This will create the directory /usr/src/wxPython-src-2.8.11.0. For convenience (especially if you want to put your code somewhere else) I will call this directory $WXDIR in what follows. To make the commands work as written, run the command

export WXDIR=/usr/src/wxPython-src-2.8.11.0

(3) Create a build directory:

cd $WXDIR
mkdir build-local

Choose any name for your build directory; I use build-local here.

(4) Configure wxWidgets:

cd $WXDIR/build-local
../configure --with-msw

(4a) Apply patches:

These instructions apply to release 2.8.11.0. They may not be needed in later versions.

Find the file build-local/lib/wx/include/msw-ansi-release-2.8/wx/setup.h and after the line:

#define wxUSE_DATEPICKCTRL 1

add the line:

#define wxUSE_DATEPICKCTRL_GENERIC 1

If you are installing release 3.0.2.0 or later, the wxUSE_DATEPICKCTRL_GENERIC definition already exists in setup.h but still needs to be modified.
Find the file build-local/lib/wx/include/msw-unicode-3.0/wx/setup.h, find the above #define wxUSE_DATEPICKCTRL_GENERIC line, and update the value from 0 to 1.

This change must be repeated if you rerun ../configure.

You also need to apply a patch to Python 2.x distutils. For python 2.6, download the patch file attachment:cygwinccompiler.patch to /usr/lib/python2.6/distutils and apply the patch with

cd /usr/lib/python2.6/distutils
patch -i cygwinccompiler.patch

For Python 2.7, download the patch file attachment:cygwinccompiler27.patch to /usr/lib/python2.7/distutils and apply the patch with

cd /usr/lib/python2.7/distutils
patch -i cygwinccompiler27.patch

This change only needs to be repeated if you reinstall python.

(5) Compile and link wxWidgets:

cd $WXDIR/build-local
make
make -C contrib/src/stc

You may do make -C contrib/src/gizmos to compile and link the gizmos package. The gizmos package has some fun tools for developing Python programs but is not required for GNU Radio.
@ @
With Cygwin 1.7.1, you may get an error during the make about conflicts between winsock.h and select.h. You can work around this error by temporarily renaming select.h:

cd /usr/include/sys
mv select.h select.h-x

and repeating the make. You will need to undo the renaming

cd /usr/include/sys
mv select.h-x select.h

before going to the next step.

@ @

(6) Install wxWidgets:

cd $WXDIR/build-local
make install
make -C contrib/src/stc install

This installs the wxWidgets DLLs in /usr/local/lib. If you compiled the gizmos package, install it with make -C contrib/src/gizmos install.

Depending on how you installed Cygwin, you might get an error like

/usr/bin/install -c -d /usr/local/lib
/usr/bin/install: cannot change permissions of @/usr/local/lib': Permission denied

You can fix this by changing /usr/local/lib and /usr/local/bin to give you ownership of these directories. See the instructions in hints, tips, known problems, and solutions for Windows.

@ @

(7) Move the DLLs to /usr/local/bin:

mv /usr/local/lib/cygwx*.dll /usr/local/bin

Unless /usr/local/lib is in your PATH, it is easier to have the DLLs in /usr/local/bin. (If you know how to make the configure/build process do this for you, please let me know.)

@ @

(8) Test the build and installation of wxWidgets:

cd $WXDIR/build-local/samples/minimal
make
./minimal.exe

This should produce an empty window to prove that wxWidgets works.

@ @

(9) Build wxPython:

cd $WXDIR/wxPython
python setup.py build_ext --inplace WXPORT=msw COMPILER=cygwin BUILD_GLCANVAS=0 BUILD_GIZMOS=0 UNICODE=0

This builds the Python connection to wxWidgets. If you built gizmos you should omit the BUILD_GIZMOS=0 flag.

@ @

(10) Install wxPython:

cd $WXDIR/wxPython
python setup.py install WXPORT=msw COMPILER=cygwin BUILD_GLCANVAS=0 BUILD_GIZMOS=0 UNICODE=0

This installs wxPython. If you build gizmos you should omit the BUILD_GIZMOS=0 flag.

@ @

(11) Test your wxPython installation:

cd $WXDIR/wxPython/demo
python demo.py

This should present you with a green snake (and a window showing what wxPython can do). If this works, you are done. You should now be able to "import wx", build gr-wxgui, and "import wxgui".

If demo.py doesn't work your version of Cygwin may be out of date (see hints, tips, known problems, and solutions for Windows).

Notes

  • The patch in statbmp.patch is not needed with wxPython 2.8.0.1 or later
  • The patches in config.patch and treelistctrl.cpp.patch are not needed with wxPython 2.8.7.1