| @@ -1,32 +1,32 @@ | | | @@ -1,32 +1,32 @@ |
1 | $NetBSD: patch-setup.py,v 1.2 2021/06/23 18:30:24 schmonz Exp $ | | 1 | $NetBSD: patch-setup.py,v 1.3 2021/09/28 12:31:25 jperkin Exp $ |
2 | | | 2 | |
3 | Disable certain modules, so they can be built as separate packages. | | 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 | | 4 | Only check the BUILDLINK_DIR for libraries etc, do not pick up random |
5 | headers and libraries from the system. | | 5 | headers and libraries from the system. |
6 | | | 6 | |
7 | Do not look for ncursesw. | | 7 | Do not look for ncursesw. |
8 | Assume panel_library is correct; this is a fix for ncurses' gnupanel | | 8 | Assume panel_library is correct; this is a fix for ncurses' gnupanel |
9 | which will get transformed to panel in buildlink. | | 9 | which will get transformed to panel in buildlink. |
10 | | | 10 | |
11 | Build the _ssl module with pkgsrc choiced OpenSSL. | | 11 | Build the _ssl module with pkgsrc choiced OpenSSL. Support OpenSSL 3.x |
12 | | | 12 | |
13 | macOS arm64 support, via MacPorts. | | 13 | macOS arm64 support, via MacPorts. |
14 | | | 14 | |
15 | cygwin 2.7.3-no-libm.patch | | 15 | cygwin 2.7.3-no-libm.patch |
16 | | | 16 | |
17 | --- setup.py.orig 2021-06-22 19:20:43.000000000 +0000 | | 17 | --- setup.py.orig 2020-04-19 21:13:39.000000000 +0000 |
18 | +++ setup.py | | 18 | +++ setup.py |
19 | @@ -16,6 +16,7 @@ from distutils.command.build_ext import | | 19 | @@ -16,6 +16,7 @@ from distutils.command.build_ext import |
20 | from distutils.command.install import install | | 20 | from distutils.command.install import install |
21 | from distutils.command.install_lib import install_lib | | 21 | from distutils.command.install_lib import install_lib |
22 | from distutils.spawn import find_executable | | 22 | from distutils.spawn import find_executable |
23 | +import distutils.command.config | | 23 | +import distutils.command.config |
24 | | | 24 | |
25 | cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ | | 25 | cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ |
26 | | | 26 | |
27 | @@ -33,7 +34,7 @@ host_platform = get_platform() | | 27 | @@ -33,7 +34,7 @@ host_platform = get_platform() |
28 | COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) | | 28 | COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) |
29 | | | 29 | |
30 | # This global variable is used to hold the list of modules to be disabled. | | 30 | # This global variable is used to hold the list of modules to be disabled. |
31 | -disabled_module_list = [] | | 31 | -disabled_module_list = [] |
32 | +disabled_module_list = ["_bsddb", "bsddb185", "_curses", "_curses_panel", "_elementtree", "gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "linuxaudiodev", "ossaudiodev", "sunaudiodev"] | | 32 | +disabled_module_list = ["_bsddb", "bsddb185", "_curses", "_curses_panel", "_elementtree", "gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "linuxaudiodev", "ossaudiodev", "sunaudiodev"] |
| @@ -87,36 +87,52 @@ cygwin 2.7.3-no-libm.patch | | | @@ -87,36 +87,52 @@ cygwin 2.7.3-no-libm.patch |
87 | if ssl_incs is not None: | | 87 | if ssl_incs is not None: |
88 | krb5_h = find_file('krb5.h', inc_dirs, | | 88 | krb5_h = find_file('krb5.h', inc_dirs, |
89 | @@ -867,9 +870,7 @@ class PyBuildExt(build_ext): | | 89 | @@ -867,9 +870,7 @@ class PyBuildExt(build_ext): |
90 | if krb5_h: | | 90 | if krb5_h: |
91 | ssl_incs += krb5_h | | 91 | ssl_incs += krb5_h |
92 | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, | | 92 | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, |
93 | - ['/usr/local/ssl/lib', | | 93 | - ['/usr/local/ssl/lib', |
94 | - '/usr/contrib/ssl/lib/' | | 94 | - '/usr/contrib/ssl/lib/' |
95 | - ] ) | | 95 | - ] ) |
96 | + [] ) | | 96 | + [] ) |
97 | | | 97 | |
98 | if (ssl_incs is not None and | | 98 | if (ssl_incs is not None and |
99 | ssl_libs is not None): | | 99 | ssl_libs is not None): |
100 | @@ -888,7 +889,7 @@ class PyBuildExt(build_ext): | | 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]+)' ) |
101 | | | 106 | |
102 | # look for the openssl version header on the compiler search path. | | 107 | # look for the openssl version header on the compiler search path. |
103 | opensslv_h = find_file('openssl/opensslv.h', [], | | 108 | opensslv_h = find_file('openssl/opensslv.h', [], |
104 | - inc_dirs + search_for_ssl_incs_in) | | 109 | - inc_dirs + search_for_ssl_incs_in) |
105 | + search_for_ssl_incs_in + inc_dirs) | | 110 | + search_for_ssl_incs_in + inc_dirs) |
106 | if opensslv_h: | | 111 | if opensslv_h: |
107 | name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') | | 112 | name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') |
108 | if host_platform == 'darwin' and is_macosx_sdk_path(name): | | 113 | if host_platform == 'darwin' and is_macosx_sdk_path(name): |
109 | @@ -988,175 +989,6 @@ class PyBuildExt(build_ext): | | 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): |
110 | else: | | 126 | else: |
111 | raise ValueError("unknown major BerkeleyDB version", major) | | 127 | raise ValueError("unknown major BerkeleyDB version", major) |
112 | | | 128 | |
113 | - # construct a list of paths to look for the header file in on | | 129 | - # construct a list of paths to look for the header file in on |
114 | - # top of the normal inc_dirs. | | 130 | - # top of the normal inc_dirs. |
115 | - db_inc_paths = [ | | 131 | - db_inc_paths = [ |
116 | - '/usr/include/db4', | | 132 | - '/usr/include/db4', |
117 | - '/usr/local/include/db4', | | 133 | - '/usr/local/include/db4', |
118 | - '/opt/sfw/include/db4', | | 134 | - '/opt/sfw/include/db4', |
119 | - '/usr/include/db3', | | 135 | - '/usr/include/db3', |
120 | - '/usr/local/include/db3', | | 136 | - '/usr/local/include/db3', |
121 | - '/opt/sfw/include/db3', | | 137 | - '/opt/sfw/include/db3', |
122 | - # Fink defaults (http://fink.sourceforge.net/) | | 138 | - # Fink defaults (http://fink.sourceforge.net/) |
| @@ -272,27 +288,27 @@ cygwin 2.7.3-no-libm.patch | | | @@ -272,27 +288,27 @@ cygwin 2.7.3-no-libm.patch |
272 | - runtime_library_dirs=dblib_dir, | | 288 | - runtime_library_dirs=dblib_dir, |
273 | - include_dirs=db_incs, | | 289 | - include_dirs=db_incs, |
274 | - libraries=dblibs)) | | 290 | - libraries=dblibs)) |
275 | - else: | | 291 | - else: |
276 | - if db_setup_debug: print "db: no appropriate library found" | | 292 | - if db_setup_debug: print "db: no appropriate library found" |
277 | - db_incs = None | | 293 | - db_incs = None |
278 | - dblibs = [] | | 294 | - dblibs = [] |
279 | - dblib_dir = None | | 295 | - dblib_dir = None |
280 | - missing.append('_bsddb') | | 296 | - missing.append('_bsddb') |
281 | - | | 297 | - |
282 | # The sqlite interface | | 298 | # The sqlite interface |
283 | sqlite_setup_debug = False # verbose debug prints from this script? | | 299 | sqlite_setup_debug = False # verbose debug prints from this script? |
284 | | | 300 | |
285 | @@ -1262,46 +1094,32 @@ class PyBuildExt(build_ext): | | 301 | @@ -1262,46 +1100,32 @@ class PyBuildExt(build_ext): |
286 | else: | | 302 | else: |
287 | missing.append('_sqlite3') | | 303 | missing.append('_sqlite3') |
288 | | | 304 | |
289 | - # Look for Berkeley db 1.85. Note that it is built as a different | | 305 | - # Look for Berkeley db 1.85. Note that it is built as a different |
290 | - # module name so it can be included even when later versions are | | 306 | - # module name so it can be included even when later versions are |
291 | - # available. A very restrictive search is performed to avoid | | 307 | - # available. A very restrictive search is performed to avoid |
292 | - # accidentally building this module with a later version of the | | 308 | - # accidentally building this module with a later version of the |
293 | - # underlying db library. May BSD-ish Unixes incorporate db 1.85 | | 309 | - # underlying db library. May BSD-ish Unixes incorporate db 1.85 |
294 | - # symbols into libc and place the include file in /usr/include. | | 310 | - # symbols into libc and place the include file in /usr/include. |
295 | - # | | 311 | - # |
296 | - # If the better bsddb library can be built (db_incs is defined) | | 312 | - # If the better bsddb library can be built (db_incs is defined) |
297 | - # we do not build this one. Otherwise this build will pick up | | 313 | - # we do not build this one. Otherwise this build will pick up |
298 | - # the more recent berkeleydb's db.h file first in the include path | | 314 | - # the more recent berkeleydb's db.h file first in the include path |
| @@ -342,97 +358,97 @@ cygwin 2.7.3-no-libm.patch | | | @@ -342,97 +358,97 @@ cygwin 2.7.3-no-libm.patch |
342 | + while 1: | | 358 | + while 1: |
343 | + line = input.readline() | | 359 | + line = input.readline() |
344 | + if not line: break | | 360 | + if not line: break |
345 | + if re.search('This file is part of GDBM', line): | | 361 | + if re.search('This file is part of GDBM', line): |
346 | + ret = None | | 362 | + ret = None |
347 | + break | | 363 | + break |
348 | + input.close() | | 364 | + input.close() |
349 | + break | | 365 | + break |
350 | + return ret | | 366 | + return ret |
351 | + | | 367 | + |
352 | config_args = [arg.strip("'") | | 368 | config_args = [arg.strip("'") |
353 | for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] | | 369 | for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] |
354 | dbm_args = [arg for arg in config_args | | 370 | dbm_args = [arg for arg in config_args |
355 | @@ -1313,7 +1131,7 @@ class PyBuildExt(build_ext): | | 371 | @@ -1313,7 +1137,7 @@ class PyBuildExt(build_ext): |
356 | dbmext = None | | 372 | dbmext = None |
357 | for cand in dbm_order: | | 373 | for cand in dbm_order: |
358 | if cand == "ndbm": | | 374 | if cand == "ndbm": |
359 | - if find_file("ndbm.h", inc_dirs, []) is not None: | | 375 | - if find_file("ndbm.h", inc_dirs, []) is not None: |
360 | + if find_ndbm_h(inc_dirs) is not None: | | 376 | + if find_ndbm_h(inc_dirs) is not None: |
361 | # Some systems have -lndbm, others have -lgdbm_compat, | | 377 | # Some systems have -lndbm, others have -lgdbm_compat, |
362 | # others don't have either | | 378 | # others don't have either |
363 | if self.compiler.find_library_file(lib_dirs, | | 379 | if self.compiler.find_library_file(lib_dirs, |
364 | @@ -1357,18 +1175,14 @@ class PyBuildExt(build_ext): | | 380 | @@ -1357,18 +1181,14 @@ class PyBuildExt(build_ext): |
365 | libraries = gdbm_libs) | | 381 | libraries = gdbm_libs) |
366 | break | | 382 | break |
367 | elif cand == "bdb": | | 383 | elif cand == "bdb": |
368 | - if db_incs is not None: | | 384 | - if db_incs is not None: |
369 | - print "building dbm using bdb" | | 385 | - print "building dbm using bdb" |
370 | - dbmext = Extension('dbm', ['dbmmodule.c'], | | 386 | - dbmext = Extension('dbm', ['dbmmodule.c'], |
371 | - library_dirs=dblib_dir, | | 387 | - library_dirs=dblib_dir, |
372 | - runtime_library_dirs=dblib_dir, | | 388 | - runtime_library_dirs=dblib_dir, |
373 | - include_dirs=db_incs, | | 389 | - include_dirs=db_incs, |
374 | - define_macros=[ | | 390 | - define_macros=[ |
375 | - ('HAVE_BERKDB_H', None), | | 391 | - ('HAVE_BERKDB_H', None), |
376 | - ('DB_DBM_HSEARCH', None), | | 392 | - ('DB_DBM_HSEARCH', None), |
377 | - ], | | 393 | - ], |
378 | - libraries=dblibs) | | 394 | - libraries=dblibs) |
379 | - break | | 395 | - break |
380 | + print "building dbm using bdb" | | 396 | + print "building dbm using bdb" |
381 | + dbmext = Extension('dbm', ['dbmmodule.c'], | | 397 | + dbmext = Extension('dbm', ['dbmmodule.c'], |
382 | + define_macros=[ | | 398 | + define_macros=[ |
383 | + ('HAVE_BERKDB_H', None), | | 399 | + ('HAVE_BERKDB_H', None), |
384 | + ('DB_DBM_HSEARCH', None), | | 400 | + ('DB_DBM_HSEARCH', None), |
385 | + ], | | 401 | + ], |
386 | + libraries=["db"]) | | 402 | + libraries=["db"]) |
387 | + break | | 403 | + break |
388 | if dbmext is not None: | | 404 | if dbmext is not None: |
389 | exts.append(dbmext) | | 405 | exts.append(dbmext) |
390 | else: | | 406 | else: |
391 | @@ -1429,8 +1243,7 @@ class PyBuildExt(build_ext): | | 407 | @@ -1429,8 +1249,7 @@ class PyBuildExt(build_ext): |
392 | missing.append('_curses') | | 408 | missing.append('_curses') |
393 | | | 409 | |
394 | # If the curses module is enabled, check for the panel module | | 410 | # If the curses module is enabled, check for the panel module |
395 | - if (module_enabled(exts, '_curses') and | | 411 | - if (module_enabled(exts, '_curses') and |
396 | - self.compiler.find_library_file(lib_dirs, panel_library)): | | 412 | - self.compiler.find_library_file(lib_dirs, panel_library)): |
397 | + if (module_enabled(exts, '_curses')): | | 413 | + if (module_enabled(exts, '_curses')): |
398 | exts.append( Extension('_curses_panel', ['_curses_panel.c'], | | 414 | exts.append( Extension('_curses_panel', ['_curses_panel.c'], |
399 | include_dirs = curses_incs, | | 415 | include_dirs = curses_incs, |
400 | libraries = [panel_library] + curses_libs) ) | | 416 | libraries = [panel_library] + curses_libs) ) |
401 | @@ -2129,6 +1942,7 @@ class PyBuildExt(build_ext): | | 417 | @@ -2129,6 +1948,7 @@ class PyBuildExt(build_ext): |
402 | | | 418 | |
403 | if host_platform == 'darwin': | | 419 | if host_platform == 'darwin': |
404 | sources.append('_ctypes/malloc_closure.c') | | 420 | sources.append('_ctypes/malloc_closure.c') |
405 | + extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1') | | 421 | + extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1') |
406 | sources.append('_ctypes/darwin/dlfcn_simple.c') | | 422 | sources.append('_ctypes/darwin/dlfcn_simple.c') |
407 | extra_compile_args.append('-DMACOSX') | | 423 | extra_compile_args.append('-DMACOSX') |
408 | include_dirs.append('_ctypes/darwin') | | 424 | include_dirs.append('_ctypes/darwin') |
409 | @@ -2191,6 +2005,16 @@ class PyBuildExt(build_ext): | | 425 | @@ -2191,6 +2011,16 @@ class PyBuildExt(build_ext): |
410 | break | | 426 | break |
411 | | | 427 | |
412 | if ffi_inc and ffi_lib: | | 428 | if ffi_inc and ffi_lib: |
413 | + config = distutils.command.config.config(self.distribution) | | 429 | + config = distutils.command.config.config(self.distribution) |
414 | + config._check_compiler() | | 430 | + config._check_compiler() |
415 | + if any(cc in config.compiler.compiler_so for cc in ('gcc', 'clang')): | | 431 | + if any(cc in config.compiler.compiler_so for cc in ('gcc', 'clang')): |
416 | + config.compiler.compiler_so += ["-Wno-unguarded-availability-new", "-Wno-unused-value"] | | 432 | + config.compiler.compiler_so += ["-Wno-unguarded-availability-new", "-Wno-unused-value"] |
417 | + if config.check_func("ffi_prep_closure_loc", headers=['ffi.h'], include_dirs=[ffi_inc]): | | 433 | + if config.check_func("ffi_prep_closure_loc", headers=['ffi.h'], include_dirs=[ffi_inc]): |
418 | + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CLOSURE_LOC=1") | | 434 | + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CLOSURE_LOC=1") |
419 | + if config.check_func("ffi_prep_cif_var", headers=['ffi.h'], include_dirs=[ffi_inc]): | | 435 | + if config.check_func("ffi_prep_cif_var", headers=['ffi.h'], include_dirs=[ffi_inc]): |
420 | + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1") | | 436 | + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1") |
421 | + if host_platform == 'darwin' and config.check_func("ffi_closure_alloc", headers=['ffi.h'], include_dirs=[ffi_inc]): | | 437 | + if host_platform == 'darwin' and config.check_func("ffi_closure_alloc", headers=['ffi.h'], include_dirs=[ffi_inc]): |
422 | + ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1") | | 438 | + ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1") |
423 | ext.include_dirs.extend(ffi_inc) | | 439 | ext.include_dirs.extend(ffi_inc) |
424 | ext.libraries.append(ffi_lib) | | 440 | ext.libraries.append(ffi_lib) |
425 | self.use_system_libffi = True | | 441 | self.use_system_libffi = True |
426 | @@ -2342,9 +2166,9 @@ def main(): | | 442 | @@ -2342,9 +2172,9 @@ def main(): |
427 | ext_modules=[Extension('_struct', ['_struct.c'])], | | 443 | ext_modules=[Extension('_struct', ['_struct.c'])], |
428 | | | 444 | |
429 | # Scripts to install | | 445 | # Scripts to install |
430 | - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', | | 446 | - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', |
431 | - 'Tools/scripts/2to3', | | 447 | - 'Tools/scripts/2to3', |
432 | - 'Lib/smtpd.py'] | | 448 | - 'Lib/smtpd.py'] |
433 | + scripts = ['Tools/scripts/pydoc2.7', | | 449 | + scripts = ['Tools/scripts/pydoc2.7', |
434 | + 'Tools/scripts/2to3-2.7', | | 450 | + 'Tools/scripts/2to3-2.7', |
435 | + 'Tools/scripts/smtpd2.7.py'] | | 451 | + 'Tools/scripts/smtpd2.7.py'] |
436 | ) | | 452 | ) |
437 | | | 453 | |
438 | # --install-platlib | | 454 | # --install-platlib |