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