Many thanks for incorporating the previous patch I submitted for detection of the DB2 installation paths in setup.py.
Unfortunately I recently found several bugs in my detection code, specifically related to 64-bit instances under Linux, and changes in v9.
Firstly, the code is doing the "wrong thing" with regard to library paths under Linux/UNIX. At the moment, the code is attempting to detect the DB2 installation path. This is fine on Windows, but on Linux/UNIX it should attempt to find the "current instance path" (typically a home directory). The current instance path on Linux/UNIX always contains a symlink connecting "sqllib/lib" to the correct library path in the installation directory (either "lib" for 32-bit instances, or "lib64" for 64-bit instances).
Another problem with the detection routine is that it only falls back to the user-specified path if detection fails, which prevents the user from easily overriding the result (useful in case they have multiple DB2 installations - possible in v9 and above - and they wish to compile against a version other than the one set as the default).
Finally, I discovered the "db2level" detection method was broken with v9 which added an extra line of output to provide the name of the default installation.
The attached patch replaces the overly complex detection routines with a far simpler one that just checks for the location of the "db2" client executable in the PATH. This provides the "bin" sub-directory of the installation path (on Windows), or instance path (on Linux/UNIX), from which it is trivial to determine the include and library paths. It also permits the user to easily override any of the detection results by setting constants at the start of the script.
The script has been tested successfully in the following environments:
DB2 v9.1 32-bit on Linux
DB2 v8.2 64-bit on Linux
DB2 v8.2 32-bit on Linux
Unfortunately, I haven't had a chance to test it on Windows yet (I haven't got my Windows environment setup for compiling Python modules). I'd be grateful if someone could test compiling from source using the patched script on Windows. I don't anticipate any problems on 32-bit Windows, but I suspect there may be an issue on 64-bit Windows (DB2 might be using a weird library path on this platform).
Improved DB2 path detection for setup.py
Logged In: YES
user_id=123639
Originator: YES
Forgot to mention: the patch is against CVS HEAD of the PyDB2_v1.1 module. Given that it replaces a rather large chunk of the script, the patch probably looks quite messy. If you'd prefer a straight copy of the updated script, let me know.
Logged In: YES
user_id=2003727
Originator: NO
Hi, I'd be grateful for the whole script instead, it's simpler for me just to diff.
I'll be happy to test it on Win32, but unfortunately I don't have access to any Win64 machines. I'm ok with releasing it as is, after some testing, as it's not too hard just to set the path by hand. I'll add some message to that effect as a hint.
Patched version of setup.py
Logged In: YES
user_id=123639
Originator: YES
Not a problem - here's the patched version of setup.py with Windows (CRLF) line endings.
File Added: setup.py