Annotation of pkgsrc/lang/python39/patches/patch-setup.py, revision 1.2
1.2 ! sjmulder 1: $NetBSD: patch-setup.py,v 1.1 2020/10/10 20:20:12 adam Exp $
1.1 adam 2:
1.2 ! sjmulder 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: - Also look for uuid/uuid.h.
! 8: - Support for macOS 11 and Apple Silicon (ARM). Backported from:
! 9: https://github.com/python/cpython/pull/22855
1.1 adam 10:
11: --- setup.py.orig 2020-10-05 15:07:58.000000000 +0000
12: +++ setup.py
13: @@ -29,7 +29,7 @@ except ImportError:
14: SUBPROCESS_BOOTSTRAP = True
15:
16:
17: -from distutils import log
18: +from distutils import log, text_file
19: from distutils.command.build_ext import build_ext
20: from distutils.command.build_scripts import build_scripts
21: from distutils.command.install import install
22: @@ -43,7 +43,7 @@ from distutils.spawn import find_executa
23: TEST_EXTENSIONS = True
24:
25: # This global variable is used to hold the list of modules to be disabled.
26: -DISABLED_MODULE_LIST = []
27: +DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]
28:
29:
30: def get_platform():
1.2 ! sjmulder 31: @@ -239,6 +239,13 @@ def is_macosx_sdk_path(path):
! 32: or path.startswith('/Library/') )
! 33:
! 34:
! 35: +def grep_headers_for(function, headers):
! 36: + for header in headers:
! 37: + with open(header, 'r') as f:
! 38: + if function in f.read():
! 39: + return True
! 40: + return False
! 41: +
! 42: def find_file(filename, std_dirs, paths):
! 43: """Searches for the directory where a given file is located,
! 44: and returns a possibly-empty list of additional directories, or None
1.1 adam 45: @@ -740,15 +740,15 @@ class PyBuildExt(build_ext):
46: add_dir_to_list(dir_list, directory)
47:
48: def configure_compiler(self):
49: - # Ensure that /usr/local is always used, but the local build
50: - # directories (i.e. '.' and 'Include') must be first. See issue
51: - # 10520.
52: - if not CROSS_COMPILING:
53: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
54: - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
55: - # only change this for cross builds for 3.3, issues on Mageia
56: - if CROSS_COMPILING:
57: - self.add_cross_compiling_paths()
58: + # Add the buildlink directories for pkgsrc
59: + if os.environ.get('BUILDLINK_DIR'):
60: + dir = os.environ['BUILDLINK_DIR']
61: + libdir = dir + '/lib'
62: + incdir = dir + '/include'
63: + if libdir not in self.compiler.library_dirs:
64: + self.compiler.library_dirs.insert(0, libdir)
65: + if incdir not in self.compiler.include_dirs:
66: + self.compiler.include_dirs.insert(0, incdir)
67: self.add_multiarch_paths()
68: self.add_ldflags_cppflags()
69:
1.2 ! sjmulder 70: @@ -803,6 +803,9 @@ class PyBuildExt(build_ext):
! 71: self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
! 72:
! 73: if MACOS:
! 74: + self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
! 75: + self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
! 76: +
! 77: # This should work on any unixy platform ;-)
! 78: # If the user has bothered specifying additional -I and -L flags
! 79: # in OPT and LDFLAGS we might as well use them here.
1.1 adam 80: @@ -1013,8 +1013,6 @@ class PyBuildExt(build_ext):
81: # use the same library for the readline and curses modules.
82: if 'curses' in readline_termcap_library:
83: curses_library = readline_termcap_library
84: - elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
85: - curses_library = 'ncursesw'
86: # Issue 36210: OSS provided ncurses does not link on AIX
87: # Use IBM supplied 'curses' for successful build of _curses
88: elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
89: @@ -1116,8 +1114,7 @@ class PyBuildExt(build_ext):
90: # If the curses module is enabled, check for the panel module
91: # _curses_panel needs some form of ncurses
92: skip_curses_panel = True if AIX else False
93: - if (curses_enabled and not skip_curses_panel and
94: - self.compiler.find_library_file(self.lib_dirs, panel_library)):
95: + if curses_enabled and not skip_curses_panel:
96: self.add(Extension('_curses_panel', ['_curses_panel.c'],
97: include_dirs=curses_includes,
98: define_macros=curses_defines,
99: @@ -1368,6 +1365,31 @@ class PyBuildExt(build_ext):
100: dbm_order = ['gdbm']
101: # The standard Unix dbm module:
102: if not CYGWIN:
103: + # Top half based on find_file
104: + def find_ndbm_h(dirs):
105: + ret = None
106: + if MACOS:
107: + sysroot = macosx_sdk_root()
108: + for dir in dirs:
109: + f = os.path.join(dir, 'ndbm.h')
110: + if MACOS and is_macosx_sdk_path(dir):
111: + f = os.path.join(sysroot, dir[1:], 'ndbm.h')
112: + if not os.path.exists(f):
113: + continue
114: +
115: + ret = True
116: + input = text_file.TextFile(f)
117: + while True:
118: + line = input.readline()
119: + if not line:
120: + break
121: + if re.search('This file is part of GDBM', line):
122: + ret = None
123: + break
124: + input.close()
125: + break
126: + return ret
127: +
128: config_args = [arg.strip("'")
129: for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
130: dbm_args = [arg for arg in config_args
131: @@ -1379,7 +1401,7 @@ class PyBuildExt(build_ext):
132: dbmext = None
133: for cand in dbm_order:
134: if cand == "ndbm":
135: - if find_file("ndbm.h", self.inc_dirs, []) is not None:
136: + if find_ndbm_h(self.inc_dirs) is not None:
137: # Some systems have -lndbm, others have -lgdbm_compat,
138: # others don't have either
139: if self.compiler.find_library_file(self.lib_dirs,
140: @@ -1779,6 +1801,8 @@ class PyBuildExt(build_ext):
141: def detect_uuid(self):
142: # Build the _uuid module if possible
143: uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"])
144: + if uuid_incs is None:
145: + uuid_incs = find_file("uuid/uuid.h", self.inc_dirs, [])
146: if uuid_incs is not None:
147: if self.compiler.find_library_file(self.lib_dirs, 'uuid'):
148: uuid_libs = ['uuid']
1.2 ! sjmulder 149: @@ -2101,43 +2108,17 @@ class PyBuildExt(build_ext):
! 150: library_dirs=added_lib_dirs))
! 151: return True
! 152:
! 153: - def configure_ctypes_darwin(self, ext):
! 154: - # Darwin (OS X) uses preconfigured files, in
! 155: - # the Modules/_ctypes/libffi_osx directory.
! 156: - ffi_srcdir = os.path.abspath(os.path.join(self.srcdir, 'Modules',
! 157: - '_ctypes', 'libffi_osx'))
! 158: - sources = [os.path.join(ffi_srcdir, p)
! 159: - for p in ['ffi.c',
! 160: - 'x86/darwin64.S',
! 161: - 'x86/x86-darwin.S',
! 162: - 'x86/x86-ffi_darwin.c',
! 163: - 'x86/x86-ffi64.c',
! 164: - 'powerpc/ppc-darwin.S',
! 165: - 'powerpc/ppc-darwin_closure.S',
! 166: - 'powerpc/ppc-ffi_darwin.c',
! 167: - 'powerpc/ppc64-darwin_closure.S',
! 168: - ]]
! 169: -
! 170: - # Add .S (preprocessed assembly) to C compiler source extensions.
! 171: - self.compiler.src_extensions.append('.S')
! 172: -
! 173: - include_dirs = [os.path.join(ffi_srcdir, 'include'),
! 174: - os.path.join(ffi_srcdir, 'powerpc')]
! 175: - ext.include_dirs.extend(include_dirs)
! 176: - ext.sources.extend(sources)
! 177: - return True
! 178: -
! 179: def configure_ctypes(self, ext):
! 180: - if not self.use_system_libffi:
! 181: - if MACOS:
! 182: - return self.configure_ctypes_darwin(ext)
! 183: - print('INFO: Could not locate ffi libs and/or headers')
! 184: - return False
! 185: return True
! 186:
! 187: def detect_ctypes(self):
! 188: # Thomas Heller's _ctypes module
! 189: - self.use_system_libffi = False
! 190: +
! 191: + if (not sysconfig.get_config_var("LIBFFI_INCLUDEDIR") and MACOS):
! 192: + self.use_system_libffi = True
! 193: + else:
! 194: + self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS")
! 195: +
! 196: include_dirs = []
! 197: extra_compile_args = ['-DPy_BUILD_CORE_MODULE']
! 198: extra_link_args = []
! 199: @@ -2150,11 +2131,9 @@ class PyBuildExt(build_ext):
! 200:
! 201: if MACOS:
! 202: sources.append('_ctypes/malloc_closure.c')
! 203: - sources.append('_ctypes/darwin/dlfcn_simple.c')
! 204: + extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1')
! 205: extra_compile_args.append('-DMACOSX')
! 206: include_dirs.append('_ctypes/darwin')
! 207: - # XXX Is this still needed?
! 208: - # extra_link_args.extend(['-read_only_relocs', 'warning'])
! 209:
! 210: elif HOST_PLATFORM == 'sunos5':
! 211: # XXX This shouldn't be necessary; it appears that some
! 212: @@ -2184,31 +2163,48 @@ class PyBuildExt(build_ext):
! 213: sources=['_ctypes/_ctypes_test.c'],
! 214: libraries=['m']))
! 215:
! 216: + ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
! 217: + ffi_lib = None
! 218: +
! 219: ffi_inc_dirs = self.inc_dirs.copy()
! 220: if MACOS:
! 221: - if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
! 222: - return
! 223: - # OS X 10.5 comes with libffi.dylib; the include files are
! 224: - # in /usr/include/ffi
! 225: - ffi_inc_dirs.append('/usr/include/ffi')
! 226: -
! 227: - ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
! 228: - if not ffi_inc or ffi_inc[0] == '':
! 229: - ffi_inc = find_file('ffi.h', [], ffi_inc_dirs)
! 230: - if ffi_inc is not None:
! 231: - ffi_h = ffi_inc[0] + '/ffi.h'
! 232: + ffi_in_sdk = os.path.join(macosx_sdk_root(), "usr/include/ffi")
! 233: +
! 234: + if not ffi_inc:
! 235: + if os.path.exists(ffi_in_sdk):
! 236: + ext.extra_compile_args.append("-DUSING_APPLE_OS_LIBFFI=1")
! 237: + ffi_inc = ffi_in_sdk
! 238: + ffi_lib = 'ffi'
! 239: + else:
! 240: + # OS X 10.5 comes with libffi.dylib; the include files are
! 241: + # in /usr/include/ffi
! 242: + ffi_inc_dirs.append('/usr/include/ffi')
! 243: +
! 244: + if not ffi_inc:
! 245: + found = find_file('ffi.h', [], ffi_inc_dirs)
! 246: + if found:
! 247: + ffi_inc = found[0]
! 248: + if ffi_inc:
! 249: + ffi_h = ffi_inc + '/ffi.h'
! 250: if not os.path.exists(ffi_h):
! 251: ffi_inc = None
! 252: print('Header file {} does not exist'.format(ffi_h))
! 253: - ffi_lib = None
! 254: - if ffi_inc is not None:
! 255: + if ffi_lib is None and ffi_inc:
! 256: for lib_name in ('ffi', 'ffi_pic'):
! 257: if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
! 258: ffi_lib = lib_name
! 259: break
! 260:
! 261: if ffi_inc and ffi_lib:
! 262: - ext.include_dirs.extend(ffi_inc)
! 263: + ffi_headers = glob(os.path.join(ffi_inc, '*.h'))
! 264: + if grep_headers_for('ffi_prep_cif_var', ffi_headers):
! 265: + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1")
! 266: + if grep_headers_for('ffi_prep_closure_loc', ffi_headers):
! 267: + ext.extra_compile_args.append("-DHAVE_FFI_PREP_CLOSURE_LOC=1")
! 268: + if grep_headers_for('ffi_closure_alloc', ffi_headers):
! 269: + ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1")
! 270: +
! 271: + ext.include_dirs.append(ffi_inc)
! 272: ext.libraries.append(ffi_lib)
! 273: self.use_system_libffi = True
! 274:
1.1 adam 275: @@ -2226,10 +2250,7 @@ class PyBuildExt(build_ext):
276: sources = ['_decimal/_decimal.c']
277: depends = ['_decimal/docstrings.h']
278: else:
279: - include_dirs = [os.path.abspath(os.path.join(self.srcdir,
280: - 'Modules',
281: - '_decimal',
282: - 'libmpdec'))]
283: + include_dirs = ['Modules/_decimal/libmpdec']
284: libraries = ['m']
285: sources = [
286: '_decimal/_decimal.c',
287: @@ -2609,7 +2630,7 @@ def main():
288: # If you change the scripts installed here, you also need to
289: # check the PyBuildScripts command above, and change the links
290: # created by the bininstall target in Makefile.pre.in
291: - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
292: + scripts = ["Tools/scripts/pydoc3",
293: "Tools/scripts/2to3"]
294: )
295:
CVSweb <webmaster@jp.NetBSD.org>