Sun Apr 3 10:54:52 2022 UTC ()
lang/python310: Make it cross-compile.


(riastradh)
diff -r1.12 -r1.13 pkgsrc/lang/python310/Makefile
diff -r1.14 -r1.15 pkgsrc/lang/python310/distinfo
diff -r1.3 -r1.4 pkgsrc/lang/python310/patches/patch-configure
diff -r1.4 -r1.5 pkgsrc/lang/python310/patches/patch-setup.py

cvs diff -r1.12 -r1.13 pkgsrc/lang/python310/Makefile (expand / switch to unified diff)

--- pkgsrc/lang/python310/Makefile 2022/03/19 18:59:40 1.12
+++ pkgsrc/lang/python310/Makefile 2022/04/03 10:54:52 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.12 2022/03/19 18:59:40 adam Exp $ 1# $NetBSD: Makefile,v 1.13 2022/04/03 10:54:52 riastradh Exp $
2 2
3.include "dist.mk" 3.include "dist.mk"
4 4
5PKGNAME= python310-${PY_DISTVERSION} 5PKGNAME= python310-${PY_DISTVERSION}
6CATEGORIES= lang python 6CATEGORIES= lang python
7 7
8MAINTAINER= pkgsrc-users@NetBSD.org 8MAINTAINER= pkgsrc-users@NetBSD.org
9HOMEPAGE= https://www.python.org/ 9HOMEPAGE= https://www.python.org/
10COMMENT= Interpreted, interactive, object-oriented programming language 10COMMENT= Interpreted, interactive, object-oriented programming language
11LICENSE= python-software-foundation 11LICENSE= python-software-foundation
12 12
13CONFLICTS+= python-[0-9]* 13CONFLICTS+= python-[0-9]*
14 14
@@ -26,26 +26,47 @@ GNU_CONFIGURE= yes @@ -26,26 +26,47 @@ GNU_CONFIGURE= yes
26CONFIGURE_ARGS+= --enable-shared 26CONFIGURE_ARGS+= --enable-shared
27CONFIGURE_ARGS+= --with-openssl=${BUILDLINK_PREFIX.openssl} 27CONFIGURE_ARGS+= --with-openssl=${BUILDLINK_PREFIX.openssl}
28CONFIGURE_ARGS+= --with-system-ffi 28CONFIGURE_ARGS+= --with-system-ffi
29CONFIGURE_ARGS+= --without-ensurepip 29CONFIGURE_ARGS+= --without-ensurepip
30CONFIGURE_ENV+= OPT=${CFLAGS:M*:Q} 30CONFIGURE_ENV+= OPT=${CFLAGS:M*:Q}
31CONFIGURE_ENV+= ac_cv_path_mkdir=${TOOLS_PATH.mkdir} 31CONFIGURE_ENV+= ac_cv_path_mkdir=${TOOLS_PATH.mkdir}
32PKGCONFIG_OVERRIDE+= Misc/python.pc.in Misc/python-embed.pc.in 32PKGCONFIG_OVERRIDE+= Misc/python.pc.in Misc/python-embed.pc.in
33 33
34PTHREAD_OPTS+= require 34PTHREAD_OPTS+= require
35.include "../../mk/pthread.buildlink3.mk" 35.include "../../mk/pthread.buildlink3.mk"
36 36
37.include "../../mk/bsd.prefs.mk" 37.include "../../mk/bsd.prefs.mk"
38 38
 39.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
 40TOOL_DEPENDS+= ${PKGNAME}:../../${PKGPATH}
 41# XXX copied from ../../lang/python/pyversion.mk to avoid including it
 42# XXX should use NATIVE_PREFIX but we don't have that
 43CONFIGURE_ARGS+= PYTHON_FOR_BUILD=${PREFIX:Q}/bin/python3.10
 44CONFIGURE_ARGS+= MACHDEP=${PY_PLATNAME}
 45CONFIGURE_ARGS+= \
 46 _PYTHON_HOST_PLATFORM=${LOWER_OPSYS}-${MACHINE_GNU_ARCH}
 47CONFIGURE_ARGS+= ac_sys_system=${OPSYS}
 48. if ${OPSYS} == "OSF1"
 49CONFIGURE_ARGS+= ac_cv_buggy_getaddrinfo=true
 50. else
 51CONFIGURE_ARGS+= ac_cv_buggy_getaddrinfo=false
 52. endif
 53CONFIGURE_ARGS.NetBSD+= ac_cv_file__dev_ptmx=yes
 54CONFIGURE_ARGS.NetBSD+= ac_cv_file__dev_ptc=no
 55MAKE_ENV+= \
 56 _PYTHON_HOST_PLATFORM=${LOWER_OPSYS}-${MACHINE_GNU_ARCH}
 57MAKE_ENV+= _PYTHON_PROJECT_BASE=${WRKSRC:Q}
 58.endif
 59
