Annotation of pkgsrc/lang/python310/patches/patch-setup.py, revision 1.8
1.8 ! riastrad 1: $NetBSD: patch-setup.py,v 1.7 2023/10/23 06:36:00 wiz Exp $
1.1 adam 2:
3: Disable certain modules, so they can be built as separate packages.
4: Do not look for ncursesw.
5: Assume panel_library is correct; this is a fix for ncurses' gnupanel
6: which will get transformed to panel in buildlink.
1.3 tnn 7: Don't search for modules in PREFIX. Fixes build failure when py-setuptools
1.5 riastrad 8: are installed.
9: Enable cross-build by setting sys._home and sys.path to build directory
1.8 ! riastrad 10: Disable circuitous readline detection which tries to outsmart pkgsrc's
! 11: static choice of libreadline and (fake-)ncurses and trips over its elven
! 12: shoelaces when cross-compiling.
1.1 adam 13:
1.8 ! riastrad 14: --- setup.py.orig 2023-08-24 12:46:25.000000000 +0000
1.1 adam 15: +++ setup.py
1.5 riastrad 16: @@ -1,5 +1,11 @@
17: # Autodetecting setup.py script for building the Python extensions
18:
19: +import sys
20: +sys._home = __file__[:-len('/setup.py')]
21: +sys.path.append(__file__[:-len('/setup.py')] + '/Lib')
22: +with open('pybuilddir.txt') as pybuilddir:
23: + sys.path.append(__file__[:-len('/setup.py')] + '/' + next(pybuilddir))
24: +
25: import argparse
26: import importlib._bootstrap
27: import importlib.machinery
28: @@ -13,6 +19,7 @@ import warnings
1.3 tnn 29: from glob import glob, escape
30: import _osx_support
31:
1.6 khorben 32: +sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/lib').match(p)]
1.3 tnn 33:
34: try:
35: import subprocess
1.5 riastrad 36: @@ -45,6 +52,7 @@ with warnings.catch_warnings():
1.1 adam 37: DeprecationWarning
38: )
39:
40: + from distutils import text_file
41: from distutils.command.build_ext import build_ext
42: from distutils.command.build_scripts import build_scripts
43: from distutils.command.install import install
1.5 riastrad 44: @@ -58,7 +66,7 @@ with warnings.catch_warnings():
1.1 adam 45: TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes')
46:
47: # This global variable is used to hold the list of modules to be disabled.
48: -DISABLED_MODULE_LIST = []
1.7 wiz 49: +DISABLED_MODULE_LIST = ["_gdbm", "_tkinter", "xxlimited"]
1.1 adam 50:
51: # --list-module-names option used by Tools/scripts/generate_module_names.py
52: LIST_MODULE_NAMES = False
1.5 riastrad 53: @@ -249,6 +257,16 @@ def grep_headers_for(function, headers):
1.1 adam 54: return False
55:
56:
57: +def grep_headers_for(function, headers):
58: + for header in headers:
59: + try:
60: + with open(header, 'r') as f:
61: + if function in f.read():
62: + return True
63: + except UnicodeDecodeError:
64: + pass
65: + return False
66: +
67: def find_file(filename, std_dirs, paths):
68: """Searches for the directory where a given file is located,
69: and returns a possibly-empty list of additional directories, or None
1.8 ! riastrad 70: @@ -822,15 +840,15 @@ class PyBuildExt(build_ext):
1.1 adam 71: add_dir_to_list(dir_list, directory)
72:
73: def configure_compiler(self):
74: - # Ensure that /usr/local is always used, but the local build
75: - # directories (i.e. '.' and 'Include') must be first. See issue
76: - # 10520.
77: - if not CROSS_COMPILING:
78: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
79: - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
80: - # only change this for cross builds for 3.3, issues on Mageia
81: - if CROSS_COMPILING:
82: - self.add_cross_compiling_paths()
83: + # Add the buildlink directories for pkgsrc
84: + if os.environ.get('BUILDLINK_DIR'):
85: + dir = os.environ['BUILDLINK_DIR']
86: + libdir = dir + '/lib'
87: + incdir = dir + '/include'
88: + if libdir not in self.compiler.library_dirs:
89: + self.compiler.library_dirs.insert(0, libdir)
90: + if incdir not in self.compiler.include_dirs:
91: + self.compiler.include_dirs.insert(0, incdir)
92: self.add_multiarch_paths()
93: self.add_ldflags_cppflags()
94:
1.8 ! riastrad 95: @@ -878,6 +896,9 @@ class PyBuildExt(build_ext):
1.1 adam 96: self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
97:
98: if MACOS:
99: + self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
100: + self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
101: +
102: # This should work on any unixy platform ;-)
103: # If the user has bothered specifying additional -I and -L flags
104: # in OPT and LDFLAGS we might as well use them here.
1.8 ! riastrad 105: @@ -1067,71 +1088,10 @@ class PyBuildExt(build_ext):
! 106: def detect_readline_curses(self):
! 107: # readline
! 108: readline_termcap_library = ""
! 109: - curses_library = ""
! 110: - # Cannot use os.popen here in py3k.
! 111: - tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
! 112: - if not os.path.exists(self.build_temp):
! 113: - os.makedirs(self.build_temp)
! 114: - # Determine if readline is already linked against curses or tinfo.
! 115: - if sysconfig.get_config_var('HAVE_LIBREADLINE'):
! 116: - if sysconfig.get_config_var('WITH_EDITLINE'):
! 117: - readline_lib = 'edit'
! 118: - else:
! 119: - readline_lib = 'readline'
! 120: - do_readline = self.compiler.find_library_file(self.lib_dirs,
! 121: - readline_lib)
! 122: - if CROSS_COMPILING:
! 123: - ret = run_command("%s -d %s | grep '(NEEDED)' > %s"
! 124: - % (sysconfig.get_config_var('READELF'),
! 125: - do_readline, tmpfile))
! 126: - elif find_executable('ldd'):
! 127: - ret = run_command("ldd %s > %s" % (do_readline, tmpfile))
! 128: - else:
! 129: - ret = 1
! 130: - if ret == 0:
! 131: - with open(tmpfile) as fp:
! 132: - for ln in fp:
! 133: - if 'curses' in ln:
! 134: - readline_termcap_library = re.sub(
! 135: - r'.*lib(n?cursesw?)\.so.*', r'\1', ln
! 136: - ).rstrip()
! 137: - break
! 138: - # termcap interface split out from ncurses
! 139: - if 'tinfo' in ln:
! 140: - readline_termcap_library = 'tinfo'
! 141: - break
! 142: - if os.path.exists(tmpfile):
! 143: - os.unlink(tmpfile)
! 144: - else:
! 145: - do_readline = False
! 146: - # Issue 7384: If readline is already linked against curses,
! 147: - # use the same library for the readline and curses modules.
! 148: - if 'curses' in readline_termcap_library:
! 149: - curses_library = readline_termcap_library
1.1 adam 150: - elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
151: - curses_library = 'ncursesw'
1.8 ! riastrad 152: - # Issue 36210: OSS provided ncurses does not link on AIX
! 153: - # Use IBM supplied 'curses' for successful build of _curses
! 154: - elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
! 155: - curses_library = 'curses'
! 156: - elif self.compiler.find_library_file(self.lib_dirs, 'ncurses'):
! 157: - curses_library = 'ncurses'
! 158: - elif self.compiler.find_library_file(self.lib_dirs, 'curses'):
! 159: - curses_library = 'curses'
! 160: + curses_library = "ncurses"
! 161: + do_readline = True
! 162: + readline_lib = 'readline'
! 163:
! 164: - if MACOS:
! 165: - os_release = int(os.uname()[2].split('.')[0])
! 166: - dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
! 167: - if (dep_target and
! 168: - (tuple(int(n) for n in dep_target.split('.')[0:2])
! 169: - < (10, 5) ) ):
! 170: - os_release = 8
! 171: - if os_release < 9:
! 172: - # MacOSX 10.4 has a broken readline. Don't try to build
! 173: - # the readline module unless the user has installed a fixed
! 174: - # readline package
! 175: - if find_file('readline/rlconf.h', self.inc_dirs, []) is None:
! 176: - do_readline = False
! 177: if do_readline:
! 178: if MACOS and os_release < 9:
! 179: # In every directory on the search path search for a dynamic
! 180: @@ -1213,8 +1173,7 @@ class PyBuildExt(build_ext):
1.1 adam 181: # If the curses module is enabled, check for the panel module
182: # _curses_panel needs some form of ncurses
183: skip_curses_panel = True if AIX else False
184: - if (curses_enabled and not skip_curses_panel and
185: - self.compiler.find_library_file(self.lib_dirs, panel_library)):
186: + if curses_enabled and not skip_curses_panel:
187: self.add(Extension('_curses_panel', ['_curses_panel.c'],
188: include_dirs=curses_includes,
189: define_macros=curses_defines,
1.8 ! riastrad 190: @@ -1459,6 +1418,31 @@ class PyBuildExt(build_ext):
1.1 adam 191: dbm_order = ['gdbm']
192: # The standard Unix dbm module:
193: if not CYGWIN:
194: + # Top half based on find_file
195: + def find_ndbm_h(dirs):
196: + ret = None
197: + if MACOS:
198: + sysroot = macosx_sdk_root()
199: + for dir in dirs:
200: + f = os.path.join(dir, 'ndbm.h')
201: + if MACOS and is_macosx_sdk_path(dir):
202: + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
203: + if not os.path.exists(f):
204: + continue
205: +
206: + ret = True
207: + input = text_file.TextFile(f)
208: + while True:
209: + line = input.readline()
210: + if not line:
211: + break
212: + if re.search('This file is part of GDBM', line):
213: + ret = None
214: + break
215: + input.close()
216: + break
217: + return ret
218: +
219: config_args = [arg.strip("'")
220: for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
221: dbm_args = [arg for arg in config_args
1.8 ! riastrad 222: @@ -1470,7 +1454,7 @@ class PyBuildExt(build_ext):
1.1 adam 223: dbmext = None
224: for cand in dbm_order:
225: if cand == "ndbm":
226: - if find_file("ndbm.h", self.inc_dirs, []) is not None:
227: + if find_ndbm_h(self.inc_dirs) is not None:
228: # Some systems have -lndbm, others have -lgdbm_compat,
229: # others don't have either
230: if self.compiler.find_library_file(self.lib_dirs,
1.8 ! riastrad 231: @@ -2333,10 +2317,7 @@ class PyBuildExt(build_ext):
1.1 adam 232: sources = ['_decimal/_decimal.c']
233: depends = ['_decimal/docstrings.h']
234: else:
235: - include_dirs = [os.path.abspath(os.path.join(self.srcdir,
236: - 'Modules',
237: - '_decimal',
238: - 'libmpdec'))]
239: + include_dirs = ['Modules/_decimal/libmpdec']
240: libraries = ['m']
241: sources = [
242: '_decimal/_decimal.c',
1.8 ! riastrad 243: @@ -2752,7 +2733,7 @@ def main():
1.1 adam 244: # If you change the scripts installed here, you also need to
245: # check the PyBuildScripts command above, and change the links
246: # created by the bininstall target in Makefile.pre.in
247: - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
248: + scripts = ["Tools/scripts/pydoc3",
249: "Tools/scripts/2to3"]
250: )
251:
CVSweb <webmaster@jp.NetBSD.org>