Annotation of pkgsrc/lang/python27/patches/patch-setup.py, revision 1.3
1.3 ! jperkin 1: $NetBSD: patch-setup.py,v 1.2 2021/06/23 18:30:24 schmonz Exp $
1.1 adam 2:
3: Disable certain modules, so they can be built as separate packages.
4: Only check the BUILDLINK_DIR for libraries etc, do not pick up random
5: headers and libraries from the system.
6:
7: Do not look for ncursesw.
8: Assume panel_library is correct; this is a fix for ncurses' gnupanel
9: which will get transformed to panel in buildlink.
10:
1.3 ! jperkin 11: Build the _ssl module with pkgsrc choiced OpenSSL. Support OpenSSL 3.x
1.1 adam 12:
1.2 schmonz 13: macOS arm64 support, via MacPorts.
14:
1.1 adam 15: cygwin 2.7.3-no-libm.patch
16:
1.3 ! jperkin 17: --- setup.py.orig 2020-04-19 21:13:39.000000000 +0000
1.1 adam 18: +++ setup.py
1.3 ! jperkin 19: @@ -16,6 +16,7 @@ from distutils.command.build_ext import
1.2 schmonz 20: from distutils.command.install import install
21: from distutils.command.install_lib import install_lib
22: from distutils.spawn import find_executable
23: +import distutils.command.config
24:
25: cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
26:
27: @@ -33,7 +34,7 @@ host_platform = get_platform()
1.1 adam 28: COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
29:
30: # This global variable is used to hold the list of modules to be disabled.
31: -disabled_module_list = []
32: +disabled_module_list = ["_bsddb", "bsddb185", "_curses", "_curses_panel", "_elementtree", "gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "linuxaudiodev", "ossaudiodev", "sunaudiodev"]
33:
34: def add_dir_to_list(dirlist, dir):
35: """Add the directory 'dir' to the list 'dirlist' (at the front) if
1.2 schmonz 36: @@ -500,10 +501,15 @@ class PyBuildExt(build_ext):
1.1 adam 37: os.unlink(tmpfile)
38:
39: def detect_modules(self):
40: - # Ensure that /usr/local is always used
41: - if not cross_compiling:
42: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
43: - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
44: + # Add the buildlink directories for pkgsrc
45: + if os.environ.has_key('BUILDLINK_DIR'):
46: + dir = os.environ['BUILDLINK_DIR']
47: + libdir = dir + '/lib'
48: + incdir = dir + '/include'
49: + if libdir not in self.compiler.library_dirs:
50: + self.compiler.library_dirs.insert(0, libdir)
51: + if incdir not in self.compiler.include_dirs:
52: + self.compiler.include_dirs.insert(0, incdir)
53: if cross_compiling:
54: self.add_gcc_paths()
55: self.add_multiarch_paths()
1.2 schmonz 56: @@ -615,7 +621,7 @@ class PyBuildExt(build_ext):
1.1 adam 57:
58: # Check for MacOS X, which doesn't need libm.a at all
59: math_libs = ['m']
60: - if host_platform in ['darwin', 'beos']:
61: + if host_platform in ['darwin', 'beos', 'cygwin']:
62: math_libs = []
63:
64: # XXX Omitted modules: gl, pure, dl, SGI-specific modules
1.2 schmonz 65: @@ -791,8 +797,6 @@ class PyBuildExt(build_ext):
1.1 adam 66: # use the same library for the readline and curses modules.
67: if 'curses' in readline_termcap_library:
68: curses_library = readline_termcap_library
69: - elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
70: - curses_library = 'ncursesw'
71: elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
72: curses_library = 'ncurses'
73: elif self.compiler.find_library_file(lib_dirs, 'curses'):
1.2 schmonz 74: @@ -855,11 +859,10 @@ class PyBuildExt(build_ext):
1.1 adam 75: libraries=math_libs) )
76: # Detect SSL support for the socket module (via _ssl)
77: search_for_ssl_incs_in = [
78: - '/usr/local/ssl/include',
79: - '/usr/contrib/ssl/include/'
80: + '@SSLBASE@/include'
81: ]
82: - ssl_incs = find_file('openssl/ssl.h', inc_dirs,
83: - search_for_ssl_incs_in
84: + ssl_incs = find_file('openssl/ssl.h', [],
85: + search_for_ssl_incs_in + inc_dirs
86: )
87: if ssl_incs is not None:
88: krb5_h = find_file('krb5.h', inc_dirs,
1.2 schmonz 89: @@ -867,9 +870,7 @@ class PyBuildExt(build_ext):
1.1 adam 90: if krb5_h:
91: ssl_incs += krb5_h
92: ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
93: - ['/usr/local/ssl/lib',
94: - '/usr/contrib/ssl/lib/'
95: - ] )
96: + [] )
97:
98: if (ssl_incs is not None and
99: ssl_libs is not None):
1.3 ! jperkin 100: @@ -885,10 +886,12 @@ class PyBuildExt(build_ext):
! 101: openssl_ver = 0
! 102: openssl_ver_re = re.compile(
! 103: '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
! 104: + openssl_ver_major = re.compile(
! 105: + '^\s*#\s*define\s+OPENSSL_VERSION_MAJOR\s+([0-9]+)' )
1.1 adam 106:
107: # look for the openssl version header on the compiler search path.
108: opensslv_h = find_file('openssl/opensslv.h', [],
109: - inc_dirs + search_for_ssl_incs_in)
110: + search_for_ssl_incs_in + inc_dirs)
111: if opensslv_h:
112: name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
113: if host_platform == 'darwin' and is_macosx_sdk_path(name):
1.3 ! jperkin 114: @@ -899,6 +902,10 @@ class PyBuildExt(build_ext):
! 115: m = openssl_ver_re.match(line)
! 116: if m:
! 117: openssl_ver = eval(m.group(1))
! 118: + break
! 119: + m = openssl_ver_major.match(line)
! 120: + if m and eval(m.group(1)) >= 3:
! 121: + openssl_ver = 0x03000000
! 122: except IOError, msg:
! 123: print "IOError while reading opensshv.h:", msg
! 124: pass
! 125: @@ -988,175 +995,6 @@ class PyBuildExt(build_ext):
1.1 adam 126: else:
127: raise ValueError("unknown major BerkeleyDB version", major)
128:
129: - # construct a list of paths to look for the header file in on
130: - # top of the normal inc_dirs.
131: - db_inc_paths = [
132: - '/usr/include/db4',
133: - '/usr/local/include/db4',
134: - '/opt/sfw/include/db4',
135: - '/usr/include/db3',
136: - '/usr/local/include/db3',
137: - '/opt/sfw/include/db3',
138: - # Fink defaults (http://fink.sourceforge.net/)
139: - '/sw/include/db4',
140: - '/sw/include/db3',
141: - ]
142: - # 4.x minor number specific paths
143: - for x in gen_db_minor_ver_nums(4):
144: - db_inc_paths.append('/usr/include/db4%d' % x)
145: - db_inc_paths.append('/usr/include/db4.%d' % x)
146: - db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
147: - db_inc_paths.append('/usr/local/include/db4%d' % x)
148: - db_inc_paths.append('/pkg/db-4.%d/include' % x)
149: - db_inc_paths.append('/opt/db-4.%d/include' % x)
150: - # MacPorts default (http://www.macports.org/)
151: - db_inc_paths.append('/opt/local/include/db4%d' % x)
152: - # 3.x minor number specific paths
153: - for x in gen_db_minor_ver_nums(3):
154: - db_inc_paths.append('/usr/include/db3%d' % x)
155: - db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
156: - db_inc_paths.append('/usr/local/include/db3%d' % x)
157: - db_inc_paths.append('/pkg/db-3.%d/include' % x)
158: - db_inc_paths.append('/opt/db-3.%d/include' % x)
159: -
160: - if cross_compiling:
161: - db_inc_paths = []
162: -
163: - # Add some common subdirectories for Sleepycat DB to the list,
164: - # based on the standard include directories. This way DB3/4 gets
165: - # picked up when it is installed in a non-standard prefix and
166: - # the user has added that prefix into inc_dirs.
167: - std_variants = []
168: - for dn in inc_dirs:
169: - std_variants.append(os.path.join(dn, 'db3'))
170: - std_variants.append(os.path.join(dn, 'db4'))
171: - for x in gen_db_minor_ver_nums(4):
172: - std_variants.append(os.path.join(dn, "db4%d"%x))
173: - std_variants.append(os.path.join(dn, "db4.%d"%x))
174: - for x in gen_db_minor_ver_nums(3):
175: - std_variants.append(os.path.join(dn, "db3%d"%x))
176: - std_variants.append(os.path.join(dn, "db3.%d"%x))
177: -
178: - db_inc_paths = std_variants + db_inc_paths
179: - db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
180: -
181: - db_ver_inc_map = {}
182: -
183: - if host_platform == 'darwin':
184: - sysroot = macosx_sdk_root()
185: -
186: - class db_found(Exception): pass
187: - try:
188: - # See whether there is a Sleepycat header in the standard
189: - # search path.
190: - for d in inc_dirs + db_inc_paths:
191: - f = os.path.join(d, "db.h")
192: -
193: - if host_platform == 'darwin' and is_macosx_sdk_path(d):
194: - f = os.path.join(sysroot, d[1:], "db.h")
195: -
196: - if db_setup_debug: print "db: looking for db.h in", f
197: - if os.path.exists(f):
198: - f = open(f).read()
199: - m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
200: - if m:
201: - db_major = int(m.group(1))
202: - m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
203: - db_minor = int(m.group(1))
204: - db_ver = (db_major, db_minor)
205: -
206: - # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
207: - if db_ver == (4, 6):
208: - m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
209: - db_patch = int(m.group(1))
210: - if db_patch < 21:
211: - print "db.h:", db_ver, "patch", db_patch,
212: - print "being ignored (4.6.x must be >= 4.6.21)"
213: - continue
214: -
215: - if ( (db_ver not in db_ver_inc_map) and
216: - allow_db_ver(db_ver) ):
217: - # save the include directory with the db.h version
218: - # (first occurrence only)
219: - db_ver_inc_map[db_ver] = d
220: - if db_setup_debug:
221: - print "db.h: found", db_ver, "in", d
222: - else:
223: - # we already found a header for this library version
224: - if db_setup_debug: print "db.h: ignoring", d
225: - else:
226: - # ignore this header, it didn't contain a version number
227: - if db_setup_debug:
228: - print "db.h: no version number version in", d
229: -
230: - db_found_vers = db_ver_inc_map.keys()
231: - db_found_vers.sort()
232: -
233: - while db_found_vers:
234: - db_ver = db_found_vers.pop()
235: - db_incdir = db_ver_inc_map[db_ver]
236: -
237: - # check lib directories parallel to the location of the header
238: - db_dirs_to_check = [
239: - db_incdir.replace("include", 'lib64'),
240: - db_incdir.replace("include", 'lib'),
241: - ]
242: -
243: - if host_platform != 'darwin':
244: - db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
245: -
246: - else:
247: - # Same as other branch, but takes OSX SDK into account
248: - tmp = []
249: - for dn in db_dirs_to_check:
250: - if is_macosx_sdk_path(dn):
251: - if os.path.isdir(os.path.join(sysroot, dn[1:])):
252: - tmp.append(dn)
253: - else:
254: - if os.path.isdir(dn):
255: - tmp.append(dn)
256: - db_dirs_to_check = tmp
257: -
258: - # Look for a version specific db-X.Y before an ambiguous dbX
259: - # XXX should we -ever- look for a dbX name? Do any
260: - # systems really not name their library by version and
261: - # symlink to more general names?
262: - for dblib in (('db-%d.%d' % db_ver),
263: - ('db%d%d' % db_ver),
264: - ('db%d' % db_ver[0])):
265: - dblib_file = self.compiler.find_library_file(
266: - db_dirs_to_check + lib_dirs, dblib )
267: - if dblib_file:
268: - dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
269: - raise db_found
270: - else:
271: - if db_setup_debug: print "db lib: ", dblib, "not found"
272: -
273: - except db_found:
274: - if db_setup_debug:
275: - print "bsddb using BerkeleyDB lib:", db_ver, dblib
276: - print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
277: - db_incs = [db_incdir]
278: - dblibs = [dblib]
279: - # We add the runtime_library_dirs argument because the
280: - # BerkeleyDB lib we're linking against often isn't in the
281: - # system dynamic library search path. This is usually
282: - # correct and most trouble free, but may cause problems in
283: - # some unusual system configurations (e.g. the directory
284: - # is on an NFS server that goes away).
285: - exts.append(Extension('_bsddb', ['_bsddb.c'],
286: - depends = ['bsddb.h'],
287: - library_dirs=dblib_dir,
288: - runtime_library_dirs=dblib_dir,
289: - include_dirs=db_incs,
290: - libraries=dblibs))
291: - else:
292: - if db_setup_debug: print "db: no appropriate library found"
293: - db_incs = None
294: - dblibs = []
295: - dblib_dir = None
296: - missing.append('_bsddb')
297: -
298: # The sqlite interface
299: sqlite_setup_debug = False # verbose debug prints from this script?
300:
1.3 ! jperkin 301: @@ -1262,46 +1100,32 @@ class PyBuildExt(build_ext):
1.1 adam 302: else:
303: missing.append('_sqlite3')
304:
305: - # Look for Berkeley db 1.85. Note that it is built as a different
306: - # module name so it can be included even when later versions are
307: - # available. A very restrictive search is performed to avoid
308: - # accidentally building this module with a later version of the
309: - # underlying db library. May BSD-ish Unixes incorporate db 1.85
310: - # symbols into libc and place the include file in /usr/include.
311: - #
312: - # If the better bsddb library can be built (db_incs is defined)
313: - # we do not build this one. Otherwise this build will pick up
314: - # the more recent berkeleydb's db.h file first in the include path
315: - # when attempting to compile and it will fail.
316: - f = "/usr/include/db.h"
317: -
318: - if host_platform == 'darwin':
319: - if is_macosx_sdk_path(f):
320: - sysroot = macosx_sdk_root()
321: - f = os.path.join(sysroot, f[1:])
322: -
323: - if os.path.exists(f) and not db_incs:
324: - data = open(f).read()
325: - m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
326: - if m is not None:
327: - # bingo - old version used hash file format version 2
328: - ### XXX this should be fixed to not be platform-dependent
329: - ### but I don't have direct access to an osf1 platform and
330: - ### seemed to be muffing the search somehow
331: - libraries = host_platform == "osf1" and ['db'] or None
332: - if libraries is not None:
333: - exts.append(Extension('bsddb185', ['bsddbmodule.c'],
334: - libraries=libraries))
335: - else:
336: - exts.append(Extension('bsddb185', ['bsddbmodule.c']))
337: - else:
338: - missing.append('bsddb185')
339: - else:
340: - missing.append('bsddb185')
341: -
342: dbm_order = ['gdbm']
343: # The standard Unix dbm module:
344: if host_platform not in ['cygwin']:
345: + ## Top half based on find_file
346: + def find_ndbm_h(dirs):
347: + ret = None
348: + if sys.platform == 'darwin':
349: + sysroot = macosx_sdk_root()
350: + for dir in dirs:
351: + f = os.path.join(dir, 'ndbm.h')
352: + if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
353: + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
354: + if not os.path.exists(f): continue
355: +
356: + ret = 'True'
357: + input = text_file.TextFile(f)
358: + while 1:
359: + line = input.readline()
360: + if not line: break
361: + if re.search('This file is part of GDBM', line):
362: + ret = None
363: + break
364: + input.close()
365: + break
366: + return ret
367: +
368: config_args = [arg.strip("'")
369: for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
370: dbm_args = [arg for arg in config_args
1.3 ! jperkin 371: @@ -1313,7 +1137,7 @@ class PyBuildExt(build_ext):
1.1 adam 372: dbmext = None
373: for cand in dbm_order:
374: if cand == "ndbm":
375: - if find_file("ndbm.h", inc_dirs, []) is not None:
376: + if find_ndbm_h(inc_dirs) is not None:
377: # Some systems have -lndbm, others have -lgdbm_compat,
378: # others don't have either
379: if self.compiler.find_library_file(lib_dirs,
1.3 ! jperkin 380: @@ -1357,18 +1181,14 @@ class PyBuildExt(build_ext):
1.1 adam 381: libraries = gdbm_libs)
382: break
383: elif cand == "bdb":
384: - if db_incs is not None:
385: - print "building dbm using bdb"
386: - dbmext = Extension('dbm', ['dbmmodule.c'],
387: - library_dirs=dblib_dir,
388: - runtime_library_dirs=dblib_dir,
389: - include_dirs=db_incs,
390: - define_macros=[
391: - ('HAVE_BERKDB_H', None),
392: - ('DB_DBM_HSEARCH', None),
393: - ],
394: - libraries=dblibs)
395: - break
396: + print "building dbm using bdb"
397: + dbmext = Extension('dbm', ['dbmmodule.c'],
398: + define_macros=[
399: + ('HAVE_BERKDB_H', None),
400: + ('DB_DBM_HSEARCH', None),
401: + ],
402: + libraries=["db"])
403: + break
404: if dbmext is not None:
405: exts.append(dbmext)
406: else:
1.3 ! jperkin 407: @@ -1429,8 +1249,7 @@ class PyBuildExt(build_ext):
1.1 adam 408: missing.append('_curses')
409:
410: # If the curses module is enabled, check for the panel module
411: - if (module_enabled(exts, '_curses') and
412: - self.compiler.find_library_file(lib_dirs, panel_library)):
413: + if (module_enabled(exts, '_curses')):
414: exts.append( Extension('_curses_panel', ['_curses_panel.c'],
415: include_dirs = curses_incs,
416: libraries = [panel_library] + curses_libs) )
1.3 ! jperkin 417: @@ -2129,6 +1948,7 @@ class PyBuildExt(build_ext):
1.2 schmonz 418:
419: if host_platform == 'darwin':
420: sources.append('_ctypes/malloc_closure.c')
421: + extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1')
422: sources.append('_ctypes/darwin/dlfcn_simple.c')
423: extra_compile_args.append('-DMACOSX')
424: include_dirs.append('_ctypes/darwin')
1.3 ! jperkin 425: @@ -2191,6 +2011,16 @@ class PyBuildExt(build_ext):
1.2 schmonz 426: break
427:
428: if ffi_inc and ffi_lib:
429: + config = distutils.command.config.config(self.distribution)
430: + config._check_compiler()
431: + if any(cc in config.compiler.compiler_so for cc in ('gcc', 'clang')):
432: + config.compiler.compiler_so += ["-Wno-unguarded-availability-new", "-Wno-unused-value"]
433: + if config.check_func("ffi_prep_closure_loc", headers=['ffi.h'], include_dirs=[ffi_inc]):
434: + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CLOSURE_LOC=1")
435: + if config.check_func("ffi_prep_cif_var", headers=['ffi.h'], include_dirs=[ffi_inc]):
436: + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1")
437: + if host_platform == 'darwin' and config.check_func("ffi_closure_alloc", headers=['ffi.h'], include_dirs=[ffi_inc]):
438: + ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1")
439: ext.include_dirs.extend(ffi_inc)
440: ext.libraries.append(ffi_lib)
441: self.use_system_libffi = True
1.3 ! jperkin 442: @@ -2342,9 +2172,9 @@ def main():
1.1 adam 443: ext_modules=[Extension('_struct', ['_struct.c'])],
444:
445: # Scripts to install
446: - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
447: - 'Tools/scripts/2to3',
448: - 'Lib/smtpd.py']
449: + scripts = ['Tools/scripts/pydoc2.7',
450: + 'Tools/scripts/2to3-2.7',
451: + 'Tools/scripts/smtpd2.7.py']
452: )
453:
454: # --install-platlib
CVSweb <webmaster@jp.NetBSD.org>