39# http://bugs.python.org/issue13241 60# http://bugs.python.org/issue13241
40.if !empty(MACHINE_PLATFORM:MDarwin-1[12].*) 61.if !empty(MACHINE_PLATFORM:MDarwin-1[12].*)
41PKGSRC_COMPILER= clang 62PKGSRC_COMPILER= clang
42PKG_CC= clang 63PKG_CC= clang
43PKG_CXX= clang++ 64PKG_CXX= clang++
44.endif 65.endif
45 66
46# Used in socketmodule.c to determine if a sethostname declaration is required 67# Used in socketmodule.c to determine if a sethostname declaration is required
47CFLAGS.SunOS+= -DPKGSRC_OPSYS_VERSION=${OPSYS_VERSION} 68CFLAGS.SunOS+= -DPKGSRC_OPSYS_VERSION=${OPSYS_VERSION}
48LIBS.SunOS+= -lrt # fdatasync() 69LIBS.SunOS+= -lrt # fdatasync()
49LIBS.SunOS+= -luuid 70LIBS.SunOS+= -luuid
50.if ${OPSYS} == "SunOS" && ${OPSYS_VERSION} < 051100 71.if ${OPSYS} == "SunOS" && ${OPSYS_VERSION} < 051100
51SUBST_CLASSES+= setup 72SUBST_CLASSES+= setup

cvs diff -r1.14 -r1.15 pkgsrc/lang/python310/distinfo (expand / switch to unified diff)

