Ticket #13778: patch-setup.py

File patch-setup.py, 2.7 KB (added by mdickens@…, 16 years ago)

Replacement patch-setup.py to correct processing of -I directives

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