[python-sybase] Some 0.36 problems

Gregory Bond gnb at itga.com.au
Tue, 29 Apr 2003 12:00:59 +1000


I'm trying to compile 0.36 on FreeBSD with FreeTDS 0.60 with Python 2.2.2 (But
I suspect this is not a FreeBSD-specific problem).  The command I am using is
	python setup.py build_ext -D WANT_THREADS,HAVE_FREETDS=60 -U WANT_BULKCOPY

but this is breaking:
	error: invalid command 'WANT_BULKCOPY' (no module named 'distutils.command.WANT_BULKCOPY')

Putting the -U before the -D also fails in interesting ways:
	python setup.py build_ext -U WANT_BULKCOPY -D WANT_THREADS,HAVE_FREETDS=60
	error: option -D requires argument

It works fine without the "=60", so I suspect a problem with the funky handling
of the -D<>= in setup.py.

A workaround is to make sure the -D HAVE_FREETDS=60 is the LAST argument, and 
not coalesce the -D arguments(i.e. "-D WANT_FOO -D HAVE_FREETDS=60" rather 
than "-D WANT_FOO,HAVE_FREETDS=60").

Or the following patch seems to handle the various permutations of -D and -U a 
bit better:

(beware whitespace munching from cut-n-paste)

--- setup.py-dist       Tue Apr 29 11:03:17 2003
+++ setup.py    Tue Apr 29 11:02:36 2003
@@ -116,6 +116,11 @@
         del sys.argv[i - 1]
     # Now set the TDS level the other other way.
     syb_macros.append(('HAVE_FREETDS', suffix[1:]))
+    if prefix:
+       # Handle -D WANT_X,HAVE_FREETDS=60 case
+       if prefix[-1] == ',':
+           prefix = prefix[:-1]
+       sys.argv[i:i] = [prefix]
     break

 for api in ('blk_alloc', 'blk_describe', 'blk_drop', 'blk_rowxfer_mult',