Survey of complex usage of distutils.
Dave Cole
djc at object-craft.com.au
Wed May 21 19:16:03 EDT 2003
In my Sybase module setup.py I have this flakey and nasty piece of
code to handle a distutils limitation that probably should not be
there.
# distutils does not allow -D HAVE_FREETDS=60 so I have to find this
# argument myself and remove it from sys.argv and set the macro via
# the define_macros argument to the extension module.
for i in range(1, len(sys.argv)):
# Find arguments like '-DHAVE_FREETDS=60' and variants
parts = string.split(sys.argv[i], 'HAVE_FREETDS')
if len(parts) == 1:
continue
prefix, suffix = parts[:2]
# Ignore -DHAVE_FREETDS which does not set a value (=blah)
if not suffix or suffix[0] != '=':
continue
# Remove this argument from sys.argv
del sys.argv[i]
# If -D was in previous argument then remove that as well
if not prefix and sys.argv[i - 1] == '-D':
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
--
http://www.object-craft.com.au
More information about the Python-list
mailing list