summaryrefslogtreecommitdiff
path: root/lang/python24/patches/patch-am
blob: 44d081f29b35d64000e6e42f302aa856e2c800b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
$NetBSD: patch-am,v 1.8 2011/10/31 06:50:53 sbd Exp $

--- setup.py.orig	2006-10-08 17:41:25.000000000 +0000
+++ setup.py
@@ -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 = ["_bsddb", "_curses", "_curses_panel", "_tkinter", "gdbm", "pyexpat", "readline"]
 
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (at the front) if
@@ -239,9 +239,15 @@
         return sys.platform
 
     def detect_modules(self):
-        # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        # Add the buildlink directories for pkgsrc
+        if os.environ.has_key('BUILDLINK_DIR'):
+            dir = os.environ['BUILDLINK_DIR']
+            libdir = dir + '/lib'
+            incdir = dir + '/include'
+            if libdir not in self.compiler.library_dirs:
+                self.compiler.library_dirs.insert(0, libdir)
+            if incdir not in self.compiler.include_dirs:
+                self.compiler.include_dirs.insert(0, incdir)
 
         # Add paths to popular package managers on OS X/darwin
         if sys.platform == "darwin":
@@ -485,9 +491,7 @@
                                depends = ['socketmodule.h']) )
         # Detect SSL support for the socket module (via _ssl)
         ssl_incs = find_file('openssl/ssl.h', inc_dirs,
-                             ['/usr/local/ssl/include',
-                              '/usr/contrib/ssl/include/'
-                             ]
+                             []
                              )
         if ssl_incs is not None:
             krb5_h = find_file('krb5.h', inc_dirs,
@@ -495,9 +499,7 @@
             if krb5_h:
                 ssl_incs += krb5_h
         ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
-                                     ['/usr/local/ssl/lib',
-                                      '/usr/contrib/ssl/lib/'
-                                     ] )
+                                     [] )
 
         if (ssl_incs is not None and
             ssl_libs is not None):
@@ -515,172 +517,79 @@
         # similar functionality (but slower of course) implemented in Python.
 
         # Sleepycat Berkeley DB interface.  http://www.sleepycat.com
-        #
-        # This requires the Sleepycat DB code. The earliest supported version
-        # of that library is 3.2, the latest supported version is 4.4.  A list
-        # of available releases can be found at
-        #
-        # http://www.sleepycat.com/update/index.html
-
-        max_db_ver = (4, 4)
-        min_db_ver = (3, 2)
-        db_setup_debug = False   # verbose debug prints from this script?
-
-        # construct a list of paths to look for the header file in on
-        # top of the normal inc_dirs.
-        db_inc_paths = [
-            '/usr/include/db4',
-            '/usr/local/include/db4',
-            '/opt/sfw/include/db4',
-            '/sw/include/db4',
-            '/usr/include/db3',
-            '/usr/local/include/db3',
-            '/opt/sfw/include/db3',
-            '/sw/include/db3',
-        ]
-        # 4.x minor number specific paths
-        for x in (0,1,2,3,4):
-            db_inc_paths.append('/usr/include/db4%d' % x)
-            db_inc_paths.append('/usr/include/db4.%d' % x)
-            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
-            db_inc_paths.append('/usr/local/include/db4%d' % x)
-            db_inc_paths.append('/pkg/db-4.%d/include' % x)
-            db_inc_paths.append('/opt/db-4.%d/include' % x)
-        # 3.x minor number specific paths
-        for x in (2,3):
-            db_inc_paths.append('/usr/include/db3%d' % x)
-            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
-            db_inc_paths.append('/usr/local/include/db3%d' % x)
-            db_inc_paths.append('/pkg/db-3.%d/include' % x)
-            db_inc_paths.append('/opt/db-3.%d/include' % x)
-
-        # Add some common subdirectories for Sleepycat DB to the list,
-        # based on the standard include directories. This way DB3/4 gets
-        # picked up when it is installed in a non-standard prefix and
-        # the user has added that prefix into inc_dirs.
-        std_variants = []
-        for dn in inc_dirs:
-            std_variants.append(os.path.join(dn, 'db3'))
-            std_variants.append(os.path.join(dn, 'db4'))
-            for x in (0,1,2,3,4):
-                std_variants.append(os.path.join(dn, "db4%d"%x))
-                std_variants.append(os.path.join(dn, "db4.%d"%x))
-            for x in (2,3):
-                std_variants.append(os.path.join(dn, "db3%d"%x))
-                std_variants.append(os.path.join(dn, "db3.%d"%x))
-
-        db_inc_paths = std_variants + db_inc_paths
-
-        db_ver_inc_map = {}
-
-        class db_found(Exception): pass
+        class Notfound(Exception): pass
         try:
             # See whether there is a Sleepycat header in the standard
             # search path.