--- pkgsrc/lang/python310/distinfo 2022/03/25 17:55:19 1.14
+++ pkgsrc/lang/python310/distinfo 2022/04/03 10:54:52 1.15
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1$NetBSD: distinfo,v 1.14 2022/03/25 17:55:19 adam Exp $ 1$NetBSD: distinfo,v 1.15 2022/04/03 10:54:52 riastradh Exp $
2 2
3BLAKE2s (Python-3.10.4.tar.xz) = 764967513abd194f54dbed2ef7520c1aeca19628627337947542b24c1ac50bb3 3BLAKE2s (Python-3.10.4.tar.xz) = 764967513abd194f54dbed2ef7520c1aeca19628627337947542b24c1ac50bb3
4SHA512 (Python-3.10.4.tar.xz) = 6c9aeecddc55c7896b2e8527fca131c7b2b6127d56ce1a001ccedfebf590334e0c0bb7c517ed3cf1da3c1910e002552b56aa7e03eeb672f42ff0bd8150799113 4SHA512 (Python-3.10.4.tar.xz) = 6c9aeecddc55c7896b2e8527fca131c7b2b6127d56ce1a001ccedfebf590334e0c0bb7c517ed3cf1da3c1910e002552b56aa7e03eeb672f42ff0bd8150799113
5Size (Python-3.10.4.tar.xz) = 19342692 bytes 5Size (Python-3.10.4.tar.xz) = 19342692 bytes
6SHA1 (patch-Lib_ctypes_util.py) = 3dec1b6b7a36e46cbfa0dfcd71c5e7fac9f60764 6SHA1 (patch-Lib_ctypes_util.py) = 3dec1b6b7a36e46cbfa0dfcd71c5e7fac9f60764
7SHA1 (patch-Lib_distutils_unixccompiler.py) = 8a91e8f4f86517a62408c3a10ed5eb50c4091fbf 7SHA1 (patch-Lib_distutils_unixccompiler.py) = 8a91e8f4f86517a62408c3a10ed5eb50c4091fbf
8SHA1 (patch-Lib_lib2to3_pgen2_driver.py) = 593c4e93c5653ab400f0a98b91db92630c0a7390 8SHA1 (patch-Lib_lib2to3_pgen2_driver.py) = 593c4e93c5653ab400f0a98b91db92630c0a7390
9SHA1 (patch-Lib_sysconfig.py) = bc6d91bf8f7121456b26ea7f080f588c96f2596f 9SHA1 (patch-Lib_sysconfig.py) = bc6d91bf8f7121456b26ea7f080f588c96f2596f
10SHA1 (patch-Makefile.pre.in) = 932a89313e8f26c435675f2487eb2141876a5f5a 10SHA1 (patch-Makefile.pre.in) = 932a89313e8f26c435675f2487eb2141876a5f5a
11SHA1 (patch-Modules_socketmodule.c) = 3e2db474b4ef08edd25528465605fff1d3d0f61b 11SHA1 (patch-Modules_socketmodule.c) = 3e2db474b4ef08edd25528465605fff1d3d0f61b
12SHA1 (patch-Modules_socketmodule.h) = 8761c7238bc74e45adefb6e647dc3b39b7bdd81c 12SHA1 (patch-Modules_socketmodule.h) = 8761c7238bc74e45adefb6e647dc3b39b7bdd81c
13SHA1 (patch-Python_thread__pthread.h) = bf1aeab011b3afedc02e68fcf5cef091b3e0aefa 13SHA1 (patch-Python_thread__pthread.h) = bf1aeab011b3afedc02e68fcf5cef091b3e0aefa
14SHA1 (patch-configure) = b238289b98d85128d0b0ad02ce926e36c0febc02 14SHA1 (patch-configure) = 8ffe98e51407d10e46e7d1531f2e0e0b58e1cfa6
15SHA1 (patch-pyconfig.h.in) = 1ab77914315acbf0352d242ed66200bea54548f6 15SHA1 (patch-pyconfig.h.in) = 1ab77914315acbf0352d242ed66200bea54548f6
16SHA1 (patch-setup.py) = 491b5ff230dd6393fabe787b429a131c88a14f45 16SHA1 (patch-setup.py) = f71085603ac5d343ee60c1d18f4f4bde0791fa6b

cvs diff -r1.3 -r1.4 pkgsrc/lang/python310/patches/patch-configure (expand / switch to unified diff)

--- pkgsrc/lang/python310/patches/patch-configure 2022/01/15 16:23:47 1.3
+++ pkgsrc/lang/python310/patches/patch-configure 2022/04/03 10:54:52 1.4
@@ -1,23 +1,33 @@ @@ -1,23 +1,33 @@
1$NetBSD: patch-configure,v 1.3 2022/01/15 16:23:47 adam Exp $ 1$NetBSD: patch-configure,v 1.4 2022/04/03 10:54:52 riastradh Exp $
2 2
3Use gnu99 instead of c99 to avoid "alloca() undefined" problems. 3Use gnu99 instead of c99 to avoid "alloca() undefined" problems.
4Fix linking on Darwin; don't use -stack_size. 4Fix linking on Darwin; don't use -stack_size.
5Changes for consistency across pkgsrc platforms. 5Changes for consistency across pkgsrc platforms.
6Simplify _sysconfigdata to include only platform name. 6Simplify _sysconfigdata to include only platform name.
7detect netcan/can.h on NetBSD 7detect netcan/can.h on NetBSD
 8Disable barrier to cross-compilation.
