Tuesday, February 19, 2008

Python, kinterbasdb and 64bit MacOSX 10.5

Now we have 64bit builds of Firebird 2.1 for MacOSX 10.5, we have issues trying to test them properly using the Firebird QMTest QA suite. This QA suite relies on Python and kinterbasdb. Currently Philippe Makowski has been able to run the tests from a 64bit Linux client. But is unable to run the tests locally. Well currently the python framework that comes with MacOSX 10.5 is only 32bit and this forces a 32bit build of kinterbasdb, since the build environment of kinterbasdb uses distutils to use the same compile switches as python. So I thought I would have a look at the issue and see if I could build a 64bit version of kinterbasdb for MacOSX 10.5.

This is how I did it...

1. Download the source distribution of Python
2. Edit configure.in and change line 817, so it looks like this
BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd -arch x86_64"
3. Make sure that (just in case)
a, CFLAGS, CXXFLAGS and LDFLAGS are exported with -arch x86_64
e.g. export CFLAGS='-arch x86_64'
4. autoconf
5. ./configure --disable-toolbox-glue
This disables Carbon as its only 32bit and you will get compile errors if you don't
We are not building a framework, or a universal binary just a simple standalone version of 64bit python. So do not enable those options.
6. make
You may get a warning/errors possibly in some of the extensions e.g.
ld warning in /System/Library/Frameworks/TK.framework/Tk missing required architecture x86_64 in file.
I guess you would have to download the relevant code and rebuild these as 64bit if you need them. But since we are only interested in kinterbasdb I guess I can afford to ignore it.
A check on the built python.exe shows that it is Mach-O 64 bit executable.

Now we need to build kinterbas db using this python.exe
1. Download kinterbasdb from sourceforge
-> 2. Replace in the kinterbasdb source the __init__.py with this one :
Note I forgot to add this step when I wrote the original instructions.
3. Make sure you have the 64bit Firebird 2.1 for MacOSX installed
4. Make sure you are running as root
su and log in
export CFLAGS, CXXFLAGS and LDFLAGS ='-arch x86_64'
The install option will want to put the kinterbasdb in /usr/local/lib/python2.5
Although I suspect you can change this by using a different --prefix when you build python
5. pathtojustbuilt64bitpython/python.exe setup.py install
pathtojustbuilt64bitpython/python.exe setup.py build
if you just want to build it.
6. You can check what you have installed by
file /usr/local/lib/python2.5/site-packages/kinterbasdb/_kinterbasdb.so
Mach-O 64bit bundle x86_64

Now we can test it...
create a database using isql
>>> import kinterbasdb;kinterbasdb.init(type_conv=200)
Don't use mx.DateTime use the default python DateTime
>>> con = kinterbasdb.connect(dsn='localhost:/pathtodd/test.fdb', user='sysdba', password='masterkey')

It works ....


Jobin said...

Very useful notes on how to build from source. I think this should go to offical documentation. because many users like me are using python to connect to firebird.

By the way are you able to connect without the __int__.py fix you have?

Thanks a lot.

Paul Beach said...

I missed a step - apologies, I have now corrected the issue. you do need the __init__.py from Firebird QA on Sourceforge.

Jeff said...

I am trying to set up QMTest with Firebird 2.1 and Python 2.6 on a Windows 7 machine with an AMD Phenom 64-bit processor, with no luck yet. Any suggestions?

Unknown said...

Jeff, the Windows AMD64 KInterbasDB installer for Python 2.6 didn't work for you?

Jeff said...

Thank you for the link to the 64-bit version, I could not find it.

However, I still am unable to run qmedit. When I try to launch it from a command window, I get the following messages:




C:\>cd \SVNRepository\qmedit\

Traceback (most recent call last):
File "C:\SVNRepository\qmedit\qmedit.py", line 30, in module
import ui
File "C:\SVNRepository\qmedit\ui.py", line 7, in module
import wx
ImportError: No module named wx

Any ideas?

Unknown said...

Jeff, qmedit is not necessary to run qmtest or even edit tests (you can use the qmtest HTML GUI via gui command), it's just another GUI tailored for specific needs of Firebrid QA people to make them more effective. qmedit is a desktop GUI application that uses wxWindows (i.e. you'll need wxPython installed).

BTW, if you're after running Firebird QA suite, then you don't need QMTest anymore, as we now use our own home-brew system (fbtest). It's in our SVN and binaries are at http://www.firebirdsql.org/download/rabbits/pcisar/
Unfortunately, it's not fully documented at our website (there is just readme in distribution package).

If you would have any questions, you can contact me directly ( see http://www.firebirdsql.org/index.php?op=rabbits&info=pcisar).