-            for d in inc_dirs + db_inc_paths:
-                f = os.path.join(d, "db.h")
-                if db_setup_debug: print "db: looking for db.h in", f
-                if os.path.exists(f):
-                    f = open(f).read()
-                    m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
-                    if m:
-                        db_major = int(m.group(1))
-                        m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
-                        db_minor = int(m.group(1))
-                        db_ver = (db_major, db_minor)
-
-                        if ( (not db_ver_inc_map.has_key(db_ver)) and
-                           (db_ver <= max_db_ver and db_ver >= min_db_ver) ):
-                            # save the include directory with the db.h version
-                            # (first occurrance only)
-                            db_ver_inc_map[db_ver] = d
-                            print "db.h: found", db_ver, "in", d
-                        else:
-                            # we already found a header for this library version
-                            if db_setup_debug: print "db.h: ignoring", d
-                    else:
-                        # ignore this header, it didn't contain a version number
-                        if db_setup_debug: print "db.h: unsupported version", db_ver, "in", d
-
-            db_found_vers = db_ver_inc_map.keys()
-            db_found_vers.sort()
-
-            while db_found_vers:
-                db_ver = db_found_vers.pop()
-                db_incdir = db_ver_inc_map[db_ver]
-
-                # check lib directories parallel to the location of the header
-                db_dirs_to_check = [
-                    os.path.join(db_incdir, '..', 'lib64'),
-                    os.path.join(db_incdir, '..', 'lib'),
-                    os.path.join(db_incdir, '..', '..', 'lib64'),
-                    os.path.join(db_incdir, '..', '..', 'lib'),
-                ]
-                db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
-
-                # Look for a version specific db-X.Y before an ambiguoius dbX
-                # XXX should we -ever- look for a dbX name?  Do any
-                # systems really not name their library by version and
-                # symlink to more general names?
-                for dblib in (('db-%d.%d' % db_ver),
-                              ('db%d%d' % db_ver),
-                              ('db%d' % db_ver[0])):
-                    dblib_file = self.compiler.find_library_file(
-                                    db_dirs_to_check + lib_dirs, dblib )
-                    if dblib_file:
-                        dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
-                        raise db_found
-                    else:
-                        if db_setup_debug: print "db lib: ", dblib, "not found"
-
-        except db_found:
-            print "db lib: using", db_ver, dblib
-            if db_setup_debug: print "db: lib dir", dblib_dir, "inc dir", db_incdir
-            db_incs = [db_incdir]
-            dblibs = [dblib]
-            # We add the runtime_library_dirs argument because the
-            # BerkeleyDB lib we're linking against often isn't in the
-            # system dynamic library search path.  This is usually
-            # correct and most trouble free, but may cause problems in
-            # some unusual system configurations (e.g. the directory
-            # is on an NFS server that goes away).
-            exts.append(Extension('_bsddb', ['_bsddb.c'],
-                                  library_dirs=dblib_dir,
-                                  runtime_library_dirs=dblib_dir,
-                                  include_dirs=db_incs,
-                                  libraries=dblibs))
-        else:
-            if db_setup_debug: print "db: no appropriate library found"
-            db_incs = None
-            dblibs = []
+            bdb_type = os.environ['PY_BDB_TYPE']
+            db_incs = [os.environ['PY_BDB_INCDIRS']]
             dblib_dir = None
+            dblibs = None
 