8 9
9--- configure.orig 2022-01-13 18:52:14.000000000 +0000 10--- configure.orig 2022-03-23 20:12:04.000000000 +0000
10+++ configure 11+++ configure
 12@@ -3380,7 +3380,7 @@ fi
 13 $as_echo "\"$MACHDEP\"" >&6; }
 14
 15
 16-if test "$cross_compiling" = yes; then
 17+if false && test "$cross_compiling" = yes; then
 18 case "$host" in
 19 *-*-linux*)
 20 case "$host_cpu" in
11@@ -7051,7 +7051,7 @@ UNIVERSAL_ARCH_FLAGS= 21@@ -7051,7 +7051,7 @@ UNIVERSAL_ARCH_FLAGS=
12 # tweak BASECFLAGS based on compiler and platform 22 # tweak BASECFLAGS based on compiler and platform
13 case $GCC in 23 case $GCC in
14 yes) 24 yes)
15- CFLAGS_NODIST="$CFLAGS_NODIST -std=c99" 25- CFLAGS_NODIST="$CFLAGS_NODIST -std=c99"
16+ CFLAGS_NODIST="$CFLAGS_NODIST -std=gnu99" 26+ CFLAGS_NODIST="$CFLAGS_NODIST -std=gnu99"
17  27
18 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra" >&5 28 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra" >&5
19 $as_echo_n "checking for -Wextra... " >&6; } 29 $as_echo_n "checking for -Wextra... " >&6; }
20@@ -8675,6 +8675,17 @@ if test "x$ac_cv_type___uint128_t" = xye 30@@ -8675,6 +8675,17 @@ if test "x$ac_cv_type___uint128_t" = xye
21 $as_echo "#define HAVE_GCC_UINT128_T 1" >>confdefs.h 31 $as_echo "#define HAVE_GCC_UINT128_T 1" >>confdefs.h
22  32
23 fi 33 fi
@@ -25,48 +35,48 @@ detect netcan/can.h on NetBSD @@ -25,48 +35,48 @@ detect netcan/can.h on NetBSD
25+#ifdef HAVE_SYS_SOCKET_H 35+#ifdef HAVE_SYS_SOCKET_H
26+#include <sys/socket.h> 36+#include <sys/socket.h>
27+#endif 37+#endif
28+ 38+
29+" 39+"
30+if test "x$ac_cv_header_netcan_can_h" = xyes 40+if test "x$ac_cv_header_netcan_can_h" = xyes
31+then : 41+then :
32+ printf "%s\n" "#define HAVE_NETCAN_CAN_H 1" >>confdefs.h 42+ printf "%s\n" "#define HAVE_NETCAN_CAN_H 1" >>confdefs.h
33+ 43+
34+fi 44+fi
35  45
36  46
37 # Sizes and alignments of various common basic types 47 # Sizes and alignments of various common basic types
38@@ -14762,10 +14773,10 @@ _ACEOF 48@@ -14729,10 +14740,10 @@ _ACEOF
39 if ac_fn_c_try_compile "$LINENO"; then : 49 if ac_fn_c_try_compile "$LINENO"; then :
40  50
41  51
42-if grep noonsees conftest.$ac_objext >/dev/null ; then 52-if grep noonsees conftest.$ac_objext >/dev/null ; then
43+if strings -a conftest.$ac_objext | grep noonsees >/dev/null ; then 53+if strings -a conftest.$ac_objext | grep noonsees >/dev/null ; then
44 ax_cv_c_float_words_bigendian=yes 54 ax_cv_c_float_words_bigendian=yes
45 fi 55 fi
46-if grep seesnoon conftest.$ac_objext >/dev/null ; then 56-if grep seesnoon conftest.$ac_objext >/dev/null ; then
47+if strings -a conftest.$ac_objext | grep seesnoon >/dev/null ; then 57+if strings -a conftest.$ac_objext | grep seesnoon >/dev/null ; then
48 if test "$ax_cv_c_float_words_bigendian" = unknown; then 58 if test "$ax_cv_c_float_words_bigendian" = unknown; then
49 ax_cv_c_float_words_bigendian=no 59 ax_cv_c_float_words_bigendian=no
50 else 60 else
51@@ -15666,7 +15677,7 @@ _ACEOF 61@@ -15633,7 +15644,7 @@ _ACEOF
52 fi 62 fi
53  63
54  64
55-EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX} 65-EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
56+EXT_SUFFIX=${SHLIB_SUFFIX} 66+EXT_SUFFIX=${SHLIB_SUFFIX}
57  67
58 { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5 68 { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
59 $as_echo_n "checking LDVERSION... " >&6; } 69 $as_echo_n "checking LDVERSION... " >&6; }
60@@ -15719,11 +15730,7 @@ fi 70@@ -15686,11 +15697,7 @@ fi
61  71
62  72
63  73
64-if test x$PLATFORM_TRIPLET = x; then 74-if test x$PLATFORM_TRIPLET = x; then
65- LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}" 75- LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
66-else 76-else
67- LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}" 77- LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
68-fi 78-fi
69+LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}" 79+LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
70  80
71  81
72 # Check for --with-wheel-pkg-dir=PATH 82 # Check for --with-wheel-pkg-dir=PATH

