[python-sybase] Some 0.36 problems

Dave Cole djc at object-craft.com.au
02 May 2003 09:27:31 +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

I didn't know that you could coalesce macros like that.  What a
strange thing to do while not allowing values to be assigned.

> 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.

Yup.  It would be really good if there was a way around that
abomination but the FreeTDS people do not put their version identifier
in any useful format that can be used by the C preprocessor.

> 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',

Applied.  Thanks for that.

- Dave

-- 
http://www.object-craft.com.au