-
-        # Look for Berkeley db 1.85.   Note that it is built as a different
-        # module name so it can be included even when later versions are
-        # available.  A very restrictive search is performed to avoid
-        # accidentally building this module with a later version of the
-        # underlying db library.  May BSD-ish Unixes incorporate db 1.85
-        # symbols into libc and place the include file in /usr/include.
-        f = "/usr/include/db.h"
-        if os.path.exists(f):
-            data = open(f).read()
-            m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
-            if m is not None:
-                # bingo - old version used hash file format version 2
-                ### XXX this should be fixed to not be platform-dependent
-                ### but I don't have direct access to an osf1 platform and
-                ### seemed to be muffing the search somehow
-                libraries = platform == "osf1" and ['db'] or None
-                if libraries is not None:
-                    exts.append(Extension('bsddb185', ['bsddbmodule.c'],
-                                          libraries=libraries))
-                else:
-                    exts.append(Extension('bsddb185', ['bsddbmodule.c']))
+            # check if need to use the db_185.h compat header
+            bsddb185_define_macros=[]
+            if bdb_type == "db2" or  bdb_type == "db3" or bdb_type == "db4":
+                bsddb185_define_macros=[('HAVE_DB_185_H',1)]
+                dblib_dir = [os.environ['PY_BDB_LIBDIRS']]
+            else:
+                # check if db_incs/db.h really is db 1.85
+                f = "%s/db.h" % db_incs[0]
+                if os.path.exists(f):
+                    data = open(f).read()
+                    m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
+                    if m is None:
+                        # check for 1.85 compat header
+                        if os.path.exists("%s/db_185.h" % db_incs[0]):
+                            bsddb185_define_macros=[('HAVE_DB_185_H',1)]
+                        else:
+                            raise NotFound
+            try:
+                bltransform = os.environ['PY_BDB_TRANSFORM']
+                m = re.search(r"l:db:(db.)\s*", bltransform)
+                if m is not None and m.group(1) is not None:
+                    dblibs = [m.group(1)]
+            except:
+                pass
+
+            # build the bsddb185 extension module
+            exts.append(Extension('bsddb185', ['bsddbmodule.c'],
+                                   library_dirs=dblib_dir,
+                                   runtime_library_dirs=dblib_dir,
+                                   include_dirs=db_incs,
+                                   define_macros=bsddb185_define_macros,
+                                   libraries=dblibs))
+        except:
+             db_incs = None
+             dblibs = []
+             dblib_dir = None
 
         # The standard Unix dbm module:
         if platform not in ['cygwin']:
-            if find_file("ndbm.h", inc_dirs, []) is not None:
+
+            ## Top half based on find_file
+            def find_ndbm_h(dirs):
+                ret = None
+                if sys.platform == 'darwin':
+                    sysroot = macosx_sdk_root()
+                for dir in dirs:
+                    f = os.path.join(dir, 'ndbm.h')
+                    if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
+                        f = os.path.join(sysroot, dir[1:], filename)
+                    if not os.path.exists(f): continue
+
+                    ret = 'True'
+                    input = text_file.TextFile(f)
+                    while 1:
+                        line = input.readline()
+                        if not line: break
+                        if re.search('This file is part of GDBM', line):
+                            ret = None
+                            break
+                    input.close()
+                    break
+                return ret
+
+            if find_ndbm_h(inc_dirs) is not None:
                 # Some systems have -lndbm, others don't
                 if self.compiler.find_library_file(lib_dirs, 'ndbm'):
                     ndbm_libs = ['ndbm']
@@ -689,13 +598,17 @@
                 exts.append( Extension('dbm', ['dbmmodule.c'],
                                        define_macros=[('HAVE_NDBM_H',None)],
                                        libraries = ndbm_libs ) )
-            elif (self.compiler.find_library_file(lib_dirs, 'gdbm')
-                  and find_file("gdbm/ndbm.h", inc_dirs, []) is not None):
-                exts.append( Extension('dbm', ['dbmmodule.c'],
-                                       define_macros=[('HAVE_GDBM_NDBM_H',None)],
-                                       libraries = ['gdbm'] ) )
-            elif db_incs is not None:
-                exts.append( Extension('dbm', ['dbmmodule.c'],
+
+            if not module_enabled(exts, 'dbm'):
+                if find_file("ndbm.h", db_incs, []) is not None:
+                    exts.append( Extension('dbm', ['dbmmodule.c'],
+                                       library_dirs=dblib_dir,
+                                       runtime_library_dirs=dblib_dir,
+                                       include_dirs=db_incs,
+                                       define_macros=[('HAVE_NDBM_H',None)],
+                                       libraries=dblibs))
+                elif db_incs is not None:
+                    exts.append( Extension('dbm', ['dbmmodule.c'],
                                        library_dirs=dblib_dir,
                                        runtime_library_dirs=dblib_dir,
                                        include_dirs=db_incs,
@@ -1224,8 +1137,8 @@
           ext_modules=[Extension('struct', ['structmodule.c'])],
 
           # Scripts to install
-          scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
-                     'Lib/smtpd.py']
+          scripts = ['Tools/scripts/pydoc2.4',
+                     'Lib/smtpd2.4.py']
         )
 
 # --install-platlib