cvs diff -r1.4 -r1.5 pkgsrc/lang/python310/patches/patch-setup.py (expand / switch to unified diff)

--- pkgsrc/lang/python310/patches/patch-setup.py 2022/01/14 10:32:28 1.4
+++ pkgsrc/lang/python310/patches/patch-setup.py 2022/04/03 10:54:52 1.5
@@ -1,121 +1,134 @@ @@ -1,121 +1,134 @@
1$NetBSD: patch-setup.py,v 1.4 2022/01/14 10:32:28 tnn Exp $ 1$NetBSD: patch-setup.py,v 1.5 2022/04/03 10:54:52 riastradh Exp $
2 2
3Disable certain modules, so they can be built as separate packages. 3Disable certain modules, so they can be built as separate packages.
4Do not look for ncursesw. 4Do not look for ncursesw.
5Assume panel_library is correct; this is a fix for ncurses' gnupanel 5Assume panel_library is correct; this is a fix for ncurses' gnupanel
6which will get transformed to panel in buildlink. 6which will get transformed to panel in buildlink.
7Don't search for modules in PREFIX. Fixes build failure when py-setuptools 7Don't search for modules in PREFIX. Fixes build failure when py-setuptools
8 are installed.  8 are installed.
 9Enable cross-build by setting sys._home and sys.path to build directory
9 10
10--- setup.py.orig 2021-12-06 18:23:39.000000000 +0000 11--- setup.py.orig 2022-03-23 20:12:04.000000000 +0000
11+++ setup.py 12+++ setup.py
12@@ -13,6 +13,7 @@ import warnings 13@@ -1,5 +1,11 @@
 14 # Autodetecting setup.py script for building the Python extensions
 15
 16+import sys
 17+sys._home = __file__[:-len('/setup.py')]
 18+sys.path.append(__file__[:-len('/setup.py')] + '/Lib')
 19+with open('pybuilddir.txt') as pybuilddir:
 20+ sys.path.append(__file__[:-len('/setup.py')] + '/' + next(pybuilddir))
 21+
 22 import argparse
 23 import importlib._bootstrap
 24 import importlib.machinery
 25@@ -13,6 +19,7 @@ import warnings
