Annotation of pkgsrc/lang/python310/patches/patch-setup.py, revision 1.2
1.2 ! adam 1: $NetBSD: patch-setup.py,v 1.1 2021/10/05 19:07:13 adam 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:
1.2 ! adam 8: --- setup.py.orig 2021-12-06 18:23:39.000000000 +0000
1.1 adam 9: +++ setup.py
10: @@ -45,6 +45,7 @@ with warnings.catch_warnings():
11: DeprecationWarning
12: )
13:
14: + from distutils import text_file
15: from distutils.command.build_ext import build_ext
16: from distutils.command.build_scripts import build_scripts
17: from distutils.command.install import install
18: @@ -58,7 +59,7 @@ with warnings.catch_warnings():
19: TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes')
20:
21: # This global variable is used to hold the list of modules to be disabled.
22: -DISABLED_MODULE_LIST = []
23: +DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]
24:
25: # --list-module-names option used by Tools/scripts/generate_module_names.py
26: LIST_MODULE_NAMES = False
1.2 ! adam 27: @@ -249,6 +250,16 @@ def grep_headers_for(function, headers):
1.1 adam 28: return False
29:
30:
31: +def grep_headers_for(function, headers):
32: + for header in headers:
33: + try:
34: + with open(header, 'r') as f:
35: + if function in f.read():
36: + return True
37: + except UnicodeDecodeError:
38: + pass
39: + return False
40: +
41: def find_file(filename, std_dirs, paths):
42: """Searches for the directory where a given file is located,
43: and returns a possibly-empty list of additional directories, or None
1.2 ! adam 44: @@ -821,15 +832,15 @@ class PyBuildExt(build_ext):
1.1 adam 45: add_dir_to_list(dir_list, directory)
46:
47: def configure_compiler(self):
48: - # Ensure that /usr/local is always used, but the local build
49: - # directories (i.e. '.' and 'Include') must be first. See issue
50: - # 10520.
51: - if not CROSS_COMPILING:
52: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
53: - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
54: - # only change this for cross builds for 3.3, issues on Mageia
55: - if CROSS_COMPILING:
56: - self.add_cross_compiling_paths()
57: + # Add the buildlink directories for pkgsrc
58: + if os.environ.get('BUILDLINK_DIR'):
59: + dir = os.environ['BUILDLINK_DIR']
60: + libdir = dir + '/lib'
61: + incdir = dir + '/include'
62: + if libdir not in self.compiler.library_dirs:
63: + self.compiler.library_dirs.insert(0, libdir)
64: + if incdir not in self.compiler.include_dirs:
65: + self.compiler.include_dirs.insert(0, incdir)
66: self.add_multiarch_paths()
67: self.add_ldflags_cppflags()
68:
1.2 ! adam 69: @@ -877,6 +888,9 @@ class PyBuildExt(build_ext):
1.1 adam 70: self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
71:
72: if MACOS:
73: + self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
74: + self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
75: +
76: # This should work on any unixy platform ;-)
77: # If the user has bothered specifying additional -I and -L flags
78: # in OPT and LDFLAGS we might as well use them here.
1.2 ! adam 79: @@ -1104,8 +1118,6 @@ class PyBuildExt(build_ext):
1.1 adam 80: # use the same library for the readline and curses modules.
81: if 'curses' in readline_termcap_library:
82: curses_library = readline_termcap_library
83: - elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
84: - curses_library = 'ncursesw'
85: # Issue 36210: OSS provided ncurses does not link on AIX
86: # Use IBM supplied 'curses' for successful build of _curses
87: elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
1.2 ! adam 88: @@ -1209,8 +1221,7 @@ class PyBuildExt(build_ext):
1.1 adam 89: # If the curses module is enabled, check for the panel module
90: # _curses_panel needs some form of ncurses
91: skip_curses_panel = True if AIX else False
92: - if (curses_enabled and not skip_curses_panel and
93: - self.compiler.find_library_file(self.lib_dirs, panel_library)):
94: + if curses_enabled and not skip_curses_panel:
95: self.add(Extension('_curses_panel', ['_curses_panel.c'],
96: include_dirs=curses_includes,
97: define_macros=curses_defines,
1.2 ! adam 98: @@ -1455,6 +1466,31 @@ class PyBuildExt(build_ext):
1.1 adam 99: dbm_order = ['gdbm']
100: # The standard Unix dbm module:
101: if not CYGWIN:
102: + # Top half based on find_file
103: + def find_ndbm_h(dirs):
104: + ret = None
105: + if MACOS:
106: + sysroot = macosx_sdk_root()
107: + for dir in dirs:
108: + f = os.path.join(dir, 'ndbm.h')
109: + if MACOS and is_macosx_sdk_path(dir):
110: + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
111: + if not os.path.exists(f):
112: + continue
113: +
114: + ret = True
115: + input = text_file.TextFile(f)
116: + while True:
117: + line = input.readline()
118: + if not line:
119: + break
120: + if re.search('This file is part of GDBM', line):
121: + ret = None
122: + break
123: + input.close()
124: + break
125: + return ret
126: +
127: config_args = [arg.strip("'")
128: for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
129: dbm_args = [arg for arg in config_args
1.2 ! adam 130: @@ -1466,7 +1502,7 @@ class PyBuildExt(build_ext):
1.1 adam 131: dbmext = None
132: for cand in dbm_order:
133: if cand == "ndbm":
134: - if find_file("ndbm.h", self.inc_dirs, []) is not None:
135: + if find_ndbm_h(self.inc_dirs) is not None:
136: # Some systems have -lndbm, others have -lgdbm_compat,
137: # others don't have either
138: if self.compiler.find_library_file(self.lib_dirs,
1.2 ! adam 139: @@ -2326,10 +2362,7 @@ class PyBuildExt(build_ext):
1.1 adam 140: sources = ['_decimal/_decimal.c']
141: depends = ['_decimal/docstrings.h']
142: else:
143: - include_dirs = [os.path.abspath(os.path.join(self.srcdir,
144: - 'Modules',
145: - '_decimal',
146: - 'libmpdec'))]
147: + include_dirs = ['Modules/_decimal/libmpdec']
148: libraries = ['m']
149: sources = [
150: '_decimal/_decimal.c',
1.2 ! adam 151: @@ -2745,7 +2778,7 @@ def main():
1.1 adam 152: # If you change the scripts installed here, you also need to
153: # check the PyBuildScripts command above, and change the links
154: # created by the bininstall target in Makefile.pre.in
155: - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
156: + scripts = ["Tools/scripts/pydoc3",
157: "Tools/scripts/2to3"]
158: )
159:
CVSweb <webmaster@jp.NetBSD.org>