30 October 2011

Building PyGTK for MyPaint

Continued from here. MyPaint require that PyGTK (GDK) to support numpy otherwise mypaint won't run. The debate is people said that the proper way to build python module is by using MSVC compiler since that's what python windows used with. While there is officially a library for GCC named libpythonXY.a some argue how stable a mixed build is.

IMHO gtk binding is bridging python and GTK, so what's the point using MSVC if GTK Runtime was build with GCC(MinGW)? Nah that's just my excuse because I don't know how to build it with MSVC :)

I've tested that I can use MinGW's pygtk with MSVC's pygobject with MinGW's GTK with MSVC's Python 2.6 and MinGW's MyPaint.... errr

Alright lets make it all MinGW's except for python shall we:

Building pygtk with MinGW could quite troublesome since official python shipped with no pkgconfig facility. So we need to define these first:

Compiler's flags
export PATH+=":/c/GTK/bin:/c/python26"
export lt_cv_deplibs_check_method="pass_all"
export PKG_CONFIG_PATH="c:\\GTK\\lib\\pkgconfig;c:\\python26\\lib\\pkgconfig"
export CXXFLAGS="-Os -mtune=pentium3
-I/c/python26/include -I/c/GTK/include"
export CFLAGS="-Os -mtune=pentium3
-I/c/python26/include -I/c/GTK/include"
export LDFLAGS="
-L/c/GTK/lib -L/c/python26/libs -lpython26 -Wl,-s"

Compiling PyGObject:

    PyGObject, get latest version then extract to d:\sources, run msys terminal and navigate to pygobject's source folder. Run "configure --without-ffi --disable-introspection --prefix=c:/python26", now we need to inject some LDFLAGS that won't accepted during configure but required during compile. Since I'm not fancied by CLI I use GrepWin:

then convert the wrong slashes:

then optionally a slight change (since it cause error):

once all done, make -j2 install

Compiling PyCairo:

    PyCairo, nothing special here just configure and make.

Compiling PyGTK:

    PyGTK,we need to enable numpy support. First download numpy superpack, then open numpy-1.6.1-win32-superpack-python2.6.exe with 7-zip inside you'll find separate installer for specific optimization (nosse, sse2 and sse3) as we targeted pentium3 unfortunately we need to use the nosse installer one.
    Run "configure --without-glade --prefix=c:/python26" the rest is same to pygobject.  If configure did not detect numpy we need to copy c:\python26\lib\site-packages\numpy\core\include\numpy folder to c:\python26\include and  re-run configure.

No comments:

Post a Comment