13 from glob import glob, escape 26 from glob import glob, escape
14 import _osx_support 27 import _osx_support
15  28
16+sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/').match(p)] 29+sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/').match(p)]
17  30
18 try: 31 try:
19 import subprocess 32 import subprocess
20@@ -45,6 +46,7 @@ with warnings.catch_warnings(): 33@@ -45,6 +52,7 @@ with warnings.catch_warnings():
21 DeprecationWarning 34 DeprecationWarning
22 ) 35 )
23  36
24+ from distutils import text_file 37+ from distutils import text_file
25 from distutils.command.build_ext import build_ext 38 from distutils.command.build_ext import build_ext
26 from distutils.command.build_scripts import build_scripts 39 from distutils.command.build_scripts import build_scripts
27 from distutils.command.install import install 40 from distutils.command.install import install
28@@ -58,7 +60,7 @@ with warnings.catch_warnings(): 41@@ -58,7 +66,7 @@ with warnings.catch_warnings():
29 TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes') 42 TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes')
30  43
31 # This global variable is used to hold the list of modules to be disabled. 44 # This global variable is used to hold the list of modules to be disabled.
32-DISABLED_MODULE_LIST = [] 45-DISABLED_MODULE_LIST = []
33+DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"] 46+DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]
34  47
35 # --list-module-names option used by Tools/scripts/generate_module_names.py 48 # --list-module-names option used by Tools/scripts/generate_module_names.py
36 LIST_MODULE_NAMES = False 49 LIST_MODULE_NAMES = False
37@@ -249,6 +251,16 @@ def grep_headers_for(function, headers): 50@@ -249,6 +257,16 @@ def grep_headers_for(function, headers):
38 return False 51 return False
39  52
40  53
41+def grep_headers_for(function, headers): 54+def grep_headers_for(function, headers):
42+ for header in headers: 55+ for header in headers:
43+ try: 56+ try:
44+ with open(header, 'r') as f: 57+ with open(header, 'r') as f:
45+ if function in f.read(): 58+ if function in f.read():
46+ return True 59+ return True
47+ except UnicodeDecodeError: 60+ except UnicodeDecodeError:
48+ pass 61+ pass
49+ return False 62+ return False
50+ 63+
51 def find_file(filename, std_dirs, paths): 64 def find_file(filename, std_dirs, paths):
52 """Searches for the directory where a given file is located, 65 """Searches for the directory where a given file is located,
53 and returns a possibly-empty list of additional directories, or None 66 and returns a possibly-empty list of additional directories, or None
54@@ -821,15 +833,15 @@ class PyBuildExt(build_ext): 67@@ -823,15 +841,15 @@ class PyBuildExt(build_ext):
55 add_dir_to_list(dir_list, directory) 68 add_dir_to_list(dir_list, directory)
56  69
57 def configure_compiler(self): 70 def configure_compiler(self):
58- # Ensure that /usr/local is always used, but the local build 71- # Ensure that /usr/local is always used, but the local build
59- # directories (i.e. '.' and 'Include') must be first. See issue 72- # directories (i.e. '.' and 'Include') must be first. See issue
60- # 10520. 73- # 10520.
61- if not CROSS_COMPILING: 74- if not CROSS_COMPILING:
62- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') 75- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
63- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') 76- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
64- # only change this for cross builds for 3.3, issues on Mageia 77- # only change this for cross builds for 3.3, issues on Mageia
65- if CROSS_COMPILING: 78- if CROSS_COMPILING:
66- self.add_cross_compiling_paths() 79- self.add_cross_compiling_paths()
67+ # Add the buildlink directories for pkgsrc 80+ # Add the buildlink directories for pkgsrc
68+ if os.environ.get('BUILDLINK_DIR'): 81+ if os.environ.get('BUILDLINK_DIR'):
69+ dir = os.environ['BUILDLINK_DIR'] 82+ dir = os.environ['BUILDLINK_DIR']
70+ libdir = dir + '/lib' 83+ libdir = dir + '/lib'
71+ incdir = dir + '/include' 84+ incdir = dir + '/include'
72+ if libdir not in self.compiler.library_dirs: 85+ if libdir not in self.compiler.library_dirs:
73+ self.compiler.library_dirs.insert(0, libdir) 86+ self.compiler.library_dirs.insert(0, libdir)
74+ if incdir not in self.compiler.include_dirs: 87+ if incdir not in self.compiler.include_dirs:
75+ self.compiler.include_dirs.insert(0, incdir) 88+ self.compiler.include_dirs.insert(0, incdir)
76 self.add_multiarch_paths() 89 self.add_multiarch_paths()
77 self.add_ldflags_cppflags() 90 self.add_ldflags_cppflags()
78  91
79@@ -877,6 +889,9 @@ class PyBuildExt(build_ext): 92@@ -879,6 +897,9 @@ class PyBuildExt(build_ext):
80 self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] 93 self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
81  94
82 if MACOS: 95 if MACOS:
83+ self.inc_dirs.append(macosx_sdk_root() + '/usr/include') 96+ self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
84+ self.lib_dirs.append(macosx_sdk_root() + '/usr/lib') 97+ self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
85+ 98+
86 # This should work on any unixy platform ;-) 99 # This should work on any unixy platform ;-)
87 # If the user has bothered specifying additional -I and -L flags 100 # If the user has bothered specifying additional -I and -L flags
88 # in OPT and LDFLAGS we might as well use them here. 101 # in OPT and LDFLAGS we might as well use them here.
89@@ -1104,8 +1119,6 @@ class PyBuildExt(build_ext): 102@@ -1106,8 +1127,6 @@ class PyBuildExt(build_ext):
90 # use the same library for the readline and curses modules. 103 # use the same library for the readline and curses modules.
91 if 'curses' in readline_termcap_library: 104 if 'curses' in readline_termcap_library:
92 curses_library = readline_termcap_library 105 curses_library = readline_termcap_library
93- elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'): 106- elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
94- curses_library = 'ncursesw' 107- curses_library = 'ncursesw'
95 # Issue 36210: OSS provided ncurses does not link on AIX 108 # Issue 36210: OSS provided ncurses does not link on AIX
96 # Use IBM supplied 'curses' for successful build of _curses 109 # Use IBM supplied 'curses' for successful build of _curses
97 elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'): 110 elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
98@@ -1209,8 +1222,7 @@ class PyBuildExt(build_ext): 111@@ -1211,8 +1230,7 @@ class PyBuildExt(build_ext):
99 # If the curses module is enabled, check for the panel module 112 # If the curses module is enabled, check for the panel module
100 # _curses_panel needs some form of ncurses 113 # _curses_panel needs some form of ncurses
101 skip_curses_panel = True if AIX else False 114 skip_curses_panel = True if AIX else False
102- if (curses_enabled and not skip_curses_panel and 115- if (curses_enabled and not skip_curses_panel and
103- self.compiler.find_library_file(self.lib_dirs, panel_library)): 116- self.compiler.find_library_file(self.lib_dirs, panel_library)):
104+ if curses_enabled and not skip_curses_panel: 117+ if curses_enabled and not skip_curses_panel:
105 self.add(Extension('_curses_panel', ['_curses_panel.c'], 118 self.add(Extension('_curses_panel', ['_curses_panel.c'],
106 include_dirs=curses_includes, 119 include_dirs=curses_includes,
107 define_macros=curses_defines, 120 define_macros=curses_defines,
108@@ -1455,6 +1467,31 @@ class PyBuildExt(build_ext): 121@@ -1457,6 +1475,31 @@ class PyBuildExt(build_ext):
109 dbm_order = ['gdbm'] 122 dbm_order = ['gdbm']
110 # The standard Unix dbm module: 123 # The standard Unix dbm module:
111 if not CYGWIN: 124 if not CYGWIN:
112+ # Top half based on find_file 125+ # Top half based on find_file
113+ def find_ndbm_h(dirs): 126+ def find_ndbm_h(dirs):
114+ ret = None 127+ ret = None
115+ if MACOS: 128+ if MACOS:
116+ sysroot = macosx_sdk_root() 129+ sysroot = macosx_sdk_root()
117+ for dir in dirs: 130+ for dir in dirs:
118+ f = os.path.join(dir, 'ndbm.h') 131+ f = os.path.join(dir, 'ndbm.h')
119+ if MACOS and is_macosx_sdk_path(dir): 132+ if MACOS and is_macosx_sdk_path(dir):
120+ f = os.path.join(sysroot, dir[1:], 'ndbm.h') 133+ f = os.path.join(sysroot, dir[1:], 'ndbm.h')
121+ if not os.path.exists(f): 134+ if not os.path.exists(f):
@@ -127,43 +140,43 @@ Don't search for modules in PREFIX. Fixe @@ -127,43 +140,43 @@ Don't search for modules in PREFIX. Fixe
127+ line = input.readline() 140+ line = input.readline()
128+ if not line: 141+ if not line:
129+ break 142+ break
130+ if re.search('This file is part of GDBM', line): 143+ if re.search('This file is part of GDBM', line):
131+ ret = None 144+ ret = None
132+ break 145+ break
133+ input.close() 146+ input.close()
134+ break 147+ break
135+ return ret 148+ return ret
136+ 149+
137 config_args = [arg.strip("'") 150 config_args = [arg.strip("'")
138 for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] 151 for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
139 dbm_args = [arg for arg in config_args 152 dbm_args = [arg for arg in config_args
140@@ -1466,7 +1503,7 @@ class PyBuildExt(build_ext): 153@@ -1468,7 +1511,7 @@ class PyBuildExt(build_ext):
141 dbmext = None 154 dbmext = None
142 for cand in dbm_order: 155 for cand in dbm_order:
143 if cand == "ndbm": 156 if cand == "ndbm":
144- if find_file("ndbm.h", self.inc_dirs, []) is not None: 157- if find_file("ndbm.h", self.inc_dirs, []) is not None:
145+ if find_ndbm_h(self.inc_dirs) is not None: 158+ if find_ndbm_h(self.inc_dirs) is not None:
146 # Some systems have -lndbm, others have -lgdbm_compat, 159 # Some systems have -lndbm, others have -lgdbm_compat,
147 # others don't have either 160 # others don't have either
148 if self.compiler.find_library_file(self.lib_dirs, 161 if self.compiler.find_library_file(self.lib_dirs,
149@@ -2326,10 +2363,7 @@ class PyBuildExt(build_ext): 162@@ -2328,10 +2371,7 @@ class PyBuildExt(build_ext):
150 sources = ['_decimal/_decimal.c'] 163 sources = ['_decimal/_decimal.c']
151 depends = ['_decimal/docstrings.h'] 164 depends = ['_decimal/docstrings.h']
152 else: 165 else:
153- include_dirs = [os.path.abspath(os.path.join(self.srcdir, 166- include_dirs = [os.path.abspath(os.path.join(self.srcdir,
154- 'Modules', 167- 'Modules',
155- '_decimal', 168- '_decimal',
156- 'libmpdec'))] 169- 'libmpdec'))]
157+ include_dirs = ['Modules/_decimal/libmpdec'] 170+ include_dirs = ['Modules/_decimal/libmpdec']
158 libraries = ['m'] 171 libraries = ['m']
159 sources = [ 172 sources = [
160 '_decimal/_decimal.c', 173 '_decimal/_decimal.c',
161@@ -2745,7 +2779,7 @@ def main(): 174@@ -2747,7 +2787,7 @@ def main():
162 # If you change the scripts installed here, you also need to 175 # If you change the scripts installed here, you also need to
163 # check the PyBuildScripts command above, and change the links 176 # check the PyBuildScripts command above, and change the links
164 # created by the bininstall target in Makefile.pre.in 177 # created by the bininstall target in Makefile.pre.in
165- scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 178- scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
166+ scripts = ["Tools/scripts/pydoc3", 179+ scripts = ["Tools/scripts/pydoc3",
167 "Tools/scripts/2to3"] 180 "Tools/scripts/2to3"]
168 ) 181 )
169  182