1 $NetBSD: patch-am,v 1.8 2013/04/12 09:03:41 adam Exp $
3 Disabled modules for normal build:
13 {linux,oss,sun}audiodev
15 Those have separate packages where needed.
17 Only check the BUILDLINK_DIR for libraries etc, do not pick up random
18 headers and libraries from the system.
20 Build the 1.85 compat module all the time against the BDB version of choice.
22 cygwin 2.7.3-no-libm.patch
24 --- setup.py.orig 2013-04-06 14:02:41.000000000 +0000
26 @@ -33,7 +33,7 @@ host_platform = get_platform()
27 COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
29 # This global variable is used to hold the list of modules to be disabled.
30 -disabled_module_list = []
31 +disabled_module_list = ["_bsddb", "_curses", "_curses_panel", "_elementtree", "_sqlite3", "_tkinter", "gdbm", "pyexpat", "readline", "linuxaudiodev", "ossaudiodev", "spwd", "sunaudiodev"]
33 def add_dir_to_list(dirlist, dir):
34 """Add the directory 'dir' to the list 'dirlist' (at the front) if
35 @@ -436,9 +436,15 @@ class PyBuildExt(build_ext):
38 def detect_modules(self):
39 - # Ensure that /usr/local is always used
40 - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
41 - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
42 + # Add the buildlink directories for pkgsrc
43 + if os.environ.has_key('BUILDLINK_DIR'):
44 + dir = os.environ['BUILDLINK_DIR']
45 + libdir = dir + '/lib'
46 + incdir = dir + '/include'
47 + if libdir not in self.compiler.library_dirs:
48 + self.compiler.library_dirs.insert(0, libdir)
49 + if incdir not in self.compiler.include_dirs:
50 + self.compiler.include_dirs.insert(0, incdir)
51 self.add_multiarch_paths()
53 # Add paths specified in the environment variables LDFLAGS and
54 @@ -548,7 +554,7 @@ class PyBuildExt(build_ext):
56 # Check for MacOS X, which doesn't need libm.a at all
58 - if host_platform in ['darwin', 'beos']:
59 + if host_platform in ['darwin', 'beos', 'cygwin']:
62 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
63 @@ -794,9 +800,7 @@ class PyBuildExt(build_ext):
66 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
67 - ['/usr/local/ssl/lib',
68 - '/usr/contrib/ssl/lib/'
72 if (ssl_incs is not None and
73 ssl_libs is not None):
74 @@ -915,175 +919,6 @@ class PyBuildExt(build_ext):
76 raise ValueError("unknown major BerkeleyDB version", major)
78 - # construct a list of paths to look for the header file in on
79 - # top of the normal inc_dirs.
82 - '/usr/local/include/db4',
83 - '/opt/sfw/include/db4',
85 - '/usr/local/include/db3',
86 - '/opt/sfw/include/db3',
87 - # Fink defaults (http://fink.sourceforge.net/)
91 - # 4.x minor number specific paths
92 - for x in gen_db_minor_ver_nums(4):
93 - db_inc_paths.append('/usr/include/db4%d' % x)
94 - db_inc_paths.append('/usr/include/db4.%d' % x)
95 - db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
96 - db_inc_paths.append('/usr/local/include/db4%d' % x)
97 - db_inc_paths.append('/pkg/db-4.%d/include' % x)
98 - db_inc_paths.append('/opt/db-4.%d/include' % x)
99 - # MacPorts default (http://www.macports.org/)
100 - db_inc_paths.append('/opt/local/include/db4%d' % x)
101 - # 3.x minor number specific paths
102 - for x in gen_db_minor_ver_nums(3):
103 - db_inc_paths.append('/usr/include/db3%d' % x)
104 - db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
105 - db_inc_paths.append('/usr/local/include/db3%d' % x)
106 - db_inc_paths.append('/pkg/db-3.%d/include' % x)
107 - db_inc_paths.append('/opt/db-3.%d/include' % x)
109 - if cross_compiling:
112 - # Add some common subdirectories for Sleepycat DB to the list,
113 - # based on the standard include directories. This way DB3/4 gets
114 - # picked up when it is installed in a non-standard prefix and
115 - # the user has added that prefix into inc_dirs.
117 - for dn in inc_dirs:
118 - std_variants.append(os.path.join(dn, 'db3'))
119 - std_variants.append(os.path.join(dn, 'db4'))
120 - for x in gen_db_minor_ver_nums(4):
121 - std_variants.append(os.path.join(dn, "db4%d"%x))
122 - std_variants.append(os.path.join(dn, "db4.%d"%x))
123 - for x in gen_db_minor_ver_nums(3):
124 - std_variants.append(os.path.join(dn, "db3%d"%x))
125 - std_variants.append(os.path.join(dn, "db3.%d"%x))
127 - db_inc_paths = std_variants + db_inc_paths
128 - db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
130 - db_ver_inc_map = {}
132 - if host_platform == 'darwin':
133 - sysroot = macosx_sdk_root()
135 - class db_found(Exception): pass
137 - # See whether there is a Sleepycat header in the standard
139 - for d in inc_dirs + db_inc_paths:
140 - f = os.path.join(d, "db.h")
142 - if host_platform == 'darwin' and is_macosx_sdk_path(d):
143 - f = os.path.join(sysroot, d[1:], "db.h")
145 - if db_setup_debug: print "db: looking for db.h in", f
146 - if os.path.exists(f):
148 - m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
150 - db_major = int(m.group(1))
151 - m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
152 - db_minor = int(m.group(1))
153 - db_ver = (db_major, db_minor)
155 - # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
156 - if db_ver == (4, 6):
157 - m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
158 - db_patch = int(m.group(1))
160 - print "db.h:", db_ver, "patch", db_patch,
161 - print "being ignored (4.6.x must be >= 4.6.21)"
164 - if ( (db_ver not in db_ver_inc_map) and
165 - allow_db_ver(db_ver) ):
166 - # save the include directory with the db.h version
167 - # (first occurrence only)
168 - db_ver_inc_map[db_ver] = d
170 - print "db.h: found", db_ver, "in", d
172 - # we already found a header for this library version
173 - if db_setup_debug: print "db.h: ignoring", d
175 - # ignore this header, it didn't contain a version number
177 - print "db.h: no version number version in", d
179 - db_found_vers = db_ver_inc_map.keys()
180 - db_found_vers.sort()
182 - while db_found_vers:
183 - db_ver = db_found_vers.pop()
184 - db_incdir = db_ver_inc_map[db_ver]
186 - # check lib directories parallel to the location of the header
187 - db_dirs_to_check = [
188 - db_incdir.replace("include", 'lib64'),
189 - db_incdir.replace("include", 'lib'),
192 - if host_platform != 'darwin':
193 - db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
196 - # Same as other branch, but takes OSX SDK into account
198 - for dn in db_dirs_to_check:
199 - if is_macosx_sdk_path(dn):
200 - if os.path.isdir(os.path.join(sysroot, dn[1:])):
203 - if os.path.isdir(dn):
205 - db_dirs_to_check = tmp
207 - # Look for a version specific db-X.Y before an ambiguous dbX
208 - # XXX should we -ever- look for a dbX name? Do any
209 - # systems really not name their library by version and
210 - # symlink to more general names?
211 - for dblib in (('db-%d.%d' % db_ver),
212 - ('db%d%d' % db_ver),
213 - ('db%d' % db_ver[0])):
214 - dblib_file = self.compiler.find_library_file(
215 - db_dirs_to_check + lib_dirs, dblib )
217 - dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
220 - if db_setup_debug: print "db lib: ", dblib, "not found"
224 - print "bsddb using BerkeleyDB lib:", db_ver, dblib
225 - print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
226 - db_incs = [db_incdir]
228 - # We add the runtime_library_dirs argument because the
229 - # BerkeleyDB lib we're linking against often isn't in the
230 - # system dynamic library search path. This is usually
231 - # correct and most trouble free, but may cause problems in
232 - # some unusual system configurations (e.g. the directory
233 - # is on an NFS server that goes away).
234 - exts.append(Extension('_bsddb', ['_bsddb.c'],
235 - depends = ['bsddb.h'],
236 - library_dirs=dblib_dir,
237 - runtime_library_dirs=dblib_dir,
238 - include_dirs=db_incs,
241 - if db_setup_debug: print "db: no appropriate library found"
245 - missing.append('_bsddb')
247 # The sqlite interface
248 sqlite_setup_debug = False # verbose debug prints from this script?
250 @@ -1201,35 +1036,39 @@ class PyBuildExt(build_ext):
251 # we do not build this one. Otherwise this build will pick up
252 # the more recent berkeleydb's db.h file first in the include path
253 # when attempting to compile and it will fail.
254 - f = "/usr/include/db.h"
256 - if host_platform == 'darwin':
257 - if is_macosx_sdk_path(f):
258 - sysroot = macosx_sdk_root()
259 - f = os.path.join(sysroot, f[1:])
261 - if os.path.exists(f) and not db_incs:
262 - data = open(f).read()
263 - m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
265 - # bingo - old version used hash file format version 2
266 - ### XXX this should be fixed to not be platform-dependent
267 - ### but I don't have direct access to an osf1 platform and
268 - ### seemed to be muffing the search somehow
269 - libraries = host_platform == "osf1" and ['db'] or None
270 - if libraries is not None:
271 - exts.append(Extension('bsddb185', ['bsddbmodule.c'],
272 - libraries=libraries))
274 - exts.append(Extension('bsddb185', ['bsddbmodule.c']))
276 - missing.append('bsddb185')
277 + libraries = os.getenv("PY_BDB_TYPE", "")
279 + exts.append(Extension('bsddb185', ['bsddbmodule.c'],
282 - missing.append('bsddb185')
283 + exts.append(Extension('bsddb185', ['bsddbmodule.c']))
286 # The standard Unix dbm module:
287 if host_platform not in ['cygwin']:
288 + ## Top half based on find_file
289 + def find_ndbm_h(dirs):
291 + if sys.platform == 'darwin':
292 + sysroot = macosx_sdk_root()
294 + f = os.path.join(dir, 'ndbm.h')
295 + if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
296 + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
297 + if not os.path.exists(f): continue
300 + input = text_file.TextFile(f)
302 + line = input.readline()
304 + if re.search('This file is part of GDBM', line):
311 config_args = [arg.strip("'")
312 for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
313 dbm_args = [arg for arg in config_args
314 @@ -1241,7 +1080,7 @@ class PyBuildExt(build_ext):
316 for cand in dbm_order:
318 - if find_file("ndbm.h", inc_dirs, []) is not None:
319 + if find_ndbm_h(inc_dirs) is not None:
320 # Some systems have -lndbm, others have -lgdbm_compat,
321 # others don't have either
322 if self.compiler.find_library_file(lib_dirs,
323 @@ -1285,18 +1124,14 @@ class PyBuildExt(build_ext):
324 libraries = gdbm_libs)
327 - if db_incs is not None:
328 - print "building dbm using bdb"
329 - dbmext = Extension('dbm', ['dbmmodule.c'],
330 - library_dirs=dblib_dir,
331 - runtime_library_dirs=dblib_dir,
332 - include_dirs=db_incs,
334 - ('HAVE_BERKDB_H', None),
335 - ('DB_DBM_HSEARCH', None),
339 + print "building dbm using bdb"
340 + dbmext = Extension('dbm', ['dbmmodule.c'],
342 + ('HAVE_BERKDB_H', None),
343 + ('DB_DBM_HSEARCH', None),
347 if dbmext is not None:
350 @@ -2176,9 +2011,9 @@ def main():
351 ext_modules=[Extension('_struct', ['_struct.c'])],
354 - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
355 - 'Tools/scripts/2to3',
357 + scripts = ['Tools/scripts/pydoc2.7',
358 + 'Tools/scripts/2to3-2.7',