Thrift with Python on Win32


Thrift is a wonderful protocol, it’s all sum up in a single paragraph:

Thrift is a software framework for scalable cross-language services development. It combines a powerful software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, and Ruby. Thrift was developed at Facebook and released as open source.

And I really like it especially now since the system I’ve build and supporting now are written in python / c++ / ruby, these systems need to talk to each other, thrift, it’s like the answers to the prayers! : )

I have back-end systems that runs in Linux, and has client app that runs in Windows. Compiling and using thrift in Linux based system are straight forward, but unfortunately its not as easy in MS Windows platform.

At this time of writing, the code checkout from Thrift Apache Incubator still need to be further modify so that it can be compile with MSVC. These are the steps I’ve went through to get the thrift for python to build:

Ingredient:
1. Python 2.6.4
2. Visual C++ 2008 Express Edition
3. thrift-incubating-0.2.0.tar.gz
4. Windows Xp (obviously)

Read this post at http://issues.apache.org/jira/browse/THRIFT-252 to understands what needs to be edit.

Build thrift for python:
1. On Linux machine, apply the patch to the thrift source. Yes, on Linux machine, or you’ll have line ending problem.
2. Install python 2.6.4 and Visual C++ 2008 Express Edition on your Windows XP machine.
3. Copy the patched thrift source to your Windows machine, e.g: C:tmpthrift-0.2.0
4. Start a command prompt and follow the following steps:

C:> cd c:tmpthrift-0.2.0libpy
C:tmpthrift-0.2.0libpy> python setup.py install

That’s it! Everything should compile and install to your python site-package directory. To test just do the following:

C:> python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import thrift
>>>

No error is good news : )

I had to modify the patch by Michael Greene to fix a problem where the LITTLE_ENDIAN and BIG_ENDIAN was not define in my attempt of getting it build with MSVC9, other than that, everything else he did work marvelously, thanks! : )

Here’s the diff file that work for me, and the binary build that should work for python 2.6.4 on Windows.

just the diff file to modify fastbinary.c and setup.py
thrift-0.2.0-msvc-patch.diff

the patched source package:
thrift-0.2.0-msvc-patched.tar.gz

if you want to skip the compilation and just want to thrift right away with python 2.6.4, here’s the binary, extract and copy to C:Python26Libsite-packages
thrift-python-2.6.4-win32.zip

NOTE: Due to the source of thrift are still actively being improve, it’s best not to apply the diff to the source you’ve just check out, as it MAY have already been fix, its best to open up the related files, and read through, to make sure the patch is still needed.

Goodbye NucleusCMS.

I’ve been a happy NucleusCMS user since the beginning of me blogging years back, but the recent problem with the spam on the comment is forcing me to move to a blog engine that has better spam management interface. i.e: comment approval system… etc. Believe me, I’ve tried all the spam fighting plugins available to NucleusCMS already, but it work to an extend that I still need to manually clear out hundreds of spam message manually.

A short searching around the web shows me that wordpress seems to be a good replacement, I really like the admin interface, and it even come with import engine to convert an existing blog!

Following the guide at wordpress, with some luck, I’ve manage to get all the entry from my Nucleus blog into the newly installed wordpress : )

Some comment in blog post are missing, not sure why, and I can’t tell if this will help be combat the comment spam more effectively, but I’m still happy.

Getting Audacious2 onto your Ubuntu 9.04…

The default apt-get from 9.04 does not gives me audacious2, so, compiling it myself seems to be the only option.

1. Install the required build lib:
   $ sudo apt-get install libglib2.0-dev libgtk2.0-dev libmowgli-dev libmcs-dev libdbus-1-dev libdbus-glib-1-dev libxml2-dev libmad0-dev gstreamer0.10-fluendo-mp3 build-essential linux-headers-`uname -r` timidity

2. Download audacious2 source:
   $ wget http://redmine.atheme.org/attachments/download/69/audacious-2.0.1.tgz
   $ wget http://redmine.atheme.org/attachments/download/71/audacious-plugins-2.0.1.tgz

3. Extract and build audacious2:
   $ tar xzf audacious-2.0.1.tgz
   $ cd audacious-2.0.1
   $ ./configure
   $ make
   $ sudo make install

4. Extract and build audacious2 plug-ins:
   $ tar xzf audacious-plugins-2.0.1.tgz
   $ cd audacious-plugins-2.0.1
   $ ./configure
   $ make
   $ sudo make install

5. Install EQ presets:
   $ wget https://www.dropbox.com/sh/xkomrskyd8i9bqy/AAC_WHF87K738WbV56LAQJ8Qa/eq.preset
   $ mkdir ~/.config/audacious
   $ cp ./eq.preset ~/.config/audacious

That’s it!

The default installation has no equalizer presets, you’ll need to import one from WinAmp or adjust it yourself, thanks to Bryan Murdock you don’t need to : )

Do Not Tilt! or DIE!

I was holiday in Singapore, and I am surprise that, almost every vending-machine that I come across on the streets has this stickers on it that says “Vending machine design prevents dispensing free products or coins. NEVER ROCK OR TILT: Machine can fall over causing serious injury or death!

Free Upgrade on Dell D630!


I could not believe it! I’ve just got a free upgrade to a dual screen monitor on my 6 months old Dell D630 laptop! The only problem would be its unable to boot into windows anymore… Contacted the Dell support guys, apparently the motherboard has to be replace, and its back to single screen… what a bummer…

oh well… Dell Sucks… as usual…

I want pretty and I want my TitleBar!

Just got back my Compaq V3000 laptop from the dealer. Its a little over 2 years old, but it has been sent back for mother board replacement for the 3rd time! (glad that I had the extended warranty period to 3 years)

Figure that I can put Ubuntu 8.10 on it while waiting for 9.04 to come alone in about two weeks time.

Installation went well, NVidia (NVIDIA-Linux-x86_64-96.43.11-pkg2.run) driver seems to install properly as well.

Reboot and damn! Wher’s my window title bar? and also the Terminal windows is un readable as well. Turning off the visual effect seems to give me back the title bar, but that’s not the solution.

For the next 5 hours is frantic googling for solutions, and it really is funny that so many had the same problem, and offered bloody lot of suggestion that is not working, until came along this article Ubuntu Desktop Effects – Fixing the missing titlebar and it hit the right spot. Just these two lines in your /etc/X11/xorg.conf under the ‘Section “Device”‘:

Option "AddARGBVisuals" "True"
Option "AddARGBGLXVisuals" "True"

: )