--- setup.py~	2007-02-14 07:53:41.000000000 -0500
+++ setup.py	2008-01-01 22:36:47.000000000 -0500
@@ -15,7 +15,7 @@
 from distutils.command.install_lib import install_lib
 
 # This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+disabled_module_list = ["zlib","_hashlib","_ssl","_bsddb","_sqlite3","_tkinter","bz2","gdbm","readline","_curses","_curses_panel"]
 
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (at the front) if
@@ -258,25 +258,12 @@
                 ('CPPFLAGS', '-I', self.compiler.include_dirs)):
             env_val = sysconfig.get_config_var(env_var)
             if env_val:
-                # To prevent optparse from raising an exception about any
-                # options in env_val that is doesn't know about we strip out
-                # all double dashes and any dashes followed by a character
-                # that is not for the option we are dealing with.
-                #
-                # Please note that order of the regex is important!  We must
-                # strip out double-dashes first so that we don't end up with
-                # substituting "--Long" to "-Long" and thus lead to "ong" being
-                # used for a library directory.
-                env_val = re.sub(r'(^|\s+)-(-|(?!%s))' % arg_name[1], '', env_val)
-                parser = optparse.OptionParser()
-                # Make sure that allowing args interspersed with options is
-                # allowed
-                parser.allow_interspersed_args = True
-                parser.error = lambda msg: None
-                parser.add_option(arg_name, dest="dirs", action="append")
-                options = parser.parse_args(env_val.split())[0]
-                if options.dirs:
-                    for directory in options.dirs:
+                # add all options in 'env_val' starting with
+                # 'arg_name' to the directory list 'dir_list'
+                # re and optparse have issues; so do this the "hard" way
+                for t_env_val in env_val.split ():
+                    if t_env_val.startswith (arg_name):
+                        directory = t_env_val.partition (arg_name)[2]
                         add_dir_to_list(dir_list, directory)
 
         if os.path.normpath(sys.prefix) != '/usr':
@@ -334,6 +321,10 @@
                 if item.startswith('-L'):
                     lib_dirs.append(item[2:])
 
+        # Ensure that /opt/local is always tried first
+        add_dir_to_list(inc_dirs, '/opt/local/lib')
+        add_dir_to_list(inc_dirs, '/opt/local/include')
+
         # Check for MacOS X, which doesn't need libm.a at all
         math_libs = ['m']
         if platform in ['darwin', 'beos', 'mac']:

