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.5 (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 September 2009 and assume you
are using wxPython 2.8.10.1
and current versions of all Cygwin tools and libraries. They 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.10.1.tar.bz2

This will create the directory /usr/src/wxPython-src-2.8.10.1. 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.10.1
(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.10.1. They may or may not be needed in
later versions.

Download wxPython-2.8.10.1.patch to $WXDIR using the Original Format link
at the bottom of the page.
Apply the patches with
cd $WXDIR
patch -p0 -b -i wxPython-2.8.10.1.patch
You will also need to 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
(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. (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

statbmp.patch - statbmp patch for wxWidgets on Cygwin (1.5 KB) Don Ward, 08/26/2006 01:04 AM

config.patch - patch file for wxPython config.py on Cygwin (597 Bytes) Don Ward, 08/26/2006 01:25 AM

treelistctrl.cpp.patch - patch for gizmos/wxCode/src/treelistctrl.cpp for wxPython 2.8.0.1 (430 Bytes) Redmine Admin, 12/31/2006 09:58 PM

wxPython-2.8.10.1.patch - patches for wxPython-2.8.10.1 (1.5 KB) Redmine Admin, 09/24/2009 05:46 PM





注:How to Build and Install wxPython for Microsoft Windows under Cygwin(原文出处,翻译整理仅供参考!