Annotation of pkgsrc/lang/python39/patches/patch-setup.py, revision 1.9
1.9 ! khorben 1: $NetBSD: patch-setup.py,v 1.8 2022/04/03 10:51:19 riastradh Exp $
1.1 adam 2:
1.4 adam 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.6 tnn 7: Don't search for modules in PREFIX. Fixes build failure when py-setuptools
8: are installed.
1.8 riastrad 9: Enable cross-build by setting sys._home and sys.path to build directory
1.1 adam 10:
1.8 riastrad 11: --- setup.py.orig 2022-03-23 21:12:08.000000000 +0000
1.1 adam 12: +++ setup.py
1.8 riastrad 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: @@ -11,6 +17,7 @@ import sysconfig
1.6 tnn 26: from glob import glob, escape
27: import _osx_support
28:
1.9 ! khorben 29: +sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/lib').match(p)]
1.6 tnn 30:
31: try:
32: import subprocess
1.8 riastrad 33: @@ -30,7 +37,7 @@ except ImportError:
1.1 adam 34: SUBPROCESS_BOOTSTRAP = True
35:
36:
37: -from distutils import log
38: +from distutils import log, text_file
39: from distutils.command.build_ext import build_ext
40: from distutils.command.build_scripts import build_scripts
41: from distutils.command.install import install
1.8 riastrad 42: @@ -44,7 +51,7 @@ from distutils.spawn import find_executa
1.1 adam 43: TEST_EXTENSIONS = True
44:
45: # This global variable is used to hold the list of modules to be disabled.
46: -DISABLED_MODULE_LIST = []
47: +DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]
48:
49:
50: def get_platform():
1.8 riastrad 51: @@ -227,6 +234,16 @@ def grep_headers_for(function, headers):
1.4 adam 52: return True
53: return False
1.2 sjmulder 54:
55: +def grep_headers_for(function, headers):
56: + for header in headers:
1.3 bsiegert 57: + try:
58: + with open(header, 'r') as f:
59: + if function in f.read():
60: + return True
61: + except UnicodeDecodeError:
62: + pass
1.2 sjmulder 63: + return False
64: +
65: def find_file(filename, std_dirs, paths):
66: """Searches for the directory where a given file is located,
67: and returns a possibly-empty list of additional directories, or None
1.8 riastrad 68: @@ -733,15 +750,15 @@ class PyBuildExt(build_ext):
1.1 adam 69: add_dir_to_list(dir_list, directory)
70:
71: def configure_compiler(self):
72: - # Ensure that /usr/local is always used, but the local build
73: - # directories (i.e. '.' and 'Include') must be first. See issue
74: - # 10520.
75: - if not CROSS_COMPILING:
76: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
77: - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
78: - # only change this for cross builds for 3.3, issues on Mageia
79: - if CROSS_COMPILING:
80: - self.add_cross_compiling_paths()
81: + # Add the buildlink directories for pkgsrc
82: + if os.environ.get('BUILDLINK_DIR'):
83: + dir = os.environ['BUILDLINK_DIR']
84: + libdir = dir + '/lib'
85: + incdir = dir + '/include'
86: + if libdir not in self.compiler.library_dirs:
87: + self.compiler.library_dirs.insert(0, libdir)
88: + if incdir not in self.compiler.include_dirs:
89: + self.compiler.include_dirs.insert(0, incdir)
90: self.add_multiarch_paths()
91: self.add_ldflags_cppflags()
92:
1.8 riastrad 93: @@ -789,6 +806,9 @@ class PyBuildExt(build_ext):
1.2 sjmulder 94: self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
95:
96: if MACOS:
97: + self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
98: + self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
99: +
100: # This should work on any unixy platform ;-)
101: # If the user has bothered specifying additional -I and -L flags
102: # in OPT and LDFLAGS we might as well use them here.
1.8 riastrad 103: @@ -1006,8 +1026,6 @@ class PyBuildExt(build_ext):
1.1 adam 104: # use the same library for the readline and curses modules.
105: if 'curses' in readline_termcap_library:
106: curses_library = readline_termcap_library
107: - elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
108: - curses_library = 'ncursesw'
109: # Issue 36210: OSS provided ncurses does not link on AIX
110: # Use IBM supplied 'curses' for successful build of _curses
111: elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
1.8 riastrad 112: @@ -1109,8 +1127,7 @@ class PyBuildExt(build_ext):
1.1 adam 113: # If the curses module is enabled, check for the panel module
114: # _curses_panel needs some form of ncurses
115: skip_curses_panel = True if AIX else False
116: - if (curses_enabled and not skip_curses_panel and
117: - self.compiler.find_library_file(self.lib_dirs, panel_library)):
118: + if curses_enabled and not skip_curses_panel:
119: self.add(Extension('_curses_panel', ['_curses_panel.c'],
120: include_dirs=curses_includes,
121: define_macros=curses_defines,
1.8 riastrad 122: @@ -1361,6 +1378,31 @@ class PyBuildExt(build_ext):
1.1 adam 123: dbm_order = ['gdbm']
124: # The standard Unix dbm module:
125: if not CYGWIN:
126: + # Top half based on find_file
127: + def find_ndbm_h(dirs):
128: + ret = None
129: + if MACOS:
130: + sysroot = macosx_sdk_root()
131: + for dir in dirs:
132: + f = os.path.join(dir, 'ndbm.h')
133: + if MACOS and is_macosx_sdk_path(dir):
134: + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
135: + if not os.path.exists(f):
136: + continue
137: +
138: + ret = True
139: + input = text_file.TextFile(f)
140: + while True:
141: + line = input.readline()
142: + if not line:
143: + break
144: + if re.search('This file is part of GDBM', line):
145: + ret = None
146: + break
147: + input.close()
148: + break
149: + return ret
150: +
151: config_args = [arg.strip("'")
152: for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
153: dbm_args = [arg for arg in config_args
1.8 riastrad 154: @@ -1372,7 +1414,7 @@ class PyBuildExt(build_ext):
1.1 adam 155: dbmext = None
156: for cand in dbm_order:
157: if cand == "ndbm":
158: - if find_file("ndbm.h", self.inc_dirs, []) is not None:
159: + if find_ndbm_h(self.inc_dirs) is not None:
160: # Some systems have -lndbm, others have -lgdbm_compat,
161: # others don't have either
162: if self.compiler.find_library_file(self.lib_dirs,
1.8 riastrad 163: @@ -2209,10 +2251,7 @@ class PyBuildExt(build_ext):
1.1 adam 164: sources = ['_decimal/_decimal.c']
165: depends = ['_decimal/docstrings.h']
166: else:
167: - include_dirs = [os.path.abspath(os.path.join(self.srcdir,
168: - 'Modules',
169: - '_decimal',
170: - 'libmpdec'))]
171: + include_dirs = ['Modules/_decimal/libmpdec']
172: libraries = ['m']
173: sources = [
174: '_decimal/_decimal.c',
1.8 riastrad 175: @@ -2597,7 +2636,7 @@ def main():
1.1 adam 176: # If you change the scripts installed here, you also need to
177: # check the PyBuildScripts command above, and change the links
178: # created by the bininstall target in Makefile.pre.in
179: - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
180: + scripts = ["Tools/scripts/pydoc3",
181: "Tools/scripts/2to3"]
182: )
183:
CVSweb <webmaster@jp.NetBSD.org>