Build PySWT Toolchain under windows

  1. Download and install Python 2.4 on C:\Python24 from http://www.python.org.
  2. Copy Python24.dll from \Windows\System32 to C:\Python24\libs if it is not there.
  3. Download and install MSYS (MSYS-1.0.10.exe) on C:\msys\ from http://www.mingw.org.
  4. Download and install MinGW? (MinGW?-4.1.1.exe) on C:\MinGW?\ from http://www.mingw.org. The following components have to been installed:
    • runtime, w32api, binutil
    • gcc-core, gcc-g++, gcc-java
    • mingw32-make
  5. Mount MinGW? and Python in MSYS
    • start "MinGW?->MSYS->msys"
    • echo "C:/MinGW? /mingw" > /etc/fstab
    • echo "C:/Python24 /python" >> /etc/fstab
  6. Download and install libiconv (libiconv-1.9.2.tar.gz) from http://www.gnu.org/software/libiconv(needed by libgcj)
    • tar zxvf libiconv-1.9.2.tar.gz
    • cd libiconv-1.9.2
    • ./configure --prefix=/mingw --enable-static=yes --enable-shared=no
    • make
    • make install
  7. Download and Install SIP (sip-4.2.1.tar.gz) from http://www.riverbankcomputing.co.uk/sip/ (note, sip-4.2.1.tar.gz is not available on their website since sip 4.3 is out, but you can download from http://pyqwt.sourceforge.net/support/
    • start a "command prompt" window
    • set PATH=c:\Python24;c:\MinGW?\bin;\%PATH\% (add python, mingw/bin into path)
    • python configure.py -k -p win32-g++ AR="ar rcs" (add -k for building SIP as static library)
    • mingw32-make
    • mingw32-make install

Build PySWT under windows

  1. Prepare environment
    • start "MinGW?->MSYS->msys"
    • export PATH=/c/Python24:$PATH (add python into PATH or you can add it into /etc/profile)
  2. Download and untar PySWT-xxx-src.tar.gz
    • tar zxvf pyswt-xxx-src.tar.gz
  3. Download swt-3.1-win32-win32-x86.zip from www.eclipse.org, unzip it and then unzip src.zip into jswt/
  4. Build libswt.a
    • cd pyswt-xxx/jswt
    • python patch.py java (patch some SWT java files)
    • make noawt (remove org/eclipse/swt/awt directories)
    • make static
  5. Generate SWT Header files
    • make headers (Do multiple time)
    • python patch.py header (patch some SWT header files)
  6. Build jsip
    • cd pyswt-xxx/jsip
    • python genmake.py
    • mingw32-make
    • cp jsip.exe /c/Python24
  7. Generate PySWT source files
    • cd pyswt-xxx/sip
    • make win32
  8. Build pyswt.pyd
    • cd pyswt-xxx/src
    • python genmake.py
    • mingw32-make
  9. Install pyswt
    • copy pyswt.pyd to c:\python24\Lib\site-packages
    • copy swt-win32-3138.dll, swt-gdip-3138.dll (swt-awt-win32-3138.dll if you didn't remove awt/ directory in swt source codes) to some directory in system, say C:\Windows\System32.
  10. Run sample
    • cd pyswt-xxx/samples
    • python test.py

Others

   flex -olexer.c lexer.l
  • generate parser.h parser.c
   bison -d -oparser.c parser.y

    /* The sip module will be builtin. */
	extern void initsip(void);

    struct _inittab builtin_modules[] = {
		{"sip", initsip},
		{NULL, NULL}
	};

    PyImport?_ExtendInittab(builtin_modules);
  • pass static=1 when generate Makefile (-DSIP_STATIC_MODULE in Makefile)

    JvInitClass?(&org::eclipse::swt::internal::image::GIFFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::JPEGFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::OS2BMPFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::PNGFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::TIFFFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::WinBMPFileFormat?::class$);
    JvInitClass?(&org::eclipse::swt::internal::image::WinICOFileFormat?::class$);
Valid XHTML 1.0! Valid CSS!