Andrew M. Kuchling | 66012fe | 2001-01-26 21:56:58 +0000 | [diff] [blame] | 1 | # Autodetecting setup.py script for building the Python extensions |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 2 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 3 | import argparse |
Eric Snow | 335e14d | 2014-01-04 15:09:28 -0700 | [diff] [blame] | 4 | import importlib._bootstrap |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 5 | import importlib.machinery |
Eric Snow | 335e14d | 2014-01-04 15:09:28 -0700 | [diff] [blame] | 6 | import importlib.util |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 7 | import os |
| 8 | import re |
| 9 | import sys |
Tarek Ziadé | edacea3 | 2010-01-29 11:41:03 +0000 | [diff] [blame] | 10 | import sysconfig |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 11 | from glob import glob |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 12 | |
| 13 | from distutils import log |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 14 | from distutils.command.build_ext import build_ext |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 15 | from distutils.command.build_scripts import build_scripts |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 16 | from distutils.command.install import install |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 17 | from distutils.command.install_lib import install_lib |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 18 | from distutils.core import Extension, setup |
| 19 | from distutils.errors import CCompilerError, DistutilsError |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 20 | from distutils.spawn import find_executable |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 21 | |
Antoine Pitrou | 2c0a916 | 2014-09-26 23:31:59 +0200 | [diff] [blame] | 22 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 23 | # Compile extensions used to test Python? |
| 24 | TEST_EXTENSIONS = True |
| 25 | |
| 26 | # This global variable is used to hold the list of modules to be disabled. |
| 27 | DISABLED_MODULE_LIST = [] |
| 28 | |
| 29 | |
doko@ubuntu.com | 93df16b | 2012-06-30 14:32:08 +0200 | [diff] [blame] | 30 | def get_platform(): |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 31 | # Cross compiling |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 32 | if "_PYTHON_HOST_PLATFORM" in os.environ: |
| 33 | return os.environ["_PYTHON_HOST_PLATFORM"] |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 34 | |
doko@ubuntu.com | 93df16b | 2012-06-30 14:32:08 +0200 | [diff] [blame] | 35 | # Get value of sys.platform |
| 36 | if sys.platform.startswith('osf1'): |
| 37 | return 'osf1' |
| 38 | return sys.platform |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 39 | |
| 40 | |
| 41 | CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ) |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 42 | HOST_PLATFORM = get_platform() |
| 43 | MS_WINDOWS = (HOST_PLATFORM == 'win32') |
| 44 | CYGWIN = (HOST_PLATFORM == 'cygwin') |
| 45 | MACOS = (HOST_PLATFORM == 'darwin') |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 46 | VXWORKS = ('vxworks' in HOST_PLATFORM) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 47 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 48 | |
| 49 | SUMMARY = """ |
| 50 | Python is an interpreted, interactive, object-oriented programming |
| 51 | language. It is often compared to Tcl, Perl, Scheme or Java. |
| 52 | |
| 53 | Python combines remarkable power with very clear syntax. It has |
| 54 | modules, classes, exceptions, very high level dynamic data types, and |
| 55 | dynamic typing. There are interfaces to many system calls and |
| 56 | libraries, as well as to various windowing systems (X11, Motif, Tk, |
| 57 | Mac, MFC). New built-in modules are easily written in C or C++. Python |
| 58 | is also usable as an extension language for applications that need a |
| 59 | programmable interface. |
| 60 | |
| 61 | The Python implementation is portable: it runs on many brands of UNIX, |
| 62 | on Windows, DOS, Mac, Amiga... If your favorite system isn't |
| 63 | listed here, it may still be supported, if there's a C compiler for |
| 64 | it. Ask around on comp.lang.python -- or just try compiling Python |
| 65 | yourself. |
| 66 | """ |
| 67 | |
| 68 | CLASSIFIERS = """ |
| 69 | Development Status :: 6 - Mature |
| 70 | License :: OSI Approved :: Python Software Foundation License |
| 71 | Natural Language :: English |
| 72 | Programming Language :: C |
| 73 | Programming Language :: Python |
| 74 | Topic :: Software Development |
| 75 | """ |
| 76 | |
| 77 | |
| 78 | # Set common compiler and linker flags derived from the Makefile, |
| 79 | # reserved for building the interpreter and the stdlib modules. |
| 80 | # See bpo-21121 and bpo-35257 |
| 81 | def set_compiler_flags(compiler_flags, compiler_py_flags_nodist): |
| 82 | flags = sysconfig.get_config_var(compiler_flags) |
| 83 | py_flags_nodist = sysconfig.get_config_var(compiler_py_flags_nodist) |
| 84 | sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist |
| 85 | |
| 86 | |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 87 | def add_dir_to_list(dirlist, dir): |
Barry Warsaw | 807bd0a | 2010-11-24 20:30:00 +0000 | [diff] [blame] | 88 | """Add the directory 'dir' to the list 'dirlist' (after any relative |
| 89 | directories) if: |
| 90 | |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 91 | 1) 'dir' is not already in 'dirlist' |
Barry Warsaw | 807bd0a | 2010-11-24 20:30:00 +0000 | [diff] [blame] | 92 | 2) 'dir' actually exists, and is a directory. |
| 93 | """ |
| 94 | if dir is None or not os.path.isdir(dir) or dir in dirlist: |
| 95 | return |
| 96 | for i, path in enumerate(dirlist): |
| 97 | if not os.path.isabs(path): |
| 98 | dirlist.insert(i + 1, dir) |
Barry Warsaw | 34520cd | 2010-11-27 20:03:03 +0000 | [diff] [blame] | 99 | return |
| 100 | dirlist.insert(0, dir) |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 101 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 102 | |
xdegaye | 77f5139 | 2017-11-25 17:25:30 +0100 | [diff] [blame] | 103 | def sysroot_paths(make_vars, subdirs): |
| 104 | """Get the paths of sysroot sub-directories. |
| 105 | |
| 106 | * make_vars: a sequence of names of variables of the Makefile where |
| 107 | sysroot may be set. |
| 108 | * subdirs: a sequence of names of subdirectories used as the location for |
| 109 | headers or libraries. |
| 110 | """ |
| 111 | |
| 112 | dirs = [] |
| 113 | for var_name in make_vars: |
| 114 | var = sysconfig.get_config_var(var_name) |
| 115 | if var is not None: |
| 116 | m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var) |
| 117 | if m is not None: |
| 118 | sysroot = m.group(1).strip('"') |
| 119 | for subdir in subdirs: |
| 120 | if os.path.isabs(subdir): |
| 121 | subdir = subdir[1:] |
| 122 | path = os.path.join(sysroot, subdir) |
| 123 | if os.path.isdir(path): |
| 124 | dirs.append(path) |
| 125 | break |
| 126 | return dirs |
| 127 | |
Ned Deily | 0288dd6 | 2019-06-03 06:34:48 -0400 | [diff] [blame] | 128 | MACOS_SDK_ROOT = None |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 129 | |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 130 | def macosx_sdk_root(): |
Ned Deily | 0288dd6 | 2019-06-03 06:34:48 -0400 | [diff] [blame] | 131 | """Return the directory of the current macOS SDK. |
| 132 | |
| 133 | If no SDK was explicitly configured, call the compiler to find which |
| 134 | include files paths are being searched by default. Use '/' if the |
| 135 | compiler is searching /usr/include (meaning system header files are |
| 136 | installed) or use the root of an SDK if that is being searched. |
| 137 | (The SDK may be supplied via Xcode or via the Command Line Tools). |
| 138 | The SDK paths used by Apple-supplied tool chains depend on the |
| 139 | setting of various variables; see the xcrun man page for more info. |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 140 | """ |
Ned Deily | 0288dd6 | 2019-06-03 06:34:48 -0400 | [diff] [blame] | 141 | global MACOS_SDK_ROOT |
| 142 | |
| 143 | # If already called, return cached result. |
| 144 | if MACOS_SDK_ROOT: |
| 145 | return MACOS_SDK_ROOT |
| 146 | |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 147 | cflags = sysconfig.get_config_var('CFLAGS') |
| 148 | m = re.search(r'-isysroot\s+(\S+)', cflags) |
Ned Deily | 0288dd6 | 2019-06-03 06:34:48 -0400 | [diff] [blame] | 149 | if m is not None: |
| 150 | MACOS_SDK_ROOT = m.group(1) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 151 | else: |
Ned Deily | 0288dd6 | 2019-06-03 06:34:48 -0400 | [diff] [blame] | 152 | MACOS_SDK_ROOT = '/' |
| 153 | cc = sysconfig.get_config_var('CC') |
| 154 | tmpfile = '/tmp/setup_sdk_root.%d' % os.getpid() |
| 155 | try: |
| 156 | os.unlink(tmpfile) |
| 157 | except: |
| 158 | pass |
| 159 | ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile)) |
| 160 | in_incdirs = False |
| 161 | try: |
| 162 | if ret >> 8 == 0: |
| 163 | with open(tmpfile) as fp: |
| 164 | for line in fp.readlines(): |
| 165 | if line.startswith("#include <...>"): |
| 166 | in_incdirs = True |
| 167 | elif line.startswith("End of search list"): |
| 168 | in_incdirs = False |
| 169 | elif in_incdirs: |
| 170 | line = line.strip() |
| 171 | if line == '/usr/include': |
| 172 | MACOS_SDK_ROOT = '/' |
| 173 | elif line.endswith(".sdk/usr/include"): |
| 174 | MACOS_SDK_ROOT = line[:-12] |
| 175 | finally: |
| 176 | os.unlink(tmpfile) |
| 177 | |
| 178 | return MACOS_SDK_ROOT |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 179 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 180 | |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 181 | def is_macosx_sdk_path(path): |
| 182 | """ |
| 183 | Returns True if 'path' can be located in an OSX SDK |
| 184 | """ |
Ned Deily | 2910a7b | 2012-07-30 02:35:58 -0700 | [diff] [blame] | 185 | return ( (path.startswith('/usr/') and not path.startswith('/usr/local')) |
| 186 | or path.startswith('/System/') |
| 187 | or path.startswith('/Library/') ) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 188 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 189 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 190 | def find_file(filename, std_dirs, paths): |
| 191 | """Searches for the directory where a given file is located, |
| 192 | and returns a possibly-empty list of additional directories, or None |
| 193 | if the file couldn't be found at all. |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 194 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 195 | 'filename' is the name of a file, such as readline.h or libcrypto.a. |
| 196 | 'std_dirs' is the list of standard system directories; if the |
| 197 | file is found in one of them, no additional directives are needed. |
| 198 | 'paths' is a list of additional locations to check; if the file is |
| 199 | found in one of them, the resulting list will contain the directory. |
| 200 | """ |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 201 | if MACOS: |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 202 | # Honor the MacOSX SDK setting when one was specified. |
| 203 | # An SDK is a directory with the same structure as a real |
| 204 | # system, but with only header files and libraries. |
| 205 | sysroot = macosx_sdk_root() |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 206 | |
| 207 | # Check the standard locations |
| 208 | for dir in std_dirs: |
| 209 | f = os.path.join(dir, filename) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 210 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 211 | if MACOS and is_macosx_sdk_path(dir): |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 212 | f = os.path.join(sysroot, dir[1:], filename) |
| 213 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 214 | if os.path.exists(f): return [] |
| 215 | |
| 216 | # Check the additional directories |
| 217 | for dir in paths: |
| 218 | f = os.path.join(dir, filename) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 219 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 220 | if MACOS and is_macosx_sdk_path(dir): |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 221 | f = os.path.join(sysroot, dir[1:], filename) |
| 222 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 223 | if os.path.exists(f): |
| 224 | return [dir] |
| 225 | |
| 226 | # Not found anywhere |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 227 | return None |
| 228 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 229 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 230 | def find_library_file(compiler, libname, std_dirs, paths): |
Andrew M. Kuchling | a246d9f | 2002-11-27 13:43:46 +0000 | [diff] [blame] | 231 | result = compiler.find_library_file(std_dirs + paths, libname) |
| 232 | if result is None: |
| 233 | return None |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 234 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 235 | if MACOS: |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 236 | sysroot = macosx_sdk_root() |
| 237 | |
Andrew M. Kuchling | a246d9f | 2002-11-27 13:43:46 +0000 | [diff] [blame] | 238 | # Check whether the found file is in one of the standard directories |
| 239 | dirname = os.path.dirname(result) |
| 240 | for p in std_dirs: |
| 241 | # Ensure path doesn't end with path separator |
Skip Montanaro | 9f5178a | 2003-05-06 20:59:57 +0000 | [diff] [blame] | 242 | p = p.rstrip(os.sep) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 243 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 244 | if MACOS and is_macosx_sdk_path(p): |
Ned Deily | 020250f | 2016-02-25 00:56:38 +1100 | [diff] [blame] | 245 | # Note that, as of Xcode 7, Apple SDKs may contain textual stub |
| 246 | # libraries with .tbd extensions rather than the normal .dylib |
| 247 | # shared libraries installed in /. The Apple compiler tool |
| 248 | # chain handles this transparently but it can cause problems |
| 249 | # for programs that are being built with an SDK and searching |
| 250 | # for specific libraries. Distutils find_library_file() now |
| 251 | # knows to also search for and return .tbd files. But callers |
| 252 | # of find_library_file need to keep in mind that the base filename |
| 253 | # of the returned SDK library file might have a different extension |
| 254 | # from that of the library file installed on the running system, |
| 255 | # for example: |
| 256 | # /Applications/Xcode.app/Contents/Developer/Platforms/ |
| 257 | # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ |
| 258 | # usr/lib/libedit.tbd |
| 259 | # vs |
| 260 | # /usr/lib/libedit.dylib |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 261 | if os.path.join(sysroot, p[1:]) == dirname: |
| 262 | return [ ] |
| 263 | |
Andrew M. Kuchling | a246d9f | 2002-11-27 13:43:46 +0000 | [diff] [blame] | 264 | if p == dirname: |
| 265 | return [ ] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 266 | |
Andrew M. Kuchling | a246d9f | 2002-11-27 13:43:46 +0000 | [diff] [blame] | 267 | # Otherwise, it must have been in one of the additional directories, |
| 268 | # so we have to figure out which one. |
| 269 | for p in paths: |
| 270 | # Ensure path doesn't end with path separator |
Skip Montanaro | 9f5178a | 2003-05-06 20:59:57 +0000 | [diff] [blame] | 271 | p = p.rstrip(os.sep) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 272 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 273 | if MACOS and is_macosx_sdk_path(p): |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 274 | if os.path.join(sysroot, p[1:]) == dirname: |
| 275 | return [ p ] |
| 276 | |
Andrew M. Kuchling | a246d9f | 2002-11-27 13:43:46 +0000 | [diff] [blame] | 277 | if p == dirname: |
| 278 | return [p] |
| 279 | else: |
| 280 | assert False, "Internal error: Path not found in std_dirs or paths" |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 281 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 282 | |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 283 | def find_module_file(module, dirlist): |
| 284 | """Find a module in a set of possible folders. If it is not found |
| 285 | return the unadorned filename""" |
| 286 | list = find_file(module, [], dirlist) |
| 287 | if not list: |
| 288 | return module |
| 289 | if len(list) > 1: |
Vinay Sajip | dd917f8 | 2016-08-31 08:22:29 +0100 | [diff] [blame] | 290 | log.info("WARNING: multiple copies of %s found", module) |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 291 | return os.path.join(list[0], module) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 292 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 293 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 294 | class PyBuildExt(build_ext): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 295 | |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 296 | def __init__(self, dist): |
| 297 | build_ext.__init__(self, dist) |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 298 | self.srcdir = None |
| 299 | self.lib_dirs = None |
| 300 | self.inc_dirs = None |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 301 | self.config_h_vars = None |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 302 | self.failed = [] |
Benjamin Peterson | 5c2ac8c | 2014-04-30 11:06:16 -0400 | [diff] [blame] | 303 | self.failed_on_import = [] |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 304 | self.missing = [] |
Antoine Pitrou | 2c0a916 | 2014-09-26 23:31:59 +0200 | [diff] [blame] | 305 | if '-j' in os.environ.get('MAKEFLAGS', ''): |
| 306 | self.parallel = True |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 307 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 308 | def add(self, ext): |
| 309 | self.extensions.append(ext) |
| 310 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 311 | def build_extensions(self): |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 312 | self.srcdir = sysconfig.get_config_var('srcdir') |
| 313 | if not self.srcdir: |
| 314 | # Maybe running on Windows but not using CYGWIN? |
| 315 | raise ValueError("No source directory; cannot proceed.") |
| 316 | self.srcdir = os.path.abspath(self.srcdir) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 317 | |
| 318 | # Detect which modules should be compiled |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 319 | self.detect_modules() |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 320 | |
| 321 | # Remove modules that are present on the disabled list |
Christian Heimes | 679db4a | 2008-01-18 09:56:22 +0000 | [diff] [blame] | 322 | extensions = [ext for ext in self.extensions |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 323 | if ext.name not in DISABLED_MODULE_LIST] |
Christian Heimes | 679db4a | 2008-01-18 09:56:22 +0000 | [diff] [blame] | 324 | # move ctypes to the end, it depends on other modules |
| 325 | ext_map = dict((ext.name, i) for i, ext in enumerate(extensions)) |
| 326 | if "_ctypes" in ext_map: |
| 327 | ctypes = extensions.pop(ext_map["_ctypes"]) |
| 328 | extensions.append(ctypes) |
| 329 | self.extensions = extensions |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 330 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 331 | # Fix up the autodetected modules, prefixing all the source files |
Neil Schemenauer | 014bf28 | 2009-02-05 16:35:45 +0000 | [diff] [blame] | 332 | # with Modules/. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 333 | moddirlist = [os.path.join(self.srcdir, 'Modules')] |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 334 | |
Andrew M. Kuchling | 3da989c | 2001-02-28 22:49:26 +0000 | [diff] [blame] | 335 | # Fix up the paths for scripts, too |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 336 | self.distribution.scripts = [os.path.join(self.srcdir, filename) |
Andrew M. Kuchling | 3da989c | 2001-02-28 22:49:26 +0000 | [diff] [blame] | 337 | for filename in self.distribution.scripts] |
| 338 | |
Christian Heimes | af98da1 | 2008-01-27 15:18:18 +0000 | [diff] [blame] | 339 | # Python header files |
Neil Schemenauer | 014bf28 | 2009-02-05 16:35:45 +0000 | [diff] [blame] | 340 | headers = [sysconfig.get_config_h_filename()] |
Stefan Krah | eb977da | 2012-02-29 14:10:53 +0100 | [diff] [blame] | 341 | headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) |
Christian Heimes | af98da1 | 2008-01-27 15:18:18 +0000 | [diff] [blame] | 342 | |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 343 | # The sysconfig variables built by makesetup that list the already |
| 344 | # built modules and the disabled modules as configured by the Setup |
| 345 | # files. |
| 346 | sysconf_built = sysconfig.get_config_var('MODBUILT_NAMES').split() |
| 347 | sysconf_dis = sysconfig.get_config_var('MODDISABLED_NAMES').split() |
Xavier de Gaye | 84968b7 | 2016-10-29 16:57:20 +0200 | [diff] [blame] | 348 | |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 349 | mods_built = [] |
| 350 | mods_disabled = [] |
Xavier de Gaye | 84968b7 | 2016-10-29 16:57:20 +0200 | [diff] [blame] | 351 | for ext in self.extensions: |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 352 | ext.sources = [ find_module_file(filename, moddirlist) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 353 | for filename in ext.sources ] |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 354 | if ext.depends is not None: |
Neil Schemenauer | 014bf28 | 2009-02-05 16:35:45 +0000 | [diff] [blame] | 355 | ext.depends = [find_module_file(filename, moddirlist) |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 356 | for filename in ext.depends] |
Christian Heimes | af98da1 | 2008-01-27 15:18:18 +0000 | [diff] [blame] | 357 | else: |
| 358 | ext.depends = [] |
| 359 | # re-compile extensions if a header file has been changed |
| 360 | ext.depends.extend(headers) |
| 361 | |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 362 | # If a module has already been built or has been disabled in the |
| 363 | # Setup files, don't build it here. |
| 364 | if ext.name in sysconf_built: |
| 365 | mods_built.append(ext) |
| 366 | if ext.name in sysconf_dis: |
| 367 | mods_disabled.append(ext) |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 368 | |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 369 | mods_configured = mods_built + mods_disabled |
| 370 | if mods_configured: |
Xavier de Gaye | 84968b7 | 2016-10-29 16:57:20 +0200 | [diff] [blame] | 371 | self.extensions = [x for x in self.extensions if x not in |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 372 | mods_configured] |
| 373 | # Remove the shared libraries built by a previous build. |
| 374 | for ext in mods_configured: |
| 375 | fullpath = self.get_ext_fullpath(ext.name) |
| 376 | if os.path.exists(fullpath): |
| 377 | os.unlink(fullpath) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 378 | |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 379 | # When you run "make CC=altcc" or something similar, you really want |
| 380 | # those environment variables passed into the setup.py phase. Here's |
| 381 | # a small set of useful ones. |
| 382 | compiler = os.environ.get('CC') |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 383 | args = {} |
| 384 | # unfortunately, distutils doesn't let us provide separate C and C++ |
| 385 | # compilers |
| 386 | if compiler is not None: |
Martin v. Löwis | d7c795e | 2005-04-25 07:14:03 +0000 | [diff] [blame] | 387 | (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') |
| 388 | args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 389 | self.compiler.set_executables(**args) |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 390 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 391 | build_ext.build_extensions(self) |
| 392 | |
Antoine Pitrou | 2c0a916 | 2014-09-26 23:31:59 +0200 | [diff] [blame] | 393 | for ext in self.extensions: |
| 394 | self.check_extension_import(ext) |
| 395 | |
Berker Peksag | 1d82a9c | 2014-10-01 05:11:13 +0300 | [diff] [blame] | 396 | longest = max([len(e.name) for e in self.extensions], default=0) |
Benjamin Peterson | 5c2ac8c | 2014-04-30 11:06:16 -0400 | [diff] [blame] | 397 | if self.failed or self.failed_on_import: |
| 398 | all_failed = self.failed + self.failed_on_import |
| 399 | longest = max(longest, max([len(name) for name in all_failed])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 400 | |
| 401 | def print_three_column(lst): |
| 402 | lst.sort(key=str.lower) |
| 403 | # guarantee zip() doesn't drop anything |
| 404 | while len(lst) % 3: |
| 405 | lst.append("") |
| 406 | for e, f, g in zip(lst[::3], lst[1::3], lst[2::3]): |
| 407 | print("%-*s %-*s %-*s" % (longest, e, longest, f, |
| 408 | longest, g)) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 409 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 410 | if self.missing: |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 411 | print() |
Brett Cannon | ae95b4f | 2013-07-12 11:30:32 -0400 | [diff] [blame] | 412 | print("Python build finished successfully!") |
| 413 | print("The necessary bits to build these optional modules were not " |
| 414 | "found:") |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 415 | print_three_column(self.missing) |
Guido van Rossum | 04110fb | 2007-08-24 16:32:05 +0000 | [diff] [blame] | 416 | print("To find the necessary bits, look in setup.py in" |
| 417 | " detect_modules() for the module's name.") |
| 418 | print() |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 419 | |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 420 | if mods_built: |
| 421 | print() |
Xavier de Gaye | 84968b7 | 2016-10-29 16:57:20 +0200 | [diff] [blame] | 422 | print("The following modules found by detect_modules() in" |
| 423 | " setup.py, have been") |
| 424 | print("built by the Makefile instead, as configured by the" |
| 425 | " Setup files:") |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 426 | print_three_column([ext.name for ext in mods_built]) |
| 427 | print() |
| 428 | |
| 429 | if mods_disabled: |
| 430 | print() |
| 431 | print("The following modules found by detect_modules() in" |
| 432 | " setup.py have not") |
| 433 | print("been built, they are *disabled* in the Setup files:") |
| 434 | print_three_column([ext.name for ext in mods_disabled]) |
| 435 | print() |
Xavier de Gaye | 84968b7 | 2016-10-29 16:57:20 +0200 | [diff] [blame] | 436 | |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 437 | if self.failed: |
| 438 | failed = self.failed[:] |
| 439 | print() |
| 440 | print("Failed to build these modules:") |
| 441 | print_three_column(failed) |
Guido van Rossum | 04110fb | 2007-08-24 16:32:05 +0000 | [diff] [blame] | 442 | print() |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 443 | |
Benjamin Peterson | 5c2ac8c | 2014-04-30 11:06:16 -0400 | [diff] [blame] | 444 | if self.failed_on_import: |
| 445 | failed = self.failed_on_import[:] |
| 446 | print() |
| 447 | print("Following modules built successfully" |
| 448 | " but were removed because they could not be imported:") |
| 449 | print_three_column(failed) |
| 450 | print() |
| 451 | |
Christian Heimes | 61d478c | 2018-01-27 15:51:38 +0100 | [diff] [blame] | 452 | if any('_ssl' in l |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 453 | for l in (self.missing, self.failed, self.failed_on_import)): |
Christian Heimes | 61d478c | 2018-01-27 15:51:38 +0100 | [diff] [blame] | 454 | print() |
| 455 | print("Could not build the ssl module!") |
| 456 | print("Python requires an OpenSSL 1.0.2 or 1.1 compatible " |
| 457 | "libssl with X509_VERIFY_PARAM_set1_host().") |
| 458 | print("LibreSSL 2.6.4 and earlier do not provide the necessary " |
| 459 | "APIs, https://github.com/libressl-portable/portable/issues/381") |
| 460 | print() |
| 461 | |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 462 | def build_extension(self, ext): |
| 463 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 464 | if ext.name == '_ctypes': |
| 465 | if not self.configure_ctypes(ext): |
Zachary Ware | f40d4dd | 2016-09-17 01:25:24 -0500 | [diff] [blame] | 466 | self.failed.append(ext.name) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 467 | return |
| 468 | |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 469 | try: |
| 470 | build_ext.build_extension(self, ext) |
Guido van Rossum | b940e11 | 2007-01-10 16:19:56 +0000 | [diff] [blame] | 471 | except (CCompilerError, DistutilsError) as why: |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 472 | self.announce('WARNING: building of extension "%s" failed: %s' % |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 473 | (ext.name, why)) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 474 | self.failed.append(ext.name) |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 475 | return |
Antoine Pitrou | 2c0a916 | 2014-09-26 23:31:59 +0200 | [diff] [blame] | 476 | |
| 477 | def check_extension_import(self, ext): |
| 478 | # Don't try to import an extension that has failed to compile |
| 479 | if ext.name in self.failed: |
| 480 | self.announce( |
| 481 | 'WARNING: skipping import check for failed build "%s"' % |
| 482 | ext.name, level=1) |
| 483 | return |
| 484 | |
Jack Jansen | f49c6f9 | 2001-11-01 14:44:15 +0000 | [diff] [blame] | 485 | # Workaround for Mac OS X: The Carbon-based modules cannot be |
| 486 | # reliably imported into a command-line Python |
| 487 | if 'Carbon' in ext.extra_link_args: |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 488 | self.announce( |
| 489 | 'WARNING: skipping import check for Carbon-based "%s"' % |
| 490 | ext.name) |
| 491 | return |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 492 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 493 | if MACOS and ( |
Benjamin Peterson | fc57635 | 2008-07-16 02:39:02 +0000 | [diff] [blame] | 494 | sys.maxsize > 2**32 and '-arch' in ext.extra_link_args): |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 495 | # Don't bother doing an import check when an extension was |
| 496 | # build with an explicit '-arch' flag on OSX. That's currently |
| 497 | # only used to build 32-bit only extensions in a 4-way |
| 498 | # universal build and loading 32-bit code into a 64-bit |
| 499 | # process will fail. |
| 500 | self.announce( |
| 501 | 'WARNING: skipping import check for "%s"' % |
| 502 | ext.name) |
| 503 | return |
| 504 | |
Jason Tishler | 24cf776 | 2002-05-22 16:46:15 +0000 | [diff] [blame] | 505 | # Workaround for Cygwin: Cygwin currently has fork issues when many |
| 506 | # modules have been imported |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 507 | if CYGWIN: |
Jason Tishler | 24cf776 | 2002-05-22 16:46:15 +0000 | [diff] [blame] | 508 | self.announce('WARNING: skipping import check for Cygwin-based "%s"' |
| 509 | % ext.name) |
| 510 | return |
Michael W. Hudson | af14289 | 2002-01-23 15:07:46 +0000 | [diff] [blame] | 511 | ext_filename = os.path.join( |
| 512 | self.build_lib, |
| 513 | self.get_ext_filename(self.get_ext_fullname(ext.name))) |
Guido van Rossum | c3fee69 | 2008-07-17 16:23:53 +0000 | [diff] [blame] | 514 | |
| 515 | # If the build directory didn't exist when setup.py was |
| 516 | # started, sys.path_importer_cache has a negative result |
| 517 | # cached. Clear that cache before trying to import. |
| 518 | sys.path_importer_cache.clear() |
| 519 | |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 520 | # Don't try to load extensions for cross builds |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 521 | if CROSS_COMPILING: |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 522 | return |
| 523 | |
Brett Cannon | ca5ff3a | 2013-06-15 17:52:59 -0400 | [diff] [blame] | 524 | loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename) |
Eric Snow | 335e14d | 2014-01-04 15:09:28 -0700 | [diff] [blame] | 525 | spec = importlib.util.spec_from_file_location(ext.name, ext_filename, |
| 526 | loader=loader) |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 527 | try: |
Brett Cannon | 2a17bde | 2014-05-30 14:55:29 -0400 | [diff] [blame] | 528 | importlib._bootstrap._load(spec) |
Guido van Rossum | b940e11 | 2007-01-10 16:19:56 +0000 | [diff] [blame] | 529 | except ImportError as why: |
Benjamin Peterson | 5c2ac8c | 2014-04-30 11:06:16 -0400 | [diff] [blame] | 530 | self.failed_on_import.append(ext.name) |
Neal Norwitz | 6e2d1c7 | 2003-02-28 17:39:42 +0000 | [diff] [blame] | 531 | self.announce('*** WARNING: renaming "%s" since importing it' |
| 532 | ' failed: %s' % (ext.name, why), level=3) |
| 533 | assert not self.inplace |
| 534 | basename, tail = os.path.splitext(ext_filename) |
| 535 | newname = basename + "_failed" + tail |
| 536 | if os.path.exists(newname): |
| 537 | os.remove(newname) |
| 538 | os.rename(ext_filename, newname) |
| 539 | |
Neal Norwitz | 3f5fcc8 | 2003-02-28 17:21:39 +0000 | [diff] [blame] | 540 | except: |
Neal Norwitz | 3f5fcc8 | 2003-02-28 17:21:39 +0000 | [diff] [blame] | 541 | exc_type, why, tb = sys.exc_info() |
Neal Norwitz | 6e2d1c7 | 2003-02-28 17:39:42 +0000 | [diff] [blame] | 542 | self.announce('*** WARNING: importing extension "%s" ' |
| 543 | 'failed with %s: %s' % (ext.name, exc_type, why), |
| 544 | level=3) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 545 | self.failed.append(ext.name) |
Fred Drake | 9028d0a | 2001-12-06 22:59:54 +0000 | [diff] [blame] | 546 | |
Barry Warsaw | 5ca305a | 2011-04-06 15:18:12 -0400 | [diff] [blame] | 547 | def add_multiarch_paths(self): |
| 548 | # Debian/Ubuntu multiarch support. |
| 549 | # https://wiki.ubuntu.com/MultiarchSpec |
doko@ubuntu.com | 3277b35 | 2012-08-08 12:15:55 +0200 | [diff] [blame] | 550 | cc = sysconfig.get_config_var('CC') |
| 551 | tmpfile = os.path.join(self.build_temp, 'multiarch') |
| 552 | if not os.path.exists(self.build_temp): |
| 553 | os.makedirs(self.build_temp) |
| 554 | ret = os.system( |
| 555 | '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile)) |
| 556 | multiarch_path_component = '' |
| 557 | try: |
| 558 | if ret >> 8 == 0: |
| 559 | with open(tmpfile) as fp: |
| 560 | multiarch_path_component = fp.readline().strip() |
| 561 | finally: |
| 562 | os.unlink(tmpfile) |
| 563 | |
| 564 | if multiarch_path_component != '': |
| 565 | add_dir_to_list(self.compiler.library_dirs, |
| 566 | '/usr/lib/' + multiarch_path_component) |
| 567 | add_dir_to_list(self.compiler.include_dirs, |
| 568 | '/usr/include/' + multiarch_path_component) |
| 569 | return |
| 570 | |
Barry Warsaw | 88e1945 | 2011-04-07 10:40:36 -0400 | [diff] [blame] | 571 | if not find_executable('dpkg-architecture'): |
| 572 | return |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 573 | opt = '' |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 574 | if CROSS_COMPILING: |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 575 | opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') |
Barry Warsaw | 5ca305a | 2011-04-06 15:18:12 -0400 | [diff] [blame] | 576 | tmpfile = os.path.join(self.build_temp, 'multiarch') |
| 577 | if not os.path.exists(self.build_temp): |
| 578 | os.makedirs(self.build_temp) |
| 579 | ret = os.system( |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 580 | 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % |
| 581 | (opt, tmpfile)) |
Barry Warsaw | 5ca305a | 2011-04-06 15:18:12 -0400 | [diff] [blame] | 582 | try: |
| 583 | if ret >> 8 == 0: |
| 584 | with open(tmpfile) as fp: |
| 585 | multiarch_path_component = fp.readline().strip() |
| 586 | add_dir_to_list(self.compiler.library_dirs, |
| 587 | '/usr/lib/' + multiarch_path_component) |
| 588 | add_dir_to_list(self.compiler.include_dirs, |
| 589 | '/usr/include/' + multiarch_path_component) |
| 590 | finally: |
| 591 | os.unlink(tmpfile) |
| 592 | |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 593 | def add_cross_compiling_paths(self): |
| 594 | cc = sysconfig.get_config_var('CC') |
| 595 | tmpfile = os.path.join(self.build_temp, 'ccpaths') |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 596 | if not os.path.exists(self.build_temp): |
| 597 | os.makedirs(self.build_temp) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 598 | ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile)) |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 599 | is_gcc = False |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 600 | is_clang = False |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 601 | in_incdirs = False |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 602 | try: |
| 603 | if ret >> 8 == 0: |
| 604 | with open(tmpfile) as fp: |
| 605 | for line in fp.readlines(): |
| 606 | if line.startswith("gcc version"): |
| 607 | is_gcc = True |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 608 | elif line.startswith("clang version"): |
| 609 | is_clang = True |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 610 | elif line.startswith("#include <...>"): |
| 611 | in_incdirs = True |
| 612 | elif line.startswith("End of search list"): |
| 613 | in_incdirs = False |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 614 | elif (is_gcc or is_clang) and line.startswith("LIBRARY_PATH"): |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 615 | for d in line.strip().split("=")[1].split(":"): |
| 616 | d = os.path.normpath(d) |
| 617 | if '/gcc/' not in d: |
| 618 | add_dir_to_list(self.compiler.library_dirs, |
| 619 | d) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 620 | elif (is_gcc or is_clang) and in_incdirs and '/gcc/' not in line and '/clang/' not in line: |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 621 | add_dir_to_list(self.compiler.include_dirs, |
| 622 | line.strip()) |
| 623 | finally: |
| 624 | os.unlink(tmpfile) |
| 625 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 626 | def add_ldflags_cppflags(self): |
Brett Cannon | 516592f | 2004-12-07 00:42:59 +0000 | [diff] [blame] | 627 | # Add paths specified in the environment variables LDFLAGS and |
Brett Cannon | 4810eb9 | 2004-12-31 08:11:21 +0000 | [diff] [blame] | 628 | # CPPFLAGS for header and library files. |
Brett Cannon | 5399c6d | 2004-12-18 20:48:09 +0000 | [diff] [blame] | 629 | # We must get the values from the Makefile and not the environment |
| 630 | # directly since an inconsistently reproducible issue comes up where |
| 631 | # the environment variable is not set even though the value were passed |
Brett Cannon | 4810eb9 | 2004-12-31 08:11:21 +0000 | [diff] [blame] | 632 | # into configure and stored in the Makefile (issue found on OS X 10.3). |
Brett Cannon | 516592f | 2004-12-07 00:42:59 +0000 | [diff] [blame] | 633 | for env_var, arg_name, dir_list in ( |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 634 | ('LDFLAGS', '-R', self.compiler.runtime_library_dirs), |
| 635 | ('LDFLAGS', '-L', self.compiler.library_dirs), |
| 636 | ('CPPFLAGS', '-I', self.compiler.include_dirs)): |
Brett Cannon | 5399c6d | 2004-12-18 20:48:09 +0000 | [diff] [blame] | 637 | env_val = sysconfig.get_config_var(env_var) |
Brett Cannon | 516592f | 2004-12-07 00:42:59 +0000 | [diff] [blame] | 638 | if env_val: |
Chih-Hsuan Yen | 09b2bec | 2018-07-11 16:48:43 +0800 | [diff] [blame] | 639 | parser = argparse.ArgumentParser() |
| 640 | parser.add_argument(arg_name, dest="dirs", action="append") |
| 641 | options, _ = parser.parse_known_args(env_val.split()) |
Brett Cannon | 4483771 | 2005-01-02 21:54:07 +0000 | [diff] [blame] | 642 | if options.dirs: |
Christian Heimes | 292d351 | 2008-02-03 16:51:08 +0000 | [diff] [blame] | 643 | for directory in reversed(options.dirs): |
Brett Cannon | 4483771 | 2005-01-02 21:54:07 +0000 | [diff] [blame] | 644 | add_dir_to_list(dir_list, directory) |
Skip Montanaro | decc6a4 | 2003-01-01 20:07:49 +0000 | [diff] [blame] | 645 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 646 | def configure_compiler(self): |
| 647 | # Ensure that /usr/local is always used, but the local build |
| 648 | # directories (i.e. '.' and 'Include') must be first. See issue |
| 649 | # 10520. |
| 650 | if not CROSS_COMPILING: |
| 651 | add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
| 652 | add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| 653 | # only change this for cross builds for 3.3, issues on Mageia |
| 654 | if CROSS_COMPILING: |
| 655 | self.add_cross_compiling_paths() |
| 656 | self.add_multiarch_paths() |
| 657 | self.add_ldflags_cppflags() |
| 658 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 659 | def init_inc_lib_dirs(self): |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 660 | if (not CROSS_COMPILING and |
Xavier de Gaye | 1351c31 | 2016-12-14 11:14:33 +0100 | [diff] [blame] | 661 | os.path.normpath(sys.base_prefix) != '/usr' and |
| 662 | not sysconfig.get_config_var('PYTHONFRAMEWORK')): |
Ronald Oussoren | f3500e1 | 2010-10-20 13:10:12 +0000 | [diff] [blame] | 663 | # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework |
| 664 | # (PYTHONFRAMEWORK is set) to avoid # linking problems when |
| 665 | # building a framework with different architectures than |
| 666 | # the one that is currently installed (issue #7473) |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 667 | add_dir_to_list(self.compiler.library_dirs, |
Michael W. Hudson | 90b8e4d | 2002-08-02 13:55:50 +0000 | [diff] [blame] | 668 | sysconfig.get_config_var("LIBDIR")) |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 669 | add_dir_to_list(self.compiler.include_dirs, |
Michael W. Hudson | 90b8e4d | 2002-08-02 13:55:50 +0000 | [diff] [blame] | 670 | sysconfig.get_config_var("INCLUDEDIR")) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 671 | |
xdegaye | 77f5139 | 2017-11-25 17:25:30 +0100 | [diff] [blame] | 672 | system_lib_dirs = ['/lib64', '/usr/lib64', '/lib', '/usr/lib'] |
| 673 | system_include_dirs = ['/usr/include'] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 674 | # lib_dirs and inc_dirs are used to search for files; |
| 675 | # if a file is found in one of those directories, it can |
| 676 | # be assumed that no additional -I,-L directives are needed. |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 677 | if not CROSS_COMPILING: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 678 | self.lib_dirs = self.compiler.library_dirs + system_lib_dirs |
| 679 | self.inc_dirs = self.compiler.include_dirs + system_include_dirs |
Christian Heimes | f19529c | 2012-12-12 12:41:00 +0100 | [diff] [blame] | 680 | else: |
xdegaye | 77f5139 | 2017-11-25 17:25:30 +0100 | [diff] [blame] | 681 | # Add the sysroot paths. 'sysroot' is a compiler option used to |
| 682 | # set the logical path of the standard system headers and |
| 683 | # libraries. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 684 | self.lib_dirs = (self.compiler.library_dirs + |
| 685 | sysroot_paths(('LDFLAGS', 'CC'), system_lib_dirs)) |
| 686 | self.inc_dirs = (self.compiler.include_dirs + |
| 687 | sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'), |
| 688 | system_include_dirs)) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 689 | |
Brett Cannon | 4454a1f | 2005-04-15 20:32:39 +0000 | [diff] [blame] | 690 | config_h = sysconfig.get_config_h_filename() |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 691 | with open(config_h) as file: |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 692 | self.config_h_vars = sysconfig.parse_config_h(file) |
Brett Cannon | 4454a1f | 2005-04-15 20:32:39 +0000 | [diff] [blame] | 693 | |
Andrew M. Kuchling | 7883dc8 | 2003-10-24 18:26:26 +0000 | [diff] [blame] | 694 | # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 695 | if HOST_PLATFORM in ['osf1', 'unixware7', 'openunix8']: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 696 | self.lib_dirs += ['/usr/ccs/lib'] |
Skip Montanaro | 22e00c4 | 2003-05-06 20:43:34 +0000 | [diff] [blame] | 697 | |
Charles-François Natali | 5739e10 | 2012-04-12 19:07:25 +0200 | [diff] [blame] | 698 | # HP-UX11iv3 keeps files in lib/hpux folders. |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 699 | if HOST_PLATFORM == 'hp-ux11': |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 700 | self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] |
Charles-François Natali | 5739e10 | 2012-04-12 19:07:25 +0200 | [diff] [blame] | 701 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 702 | if MACOS: |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 703 | # This should work on any unixy platform ;-) |
| 704 | # If the user has bothered specifying additional -I and -L flags |
| 705 | # in OPT and LDFLAGS we might as well use them here. |
Barry Warsaw | 807bd0a | 2010-11-24 20:30:00 +0000 | [diff] [blame] | 706 | # |
| 707 | # NOTE: using shlex.split would technically be more correct, but |
| 708 | # also gives a bootstrap problem. Let's hope nobody uses |
| 709 | # directories with whitespace in the name to store libraries. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 710 | cflags, ldflags = sysconfig.get_config_vars( |
| 711 | 'CFLAGS', 'LDFLAGS') |
| 712 | for item in cflags.split(): |
| 713 | if item.startswith('-I'): |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 714 | self.inc_dirs.append(item[2:]) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 715 | |
| 716 | for item in ldflags.split(): |
| 717 | if item.startswith('-L'): |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 718 | self.lib_dirs.append(item[2:]) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 719 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 720 | def detect_simple_extensions(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 721 | # |
| 722 | # The following modules are all pretty straightforward, and compile |
| 723 | # on pretty much any POSIXish platform. |
| 724 | # |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 725 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 726 | # array objects |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 727 | self.add(Extension('array', ['arraymodule.c'])) |
Martin Panter | c9deece | 2016-02-03 05:19:44 +0000 | [diff] [blame] | 728 | |
Yury Selivanov | f23746a | 2018-01-22 19:11:18 -0500 | [diff] [blame] | 729 | # Context Variables |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 730 | self.add(Extension('_contextvars', ['_contextvarsmodule.c'])) |
Yury Selivanov | f23746a | 2018-01-22 19:11:18 -0500 | [diff] [blame] | 731 | |
Martin Panter | c9deece | 2016-02-03 05:19:44 +0000 | [diff] [blame] | 732 | shared_math = 'Modules/_math.o' |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 733 | |
| 734 | # math library functions, e.g. sin() |
| 735 | self.add(Extension('math', ['mathmodule.c'], |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 736 | extra_objects=[shared_math], |
| 737 | depends=['_math.h', shared_math], |
| 738 | libraries=['m'])) |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 739 | |
| 740 | # complex math library functions |
| 741 | self.add(Extension('cmath', ['cmathmodule.c'], |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 742 | extra_objects=[shared_math], |
| 743 | depends=['_math.h', shared_math], |
| 744 | libraries=['m'])) |
Victor Stinner | e0be423 | 2011-10-25 13:06:09 +0200 | [diff] [blame] | 745 | |
| 746 | # time libraries: librt may be needed for clock_gettime() |
| 747 | time_libs = [] |
| 748 | lib = sysconfig.get_config_var('TIMEMODULE_LIB') |
| 749 | if lib: |
| 750 | time_libs.append(lib) |
| 751 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 752 | # time operations and variables |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 753 | self.add(Extension('time', ['timemodule.c'], |
| 754 | libraries=time_libs)) |
Benjamin Peterson | 8acaa31 | 2017-11-12 20:53:39 -0800 | [diff] [blame] | 755 | # libm is needed by delta_new() that uses round() and by accum() that |
| 756 | # uses modf(). |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 757 | self.add(Extension('_datetime', ['_datetimemodule.c'], |
| 758 | libraries=['m'])) |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 759 | # random number generator implemented in C |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 760 | self.add(Extension("_random", ["_randommodule.c"])) |
Raymond Hettinger | 0c41027 | 2004-01-05 10:13:35 +0000 | [diff] [blame] | 761 | # bisect |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 762 | self.add(Extension("_bisect", ["_bisectmodule.c"])) |
Raymond Hettinger | b3af181 | 2003-11-08 10:24:38 +0000 | [diff] [blame] | 763 | # heapq |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 764 | self.add(Extension("_heapq", ["_heapqmodule.c"])) |
Alexandre Vassalotti | ca2d610 | 2008-06-12 18:26:05 +0000 | [diff] [blame] | 765 | # C-optimized pickle replacement |
Victor Stinner | 5c75f37 | 2019-04-17 23:02:26 +0200 | [diff] [blame] | 766 | self.add(Extension("_pickle", ["_pickle.c"], |
Victor Stinner | 5749134 | 2019-04-23 12:26:33 +0200 | [diff] [blame] | 767 | extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) |
Collin Winter | 670e692 | 2007-03-21 02:57:17 +0000 | [diff] [blame] | 768 | # atexit |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 769 | self.add(Extension("atexit", ["atexitmodule.c"])) |
Christian Heimes | 9054000 | 2008-05-08 14:29:10 +0000 | [diff] [blame] | 770 | # _json speedups |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 771 | self.add(Extension("_json", ["_json.c"], |
Victor Stinner | 5749134 | 2019-04-23 12:26:33 +0200 | [diff] [blame] | 772 | extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 773 | |
Fred Drake | 0e474a8 | 2007-10-11 18:01:43 +0000 | [diff] [blame] | 774 | # profiler (_lsprof is for cProfile.py) |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 775 | self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 776 | # static Unicode character database |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 777 | self.add(Extension('unicodedata', ['unicodedata.c'], |
| 778 | depends=['unicodedata_db.h', 'unicodename_db.h'])) |
Larry Hastings | 3a90797 | 2013-11-23 14:49:22 -0800 | [diff] [blame] | 779 | # _opcode module |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 780 | self.add(Extension('_opcode', ['_opcode.c'])) |
INADA Naoki | 9f2ce25 | 2016-10-15 15:39:19 +0900 | [diff] [blame] | 781 | # asyncio speedups |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 782 | self.add(Extension("_asyncio", ["_asynciomodule.c"])) |
Ivan Levkivskyi | 03e3c34 | 2018-02-18 12:41:58 +0000 | [diff] [blame] | 783 | # _abc speedups |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 784 | self.add(Extension("_abc", ["_abc.c"])) |
Antoine Pitrou | 94e1696 | 2018-01-16 00:27:16 +0100 | [diff] [blame] | 785 | # _queue module |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 786 | self.add(Extension("_queue", ["_queuemodule.c"])) |
Miss Islington (bot) | 5779c53 | 2019-08-23 15:39:27 -0700 | [diff] [blame] | 787 | # _statistics module |
| 788 | self.add(Extension("_statistics", ["_statisticsmodule.c"])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 789 | |
| 790 | # Modules with some UNIX dependencies -- on by default: |
| 791 | # (If you have a really backward UNIX, select and socket may not be |
| 792 | # supported...) |
| 793 | |
| 794 | # fcntl(2) and ioctl(2) |
Antoine Pitrou | a300007 | 2010-09-07 14:52:42 +0000 | [diff] [blame] | 795 | libs = [] |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 796 | if (self.config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): |
Antoine Pitrou | a300007 | 2010-09-07 14:52:42 +0000 | [diff] [blame] | 797 | # May be necessary on AIX for flock function |
| 798 | libs = ['bsd'] |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 799 | self.add(Extension('fcntl', ['fcntlmodule.c'], |
| 800 | libraries=libs)) |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 801 | # pwd(3) |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 802 | self.add(Extension('pwd', ['pwdmodule.c'])) |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 803 | # grp(3) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 804 | if not VXWORKS: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 805 | self.add(Extension('grp', ['grpmodule.c'])) |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 806 | # spwd, shadow passwords |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 807 | if (self.config_h_vars.get('HAVE_GETSPNAM', False) or |
| 808 | self.config_h_vars.get('HAVE_GETSPENT', False)): |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 809 | self.add(Extension('spwd', ['spwdmodule.c'])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 810 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 811 | self.missing.append('spwd') |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 812 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 813 | # select(2); not on ancient System V |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 814 | self.add(Extension('select', ['selectmodule.c'])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 815 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 816 | # Fred Drake's interface to the Python parser |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 817 | self.add(Extension('parser', ['parsermodule.c'])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 818 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 819 | # Memory-mapped files (also works on Win32). |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 820 | self.add(Extension('mmap', ['mmapmodule.c'])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 821 | |
Andrew M. Kuchling | 57269d0 | 2004-08-31 13:37:25 +0000 | [diff] [blame] | 822 | # Lance Ellinghaus's syslog module |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 823 | # syslog daemon interface |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 824 | self.add(Extension('syslog', ['syslogmodule.c'])) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 825 | |
Eric Snow | 7f8bfc9 | 2018-01-29 18:23:44 -0700 | [diff] [blame] | 826 | # Python interface to subinterpreter C-API. |
Eric Snow | c11183c | 2019-03-15 16:35:46 -0600 | [diff] [blame] | 827 | self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) |
Eric Snow | 7f8bfc9 | 2018-01-29 18:23:44 -0700 | [diff] [blame] | 828 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 829 | # |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 830 | # Here ends the simple stuff. From here on, modules need certain |
| 831 | # libraries, are platform-specific, or present other surprises. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 832 | # |
| 833 | |
| 834 | # Multimedia modules |
| 835 | # These don't work for 64-bit platforms!!! |
| 836 | # These represent audio samples or images as strings: |
Victor Stinner | def8072 | 2016-04-19 15:58:11 +0200 | [diff] [blame] | 837 | # |
Neal Norwitz | 5e4a3b8 | 2004-07-19 16:55:07 +0000 | [diff] [blame] | 838 | # Operations on audio samples |
Tim Peters | f9cbf21 | 2004-07-23 02:50:10 +0000 | [diff] [blame] | 839 | # According to #993173, this one should actually work fine on |
Martin v. Löwis | 8fbefe2 | 2004-07-19 16:42:20 +0000 | [diff] [blame] | 840 | # 64-bit platforms. |
Victor Stinner | def8072 | 2016-04-19 15:58:11 +0200 | [diff] [blame] | 841 | # |
Benjamin Peterson | 8acaa31 | 2017-11-12 20:53:39 -0800 | [diff] [blame] | 842 | # audioop needs libm for floor() in multiple functions. |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 843 | self.add(Extension('audioop', ['audioop.c'], |
| 844 | libraries=['m'])) |
Martin v. Löwis | 8fbefe2 | 2004-07-19 16:42:20 +0000 | [diff] [blame] | 845 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 846 | # CSV files |
| 847 | self.add(Extension('_csv', ['_csv.c'])) |
| 848 | |
| 849 | # POSIX subprocess module helper. |
| 850 | self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'])) |
| 851 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 852 | def detect_test_extensions(self): |
| 853 | # Python C API test module |
| 854 | self.add(Extension('_testcapi', ['_testcapimodule.c'], |
| 855 | depends=['testcapi_long.h'])) |
| 856 | |
Victor Stinner | 23bace2 | 2019-04-18 11:37:26 +0200 | [diff] [blame] | 857 | # Python Internal C API test module |
| 858 | self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'], |
Victor Stinner | 5749134 | 2019-04-23 12:26:33 +0200 | [diff] [blame] | 859 | extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) |
Victor Stinner | 23bace2 | 2019-04-18 11:37:26 +0200 | [diff] [blame] | 860 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 861 | # Python PEP-3118 (buffer protocol) test module |
| 862 | self.add(Extension('_testbuffer', ['_testbuffer.c'])) |
| 863 | |
| 864 | # Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421) |
| 865 | self.add(Extension('_testimportmultiple', ['_testimportmultiple.c'])) |
| 866 | |
| 867 | # Test multi-phase extension module init (PEP 489) |
| 868 | self.add(Extension('_testmultiphase', ['_testmultiphase.c'])) |
| 869 | |
| 870 | # Fuzz tests. |
| 871 | self.add(Extension('_xxtestfuzz', |
| 872 | ['_xxtestfuzz/_xxtestfuzz.c', |
| 873 | '_xxtestfuzz/fuzzer.c'])) |
| 874 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 875 | def detect_readline_curses(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 876 | # readline |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 877 | do_readline = self.compiler.find_library_file(self.lib_dirs, 'readline') |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 878 | readline_termcap_library = "" |
| 879 | curses_library = "" |
doko@ubuntu.com | 5884449 | 2012-06-30 18:25:32 +0200 | [diff] [blame] | 880 | # Cannot use os.popen here in py3k. |
| 881 | tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib') |
| 882 | if not os.path.exists(self.build_temp): |
| 883 | os.makedirs(self.build_temp) |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 884 | # Determine if readline is already linked against curses or tinfo. |
doko@ubuntu.com | 5884449 | 2012-06-30 18:25:32 +0200 | [diff] [blame] | 885 | if do_readline: |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 886 | if CROSS_COMPILING: |
doko@ubuntu.com | 5884449 | 2012-06-30 18:25:32 +0200 | [diff] [blame] | 887 | ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \ |
| 888 | % (sysconfig.get_config_var('READELF'), |
| 889 | do_readline, tmpfile)) |
| 890 | elif find_executable('ldd'): |
| 891 | ret = os.system("ldd %s > %s" % (do_readline, tmpfile)) |
| 892 | else: |
| 893 | ret = 256 |
doko@ubuntu.com | 4c99071 | 2012-06-30 23:28:09 +0200 | [diff] [blame] | 894 | if ret >> 8 == 0: |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 895 | with open(tmpfile) as fp: |
| 896 | for ln in fp: |
| 897 | if 'curses' in ln: |
| 898 | readline_termcap_library = re.sub( |
| 899 | r'.*lib(n?cursesw?)\.so.*', r'\1', ln |
| 900 | ).rstrip() |
| 901 | break |
| 902 | # termcap interface split out from ncurses |
| 903 | if 'tinfo' in ln: |
| 904 | readline_termcap_library = 'tinfo' |
| 905 | break |
doko@ubuntu.com | 4c99071 | 2012-06-30 23:28:09 +0200 | [diff] [blame] | 906 | if os.path.exists(tmpfile): |
| 907 | os.unlink(tmpfile) |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 908 | # Issue 7384: If readline is already linked against curses, |
| 909 | # use the same library for the readline and curses modules. |
| 910 | if 'curses' in readline_termcap_library: |
| 911 | curses_library = readline_termcap_library |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 912 | elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'): |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 913 | curses_library = 'ncursesw' |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 914 | elif self.compiler.find_library_file(self.lib_dirs, 'ncurses'): |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 915 | curses_library = 'ncurses' |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 916 | elif self.compiler.find_library_file(self.lib_dirs, 'curses'): |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 917 | curses_library = 'curses' |
| 918 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 919 | if MACOS: |
Ronald Oussoren | 2efd924 | 2009-09-20 14:53:22 +0000 | [diff] [blame] | 920 | os_release = int(os.uname()[2].split('.')[0]) |
Ronald Oussoren | 961683a | 2010-03-08 07:09:59 +0000 | [diff] [blame] | 921 | dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') |
Ned Deily | 04cdfa1 | 2014-06-25 13:36:14 -0700 | [diff] [blame] | 922 | if (dep_target and |
| 923 | (tuple(int(n) for n in dep_target.split('.')[0:2]) |
| 924 | < (10, 5) ) ): |
Ronald Oussoren | 961683a | 2010-03-08 07:09:59 +0000 | [diff] [blame] | 925 | os_release = 8 |
Ronald Oussoren | 2efd924 | 2009-09-20 14:53:22 +0000 | [diff] [blame] | 926 | if os_release < 9: |
| 927 | # MacOSX 10.4 has a broken readline. Don't try to build |
| 928 | # the readline module unless the user has installed a fixed |
| 929 | # readline package |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 930 | if find_file('readline/rlconf.h', self.inc_dirs, []) is None: |
Ronald Oussoren | 2efd924 | 2009-09-20 14:53:22 +0000 | [diff] [blame] | 931 | do_readline = False |
Jack Jansen | 81ae235 | 2006-02-23 15:02:23 +0000 | [diff] [blame] | 932 | if do_readline: |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 933 | if MACOS and os_release < 9: |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 934 | # In every directory on the search path search for a dynamic |
| 935 | # library and then a static library, instead of first looking |
Fred Drake | 0af1761 | 2007-09-04 19:43:19 +0000 | [diff] [blame] | 936 | # for dynamic libraries on the entire path. |
Martin Panter | e26da7c | 2016-06-02 10:07:09 +0000 | [diff] [blame] | 937 | # This way a statically linked custom readline gets picked up |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 938 | # before the (possibly broken) dynamic library in /usr/lib. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 939 | readline_extra_link_args = ('-Wl,-search_paths_first',) |
| 940 | else: |
| 941 | readline_extra_link_args = () |
| 942 | |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 943 | readline_libs = ['readline'] |
Stefan Krah | 095b273 | 2010-06-08 13:41:44 +0000 | [diff] [blame] | 944 | if readline_termcap_library: |
| 945 | pass # Issue 7384: Already linked against curses or tinfo. |
| 946 | elif curses_library: |
| 947 | readline_libs.append(curses_library) |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 948 | elif self.compiler.find_library_file(self.lib_dirs + |
Tarek Ziadé | dd07ebb | 2009-07-06 13:52:17 +0000 | [diff] [blame] | 949 | ['/usr/lib/termcap'], |
| 950 | 'termcap'): |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 951 | readline_libs.append('termcap') |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 952 | self.add(Extension('readline', ['readline.c'], |
| 953 | library_dirs=['/usr/lib/termcap'], |
| 954 | extra_link_args=readline_extra_link_args, |
| 955 | libraries=readline_libs)) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 956 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 957 | self.missing.append('readline') |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 958 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 959 | # Curses support, requiring the System V version of curses, often |
| 960 | # provided by the ncurses library. |
| 961 | curses_defines = [] |
| 962 | curses_includes = [] |
| 963 | panel_library = 'panel' |
| 964 | if curses_library == 'ncursesw': |
| 965 | curses_defines.append(('HAVE_NCURSESW', '1')) |
| 966 | if not CROSS_COMPILING: |
| 967 | curses_includes.append('/usr/include/ncursesw') |
| 968 | # Bug 1464056: If _curses.so links with ncursesw, |
| 969 | # _curses_panel.so must link with panelw. |
| 970 | panel_library = 'panelw' |
| 971 | if MACOS: |
| 972 | # On OS X, there is no separate /usr/lib/libncursesw nor |
| 973 | # libpanelw. If we are here, we found a locally-supplied |
| 974 | # version of libncursesw. There should also be a |
| 975 | # libpanelw. _XOPEN_SOURCE defines are usually excluded |
| 976 | # for OS X but we need _XOPEN_SOURCE_EXTENDED here for |
| 977 | # ncurses wide char support |
| 978 | curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1')) |
| 979 | elif MACOS and curses_library == 'ncurses': |
| 980 | # Building with the system-suppied combined libncurses/libpanel |
| 981 | curses_defines.append(('HAVE_NCURSESW', '1')) |
| 982 | curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1')) |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 983 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 984 | curses_enabled = True |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 985 | if curses_library.startswith('ncurses'): |
| 986 | curses_libs = [curses_library] |
| 987 | self.add(Extension('_curses', ['_cursesmodule.c'], |
| 988 | include_dirs=curses_includes, |
| 989 | define_macros=curses_defines, |
| 990 | libraries=curses_libs)) |
| 991 | elif curses_library == 'curses' and not MACOS: |
| 992 | # OSX has an old Berkeley curses, not good enough for |
| 993 | # the _curses module. |
| 994 | if (self.compiler.find_library_file(self.lib_dirs, 'terminfo')): |
| 995 | curses_libs = ['curses', 'terminfo'] |
| 996 | elif (self.compiler.find_library_file(self.lib_dirs, 'termcap')): |
| 997 | curses_libs = ['curses', 'termcap'] |
| 998 | else: |
| 999 | curses_libs = ['curses'] |
| 1000 | |
| 1001 | self.add(Extension('_curses', ['_cursesmodule.c'], |
| 1002 | define_macros=curses_defines, |
| 1003 | libraries=curses_libs)) |
| 1004 | else: |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1005 | curses_enabled = False |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1006 | self.missing.append('_curses') |
| 1007 | |
| 1008 | # If the curses module is enabled, check for the panel module |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1009 | if (curses_enabled and |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1010 | self.compiler.find_library_file(self.lib_dirs, panel_library)): |
| 1011 | self.add(Extension('_curses_panel', ['_curses_panel.c'], |
| 1012 | include_dirs=curses_includes, |
| 1013 | define_macros=curses_defines, |
| 1014 | libraries=[panel_library, *curses_libs])) |
| 1015 | else: |
| 1016 | self.missing.append('_curses_panel') |
| 1017 | |
| 1018 | def detect_crypt(self): |
| 1019 | # crypt module. |
pxinwr | 236d0b7 | 2019-04-15 17:02:20 +0800 | [diff] [blame] | 1020 | if VXWORKS: |
| 1021 | # bpo-31904: crypt() function is not provided by VxWorks. |
| 1022 | # DES_crypt() OpenSSL provides is too weak to implement |
| 1023 | # the encryption. |
| 1024 | return |
| 1025 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1026 | if self.compiler.find_library_file(self.lib_dirs, 'crypt'): |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 1027 | libs = ['crypt'] |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1028 | else: |
Ronald Oussoren | 94f2528 | 2010-05-05 19:11:21 +0000 | [diff] [blame] | 1029 | libs = [] |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1030 | |
pxinwr | 236d0b7 | 2019-04-15 17:02:20 +0800 | [diff] [blame] | 1031 | self.add(Extension('_crypt', ['_cryptmodule.c'], |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1032 | libraries=libs)) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1033 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1034 | def detect_socket(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1035 | # socket(2) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1036 | if not VXWORKS: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1037 | self.add(Extension('_socket', ['socketmodule.c'], |
| 1038 | depends=['socketmodule.h'])) |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1039 | elif self.compiler.find_library_file(self.lib_dirs, 'net'): |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1040 | libs = ['net'] |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1041 | self.add(Extension('_socket', ['socketmodule.c'], |
| 1042 | depends=['socketmodule.h'], |
| 1043 | libraries=libs)) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1044 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1045 | def detect_dbm_gdbm(self): |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1046 | # Modules that provide persistent dictionary-like semantics. You will |
| 1047 | # probably want to arrange for at least one of them to be available on |
| 1048 | # your machine, though none are defined by default because of library |
| 1049 | # dependencies. The Python module dbm/__init__.py provides an |
| 1050 | # implementation independent wrapper for these; dbm/dumb.py provides |
| 1051 | # similar functionality (but slower of course) implemented in Python. |
| 1052 | |
| 1053 | # Sleepycat^WOracle Berkeley DB interface. |
| 1054 | # http://www.oracle.com/database/berkeley-db/db/index.html |
| 1055 | # |
| 1056 | # This requires the Sleepycat^WOracle DB code. The supported versions |
| 1057 | # are set below. Visit the URL above to download |
| 1058 | # a release. Most open source OSes come with one or more |
| 1059 | # versions of BerkeleyDB already installed. |
| 1060 | |
doko@ubuntu.com | 15bac0f | 2012-07-01 10:35:54 +0200 | [diff] [blame] | 1061 | max_db_ver = (5, 3) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1062 | min_db_ver = (3, 3) |
| 1063 | db_setup_debug = False # verbose debug prints from this script? |
| 1064 | |
| 1065 | def allow_db_ver(db_ver): |
| 1066 | """Returns a boolean if the given BerkeleyDB version is acceptable. |
| 1067 | |
| 1068 | Args: |
| 1069 | db_ver: A tuple of the version to verify. |
| 1070 | """ |
| 1071 | if not (min_db_ver <= db_ver <= max_db_ver): |
| 1072 | return False |
| 1073 | return True |
| 1074 | |
| 1075 | def gen_db_minor_ver_nums(major): |
| 1076 | if major == 4: |
| 1077 | for x in range(max_db_ver[1]+1): |
| 1078 | if allow_db_ver((4, x)): |
| 1079 | yield x |
| 1080 | elif major == 3: |
| 1081 | for x in (3,): |
| 1082 | if allow_db_ver((3, x)): |
| 1083 | yield x |
| 1084 | else: |
| 1085 | raise ValueError("unknown major BerkeleyDB version", major) |
| 1086 | |
| 1087 | # construct a list of paths to look for the header file in on |
| 1088 | # top of the normal inc_dirs. |
| 1089 | db_inc_paths = [ |
| 1090 | '/usr/include/db4', |
| 1091 | '/usr/local/include/db4', |
| 1092 | '/opt/sfw/include/db4', |
| 1093 | '/usr/include/db3', |
| 1094 | '/usr/local/include/db3', |
| 1095 | '/opt/sfw/include/db3', |
| 1096 | # Fink defaults (http://fink.sourceforge.net/) |
| 1097 | '/sw/include/db4', |
| 1098 | '/sw/include/db3', |
| 1099 | ] |
| 1100 | # 4.x minor number specific paths |
| 1101 | for x in gen_db_minor_ver_nums(4): |
| 1102 | db_inc_paths.append('/usr/include/db4%d' % x) |
| 1103 | db_inc_paths.append('/usr/include/db4.%d' % x) |
| 1104 | db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x) |
| 1105 | db_inc_paths.append('/usr/local/include/db4%d' % x) |
| 1106 | db_inc_paths.append('/pkg/db-4.%d/include' % x) |
| 1107 | db_inc_paths.append('/opt/db-4.%d/include' % x) |
| 1108 | # MacPorts default (http://www.macports.org/) |
| 1109 | db_inc_paths.append('/opt/local/include/db4%d' % x) |
| 1110 | # 3.x minor number specific paths |
| 1111 | for x in gen_db_minor_ver_nums(3): |
| 1112 | db_inc_paths.append('/usr/include/db3%d' % x) |
| 1113 | db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) |
| 1114 | db_inc_paths.append('/usr/local/include/db3%d' % x) |
| 1115 | db_inc_paths.append('/pkg/db-3.%d/include' % x) |
| 1116 | db_inc_paths.append('/opt/db-3.%d/include' % x) |
| 1117 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1118 | if CROSS_COMPILING: |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 1119 | db_inc_paths = [] |
| 1120 | |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1121 | # Add some common subdirectories for Sleepycat DB to the list, |
| 1122 | # based on the standard include directories. This way DB3/4 gets |
| 1123 | # picked up when it is installed in a non-standard prefix and |
| 1124 | # the user has added that prefix into inc_dirs. |
| 1125 | std_variants = [] |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1126 | for dn in self.inc_dirs: |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1127 | std_variants.append(os.path.join(dn, 'db3')) |
| 1128 | std_variants.append(os.path.join(dn, 'db4')) |
| 1129 | for x in gen_db_minor_ver_nums(4): |
| 1130 | std_variants.append(os.path.join(dn, "db4%d"%x)) |
| 1131 | std_variants.append(os.path.join(dn, "db4.%d"%x)) |
| 1132 | for x in gen_db_minor_ver_nums(3): |
| 1133 | std_variants.append(os.path.join(dn, "db3%d"%x)) |
| 1134 | std_variants.append(os.path.join(dn, "db3.%d"%x)) |
| 1135 | |
| 1136 | db_inc_paths = std_variants + db_inc_paths |
| 1137 | db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] |
| 1138 | |
| 1139 | db_ver_inc_map = {} |
| 1140 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1141 | if MACOS: |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1142 | sysroot = macosx_sdk_root() |
| 1143 | |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1144 | class db_found(Exception): pass |
| 1145 | try: |
| 1146 | # See whether there is a Sleepycat header in the standard |
| 1147 | # search path. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1148 | for d in self.inc_dirs + db_inc_paths: |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1149 | f = os.path.join(d, "db.h") |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1150 | if MACOS and is_macosx_sdk_path(d): |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1151 | f = os.path.join(sysroot, d[1:], "db.h") |
| 1152 | |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1153 | if db_setup_debug: print("db: looking for db.h in", f) |
| 1154 | if os.path.exists(f): |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 1155 | with open(f, 'rb') as file: |
| 1156 | f = file.read() |
Benjamin Peterson | 019f361 | 2009-08-12 18:18:03 +0000 | [diff] [blame] | 1157 | m = re.search(br"#define\WDB_VERSION_MAJOR\W(\d+)", f) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1158 | if m: |
| 1159 | db_major = int(m.group(1)) |
Benjamin Peterson | 019f361 | 2009-08-12 18:18:03 +0000 | [diff] [blame] | 1160 | m = re.search(br"#define\WDB_VERSION_MINOR\W(\d+)", f) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1161 | db_minor = int(m.group(1)) |
| 1162 | db_ver = (db_major, db_minor) |
| 1163 | |
| 1164 | # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug |
| 1165 | if db_ver == (4, 6): |
Benjamin Peterson | 019f361 | 2009-08-12 18:18:03 +0000 | [diff] [blame] | 1166 | m = re.search(br"#define\WDB_VERSION_PATCH\W(\d+)", f) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1167 | db_patch = int(m.group(1)) |
| 1168 | if db_patch < 21: |
| 1169 | print("db.h:", db_ver, "patch", db_patch, |
| 1170 | "being ignored (4.6.x must be >= 4.6.21)") |
| 1171 | continue |
| 1172 | |
| 1173 | if ( (db_ver not in db_ver_inc_map) and |
| 1174 | allow_db_ver(db_ver) ): |
| 1175 | # save the include directory with the db.h version |
| 1176 | # (first occurrence only) |
| 1177 | db_ver_inc_map[db_ver] = d |
| 1178 | if db_setup_debug: |
| 1179 | print("db.h: found", db_ver, "in", d) |
| 1180 | else: |
| 1181 | # we already found a header for this library version |
| 1182 | if db_setup_debug: print("db.h: ignoring", d) |
| 1183 | else: |
| 1184 | # ignore this header, it didn't contain a version number |
| 1185 | if db_setup_debug: |
| 1186 | print("db.h: no version number version in", d) |
| 1187 | |
| 1188 | db_found_vers = list(db_ver_inc_map.keys()) |
| 1189 | db_found_vers.sort() |
| 1190 | |
| 1191 | while db_found_vers: |
| 1192 | db_ver = db_found_vers.pop() |
| 1193 | db_incdir = db_ver_inc_map[db_ver] |
| 1194 | |
| 1195 | # check lib directories parallel to the location of the header |
| 1196 | db_dirs_to_check = [ |
| 1197 | db_incdir.replace("include", 'lib64'), |
| 1198 | db_incdir.replace("include", 'lib'), |
| 1199 | ] |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1200 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1201 | if not MACOS: |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1202 | db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_check)) |
| 1203 | |
| 1204 | else: |
| 1205 | # Same as other branch, but takes OSX SDK into account |
| 1206 | tmp = [] |
| 1207 | for dn in db_dirs_to_check: |
| 1208 | if is_macosx_sdk_path(dn): |
| 1209 | if os.path.isdir(os.path.join(sysroot, dn[1:])): |
| 1210 | tmp.append(dn) |
| 1211 | else: |
| 1212 | if os.path.isdir(dn): |
| 1213 | tmp.append(dn) |
Ronald Oussoren | dc969e5 | 2010-06-27 12:37:46 +0000 | [diff] [blame] | 1214 | db_dirs_to_check = tmp |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1215 | |
| 1216 | db_dirs_to_check = tmp |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1217 | |
Ezio Melotti | 42da663 | 2011-03-15 05:18:48 +0200 | [diff] [blame] | 1218 | # Look for a version specific db-X.Y before an ambiguous dbX |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1219 | # XXX should we -ever- look for a dbX name? Do any |
| 1220 | # systems really not name their library by version and |
| 1221 | # symlink to more general names? |
| 1222 | for dblib in (('db-%d.%d' % db_ver), |
| 1223 | ('db%d%d' % db_ver), |
| 1224 | ('db%d' % db_ver[0])): |
| 1225 | dblib_file = self.compiler.find_library_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1226 | db_dirs_to_check + self.lib_dirs, dblib ) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1227 | if dblib_file: |
| 1228 | dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ] |
| 1229 | raise db_found |
| 1230 | else: |
| 1231 | if db_setup_debug: print("db lib: ", dblib, "not found") |
| 1232 | |
| 1233 | except db_found: |
| 1234 | if db_setup_debug: |
| 1235 | print("bsddb using BerkeleyDB lib:", db_ver, dblib) |
| 1236 | print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir) |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1237 | dblibs = [dblib] |
doko@ubuntu.com | a3818a3 | 2014-04-17 17:52:48 +0200 | [diff] [blame] | 1238 | # Only add the found library and include directories if they aren't |
| 1239 | # already being searched. This avoids an explicit runtime library |
| 1240 | # dependency. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1241 | if db_incdir in self.inc_dirs: |
doko@ubuntu.com | a3818a3 | 2014-04-17 17:52:48 +0200 | [diff] [blame] | 1242 | db_incs = None |
| 1243 | else: |
| 1244 | db_incs = [db_incdir] |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1245 | if dblib_dir[0] in self.lib_dirs: |
doko@ubuntu.com | a3818a3 | 2014-04-17 17:52:48 +0200 | [diff] [blame] | 1246 | dblib_dir = None |
Georg Brandl | 489cb4f | 2009-07-11 10:08:49 +0000 | [diff] [blame] | 1247 | else: |
| 1248 | if db_setup_debug: print("db: no appropriate library found") |
| 1249 | db_incs = None |
| 1250 | dblibs = [] |
| 1251 | dblib_dir = None |
| 1252 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1253 | dbm_setup_debug = False # verbose debug prints from this script? |
| 1254 | dbm_order = ['gdbm'] |
| 1255 | # The standard Unix dbm module: |
| 1256 | if not CYGWIN: |
| 1257 | config_args = [arg.strip("'") |
| 1258 | for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] |
| 1259 | dbm_args = [arg for arg in config_args |
| 1260 | if arg.startswith('--with-dbmliborder=')] |
| 1261 | if dbm_args: |
| 1262 | dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") |
| 1263 | else: |
| 1264 | dbm_order = "ndbm:gdbm:bdb".split(":") |
| 1265 | dbmext = None |
| 1266 | for cand in dbm_order: |
| 1267 | if cand == "ndbm": |
| 1268 | if find_file("ndbm.h", self.inc_dirs, []) is not None: |
| 1269 | # Some systems have -lndbm, others have -lgdbm_compat, |
| 1270 | # others don't have either |
| 1271 | if self.compiler.find_library_file(self.lib_dirs, |
| 1272 | 'ndbm'): |
| 1273 | ndbm_libs = ['ndbm'] |
| 1274 | elif self.compiler.find_library_file(self.lib_dirs, |
| 1275 | 'gdbm_compat'): |
| 1276 | ndbm_libs = ['gdbm_compat'] |
| 1277 | else: |
| 1278 | ndbm_libs = [] |
| 1279 | if dbm_setup_debug: print("building dbm using ndbm") |
| 1280 | dbmext = Extension('_dbm', ['_dbmmodule.c'], |
| 1281 | define_macros=[ |
| 1282 | ('HAVE_NDBM_H',None), |
| 1283 | ], |
| 1284 | libraries=ndbm_libs) |
| 1285 | break |
| 1286 | |
| 1287 | elif cand == "gdbm": |
| 1288 | if self.compiler.find_library_file(self.lib_dirs, 'gdbm'): |
| 1289 | gdbm_libs = ['gdbm'] |
| 1290 | if self.compiler.find_library_file(self.lib_dirs, |
| 1291 | 'gdbm_compat'): |
| 1292 | gdbm_libs.append('gdbm_compat') |
| 1293 | if find_file("gdbm/ndbm.h", self.inc_dirs, []) is not None: |
| 1294 | if dbm_setup_debug: print("building dbm using gdbm") |
| 1295 | dbmext = Extension( |
| 1296 | '_dbm', ['_dbmmodule.c'], |
| 1297 | define_macros=[ |
| 1298 | ('HAVE_GDBM_NDBM_H', None), |
| 1299 | ], |
| 1300 | libraries = gdbm_libs) |
| 1301 | break |
| 1302 | if find_file("gdbm-ndbm.h", self.inc_dirs, []) is not None: |
| 1303 | if dbm_setup_debug: print("building dbm using gdbm") |
| 1304 | dbmext = Extension( |
| 1305 | '_dbm', ['_dbmmodule.c'], |
| 1306 | define_macros=[ |
| 1307 | ('HAVE_GDBM_DASH_NDBM_H', None), |
| 1308 | ], |
| 1309 | libraries = gdbm_libs) |
| 1310 | break |
| 1311 | elif cand == "bdb": |
| 1312 | if dblibs: |
| 1313 | if dbm_setup_debug: print("building dbm using bdb") |
| 1314 | dbmext = Extension('_dbm', ['_dbmmodule.c'], |
| 1315 | library_dirs=dblib_dir, |
| 1316 | runtime_library_dirs=dblib_dir, |
| 1317 | include_dirs=db_incs, |
| 1318 | define_macros=[ |
| 1319 | ('HAVE_BERKDB_H', None), |
| 1320 | ('DB_DBM_HSEARCH', None), |
| 1321 | ], |
| 1322 | libraries=dblibs) |
| 1323 | break |
| 1324 | if dbmext is not None: |
| 1325 | self.add(dbmext) |
| 1326 | else: |
| 1327 | self.missing.append('_dbm') |
| 1328 | |
| 1329 | # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: |
| 1330 | if ('gdbm' in dbm_order and |
| 1331 | self.compiler.find_library_file(self.lib_dirs, 'gdbm')): |
| 1332 | self.add(Extension('_gdbm', ['_gdbmmodule.c'], |
| 1333 | libraries=['gdbm'])) |
| 1334 | else: |
| 1335 | self.missing.append('_gdbm') |
| 1336 | |
| 1337 | def detect_sqlite(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1338 | # The sqlite interface |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 1339 | sqlite_setup_debug = False # verbose debug prints from this script? |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1340 | |
| 1341 | # We hunt for #define SQLITE_VERSION "n.n.n" |
Charles Pigott | ad0daf5 | 2019-04-26 16:38:12 +0100 | [diff] [blame] | 1342 | # We need to find >= sqlite version 3.3.9, for sqlite3_prepare_v2 |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1343 | sqlite_incdir = sqlite_libdir = None |
| 1344 | sqlite_inc_paths = [ '/usr/include', |
| 1345 | '/usr/include/sqlite', |
| 1346 | '/usr/include/sqlite3', |
| 1347 | '/usr/local/include', |
| 1348 | '/usr/local/include/sqlite', |
| 1349 | '/usr/local/include/sqlite3', |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 1350 | ] |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1351 | if CROSS_COMPILING: |
doko@ubuntu.com | 1abe1c5 | 2012-06-30 20:42:45 +0200 | [diff] [blame] | 1352 | sqlite_inc_paths = [] |
Miss Islington (bot) | 36101c2 | 2019-07-12 20:33:53 -0700 | [diff] [blame] | 1353 | MIN_SQLITE_VERSION_NUMBER = (3, 7, 2) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1354 | MIN_SQLITE_VERSION = ".".join([str(x) |
| 1355 | for x in MIN_SQLITE_VERSION_NUMBER]) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1356 | |
| 1357 | # Scan the default include directories before the SQLite specific |
| 1358 | # ones. This allows one to override the copy of sqlite on OSX, |
| 1359 | # where /usr/include contains an old version of sqlite. |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1360 | if MACOS: |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1361 | sysroot = macosx_sdk_root() |
| 1362 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1363 | for d_ in self.inc_dirs + sqlite_inc_paths: |
Ned Deily | 9b63583 | 2012-08-05 15:13:33 -0700 | [diff] [blame] | 1364 | d = d_ |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1365 | if MACOS and is_macosx_sdk_path(d): |
Ned Deily | 9b63583 | 2012-08-05 15:13:33 -0700 | [diff] [blame] | 1366 | d = os.path.join(sysroot, d[1:]) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1367 | |
Ned Deily | 9b63583 | 2012-08-05 15:13:33 -0700 | [diff] [blame] | 1368 | f = os.path.join(d, "sqlite3.h") |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1369 | if os.path.exists(f): |
Guido van Rossum | 452bf51 | 2007-02-09 05:32:43 +0000 | [diff] [blame] | 1370 | if sqlite_setup_debug: print("sqlite: found %s"%f) |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 1371 | with open(f) as file: |
| 1372 | incf = file.read() |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1373 | m = re.search( |
Petri Lehtinen | ed909bc | 2013-02-23 17:05:28 +0100 | [diff] [blame] | 1374 | r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"([\d\.]*)"', incf) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1375 | if m: |
| 1376 | sqlite_version = m.group(1) |
| 1377 | sqlite_version_tuple = tuple([int(x) |
| 1378 | for x in sqlite_version.split(".")]) |
| 1379 | if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: |
| 1380 | # we win! |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 1381 | if sqlite_setup_debug: |
Guido van Rossum | 452bf51 | 2007-02-09 05:32:43 +0000 | [diff] [blame] | 1382 | print("%s/sqlite3.h: version %s"%(d, sqlite_version)) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1383 | sqlite_incdir = d |
| 1384 | break |
| 1385 | else: |
| 1386 | if sqlite_setup_debug: |
Charles Pigott | ad0daf5 | 2019-04-26 16:38:12 +0100 | [diff] [blame] | 1387 | print("%s: version %s is too old, need >= %s"%(d, |
Guido van Rossum | 452bf51 | 2007-02-09 05:32:43 +0000 | [diff] [blame] | 1388 | sqlite_version, MIN_SQLITE_VERSION)) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1389 | elif sqlite_setup_debug: |
Guido van Rossum | 452bf51 | 2007-02-09 05:32:43 +0000 | [diff] [blame] | 1390 | print("sqlite: %s had no SQLITE_VERSION"%(f,)) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1391 | |
| 1392 | if sqlite_incdir: |
| 1393 | sqlite_dirs_to_check = [ |
| 1394 | os.path.join(sqlite_incdir, '..', 'lib64'), |
| 1395 | os.path.join(sqlite_incdir, '..', 'lib'), |
| 1396 | os.path.join(sqlite_incdir, '..', '..', 'lib64'), |
| 1397 | os.path.join(sqlite_incdir, '..', '..', 'lib'), |
| 1398 | ] |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 1399 | sqlite_libfile = self.compiler.find_library_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1400 | sqlite_dirs_to_check + self.lib_dirs, 'sqlite3') |
Benjamin Peterson | f10a79a | 2008-10-11 00:49:57 +0000 | [diff] [blame] | 1401 | if sqlite_libfile: |
| 1402 | sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1403 | |
| 1404 | if sqlite_incdir and sqlite_libdir: |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1405 | sqlite_srcs = ['_sqlite/cache.c', |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1406 | '_sqlite/connection.c', |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1407 | '_sqlite/cursor.c', |
| 1408 | '_sqlite/microprotocols.c', |
| 1409 | '_sqlite/module.c', |
| 1410 | '_sqlite/prepare_protocol.c', |
| 1411 | '_sqlite/row.c', |
| 1412 | '_sqlite/statement.c', |
| 1413 | '_sqlite/util.c', ] |
| 1414 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1415 | sqlite_defines = [] |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1416 | if not MS_WINDOWS: |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1417 | sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) |
| 1418 | else: |
| 1419 | sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) |
| 1420 | |
Benjamin Peterson | 076ed00 | 2010-10-31 17:11:02 +0000 | [diff] [blame] | 1421 | # Enable support for loadable extensions in the sqlite3 module |
| 1422 | # if --enable-loadable-sqlite-extensions configure option is used. |
| 1423 | if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"): |
| 1424 | sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1425 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1426 | if MACOS: |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1427 | # In every directory on the search path search for a dynamic |
| 1428 | # library and then a static library, instead of first looking |
Ezio Melotti | 1392500 | 2011-03-16 11:05:33 +0200 | [diff] [blame] | 1429 | # for dynamic libraries on the entire path. |
| 1430 | # This way a statically linked custom sqlite gets picked up |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1431 | # before the dynamic library in /usr/lib. |
| 1432 | sqlite_extra_link_args = ('-Wl,-search_paths_first',) |
| 1433 | else: |
| 1434 | sqlite_extra_link_args = () |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1435 | |
Brett Cannon | c5011fe | 2011-06-06 20:09:10 -0700 | [diff] [blame] | 1436 | include_dirs = ["Modules/_sqlite"] |
| 1437 | # Only include the directory where sqlite was found if it does |
| 1438 | # not already exist in set include directories, otherwise you |
| 1439 | # can end up with a bad search path order. |
| 1440 | if sqlite_incdir not in self.compiler.include_dirs: |
| 1441 | include_dirs.append(sqlite_incdir) |
doko@ubuntu.com | a3818a3 | 2014-04-17 17:52:48 +0200 | [diff] [blame] | 1442 | # avoid a runtime library path for a system library dir |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1443 | if sqlite_libdir and sqlite_libdir[0] in self.lib_dirs: |
doko@ubuntu.com | a3818a3 | 2014-04-17 17:52:48 +0200 | [diff] [blame] | 1444 | sqlite_libdir = None |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1445 | self.add(Extension('_sqlite3', sqlite_srcs, |
| 1446 | define_macros=sqlite_defines, |
| 1447 | include_dirs=include_dirs, |
| 1448 | library_dirs=sqlite_libdir, |
| 1449 | extra_link_args=sqlite_extra_link_args, |
| 1450 | libraries=["sqlite3",])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1451 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1452 | self.missing.append('_sqlite3') |
Skip Montanaro | 22e00c4 | 2003-05-06 20:43:34 +0000 | [diff] [blame] | 1453 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1454 | def detect_platform_specific_exts(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1455 | # Unix-only modules |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1456 | if not MS_WINDOWS: |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1457 | if not VXWORKS: |
| 1458 | # Steen Lumholt's termios module |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1459 | self.add(Extension('termios', ['termios.c'])) |
pxinwr | 32f5fdd | 2019-02-27 19:09:28 +0800 | [diff] [blame] | 1460 | # Jeremy Hylton's rlimit interface |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1461 | self.add(Extension('resource', ['resource.c'])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1462 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1463 | self.missing.extend(['resource', 'termios']) |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 1464 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1465 | # Platform-specific libraries |
| 1466 | if HOST_PLATFORM.startswith(('linux', 'freebsd', 'gnukfreebsd')): |
| 1467 | self.add(Extension('ossaudiodev', ['ossaudiodev.c'])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1468 | else: |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1469 | self.missing.append('ossaudiodev') |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1470 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1471 | if MACOS: |
| 1472 | self.add(Extension('_scproxy', ['_scproxy.c'], |
| 1473 | extra_link_args=[ |
| 1474 | '-framework', 'SystemConfiguration', |
| 1475 | '-framework', 'CoreFoundation'])) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1476 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1477 | def detect_compress_exts(self): |
Barry Warsaw | 259b1e1 | 2002-08-13 20:09:26 +0000 | [diff] [blame] | 1478 | # Andrew Kuchling's zlib module. Note that some versions of zlib |
| 1479 | # 1.1.3 have security problems. See CERT Advisory CA-2002-07: |
| 1480 | # http://www.cert.org/advisories/CA-2002-07.html |
| 1481 | # |
| 1482 | # zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to |
| 1483 | # patch its zlib 1.1.3 package instead of upgrading to 1.1.4. For |
| 1484 | # now, we still accept 1.1.3, because we think it's difficult to |
| 1485 | # exploit this in Python, and we'd rather make it RedHat's problem |
| 1486 | # than our problem <wink>. |
| 1487 | # |
| 1488 | # You can upgrade zlib to version 1.1.4 yourself by going to |
| 1489 | # http://www.gzip.org/zlib/ |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1490 | zlib_inc = find_file('zlib.h', [], self.inc_dirs) |
Christian Heimes | 1dc5400 | 2008-03-24 02:19:29 +0000 | [diff] [blame] | 1491 | have_zlib = False |
Guido van Rossum | e697091 | 2001-04-15 15:16:12 +0000 | [diff] [blame] | 1492 | if zlib_inc is not None: |
| 1493 | zlib_h = zlib_inc[0] + '/zlib.h' |
| 1494 | version = '"0.0.0"' |
Barry Warsaw | 259b1e1 | 2002-08-13 20:09:26 +0000 | [diff] [blame] | 1495 | version_req = '"1.1.3"' |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1496 | if MACOS and is_macosx_sdk_path(zlib_h): |
Ned Deily | 507c591 | 2013-10-18 21:32:00 -0700 | [diff] [blame] | 1497 | zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:]) |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 1498 | with open(zlib_h) as fp: |
| 1499 | while 1: |
| 1500 | line = fp.readline() |
| 1501 | if not line: |
| 1502 | break |
| 1503 | if line.startswith('#define ZLIB_VERSION'): |
| 1504 | version = line.split()[2] |
| 1505 | break |
Guido van Rossum | e697091 | 2001-04-15 15:16:12 +0000 | [diff] [blame] | 1506 | if version >= version_req: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1507 | if (self.compiler.find_library_file(self.lib_dirs, 'z')): |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1508 | if MACOS: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 1509 | zlib_extra_link_args = ('-Wl,-search_paths_first',) |
| 1510 | else: |
| 1511 | zlib_extra_link_args = () |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1512 | self.add(Extension('zlib', ['zlibmodule.c'], |
| 1513 | libraries=['z'], |
| 1514 | extra_link_args=zlib_extra_link_args)) |
Christian Heimes | 1dc5400 | 2008-03-24 02:19:29 +0000 | [diff] [blame] | 1515 | have_zlib = True |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1516 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1517 | self.missing.append('zlib') |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1518 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1519 | self.missing.append('zlib') |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1520 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1521 | self.missing.append('zlib') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1522 | |
Christian Heimes | 1dc5400 | 2008-03-24 02:19:29 +0000 | [diff] [blame] | 1523 | # Helper module for various ascii-encoders. Uses zlib for an optimized |
| 1524 | # crc32 if we have it. Otherwise binascii uses its own. |
| 1525 | if have_zlib: |
| 1526 | extra_compile_args = ['-DUSE_ZLIB_CRC32'] |
| 1527 | libraries = ['z'] |
| 1528 | extra_link_args = zlib_extra_link_args |
| 1529 | else: |
| 1530 | extra_compile_args = [] |
| 1531 | libraries = [] |
| 1532 | extra_link_args = [] |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1533 | self.add(Extension('binascii', ['binascii.c'], |
| 1534 | extra_compile_args=extra_compile_args, |
| 1535 | libraries=libraries, |
| 1536 | extra_link_args=extra_link_args)) |
Christian Heimes | 1dc5400 | 2008-03-24 02:19:29 +0000 | [diff] [blame] | 1537 | |
Gustavo Niemeyer | f8ca836 | 2002-11-05 16:50:05 +0000 | [diff] [blame] | 1538 | # Gustavo Niemeyer's bz2 module. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1539 | if (self.compiler.find_library_file(self.lib_dirs, 'bz2')): |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1540 | if MACOS: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 1541 | bz2_extra_link_args = ('-Wl,-search_paths_first',) |
| 1542 | else: |
| 1543 | bz2_extra_link_args = () |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1544 | self.add(Extension('_bz2', ['_bz2module.c'], |
| 1545 | libraries=['bz2'], |
| 1546 | extra_link_args=bz2_extra_link_args)) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1547 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1548 | self.missing.append('_bz2') |
Gustavo Niemeyer | f8ca836 | 2002-11-05 16:50:05 +0000 | [diff] [blame] | 1549 | |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 1550 | # LZMA compression support. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1551 | if self.compiler.find_library_file(self.lib_dirs, 'lzma'): |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1552 | self.add(Extension('_lzma', ['_lzmamodule.c'], |
| 1553 | libraries=['lzma'])) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 1554 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1555 | self.missing.append('_lzma') |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 1556 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1557 | def detect_expat_elementtree(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1558 | # Interface to the Expat XML parser |
| 1559 | # |
Benjamin Peterson | a28e702 | 2010-01-09 18:53:06 +0000 | [diff] [blame] | 1560 | # Expat was written by James Clark and is now maintained by a group of |
| 1561 | # developers on SourceForge; see www.libexpat.org for more information. |
| 1562 | # The pyexpat module was written by Paul Prescod after a prototype by |
| 1563 | # Jack Jansen. The Expat source is included in Modules/expat/. Usage |
| 1564 | # of a system shared libexpat.so is possible with --with-system-expat |
Benjamin Peterson | c73206c | 2010-10-31 16:38:19 +0000 | [diff] [blame] | 1565 | # configure option. |
Fred Drake | fc8341d | 2002-06-17 17:55:30 +0000 | [diff] [blame] | 1566 | # |
| 1567 | # More information on Expat can be found at www.libexpat.org. |
| 1568 | # |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1569 | if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): |
| 1570 | expat_inc = [] |
| 1571 | define_macros = [] |
Stefan Krah | 9e1e6f5 | 2017-08-25 14:07:50 +0200 | [diff] [blame] | 1572 | extra_compile_args = [] |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1573 | expat_lib = ['expat'] |
| 1574 | expat_sources = [] |
Christian Heimes | d489c7a | 2013-02-09 17:02:06 +0100 | [diff] [blame] | 1575 | expat_depends = [] |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1576 | else: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1577 | expat_inc = [os.path.join(self.srcdir, 'Modules', 'expat')] |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1578 | define_macros = [ |
| 1579 | ('HAVE_EXPAT_CONFIG_H', '1'), |
Victor Stinner | 93d0cb5 | 2017-08-18 23:43:54 +0200 | [diff] [blame] | 1580 | # bpo-30947: Python uses best available entropy sources to |
| 1581 | # call XML_SetHashSalt(), expat entropy sources are not needed |
| 1582 | ('XML_POOR_ENTROPY', '1'), |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1583 | ] |
Stefan Krah | 9e1e6f5 | 2017-08-25 14:07:50 +0200 | [diff] [blame] | 1584 | extra_compile_args = [] |
Benjamin Peterson | b2d9046 | 2009-12-31 03:23:10 +0000 | [diff] [blame] | 1585 | expat_lib = [] |
| 1586 | expat_sources = ['expat/xmlparse.c', |
| 1587 | 'expat/xmlrole.c', |
| 1588 | 'expat/xmltok.c'] |
Christian Heimes | d489c7a | 2013-02-09 17:02:06 +0100 | [diff] [blame] | 1589 | expat_depends = ['expat/ascii.h', |
| 1590 | 'expat/asciitab.h', |
| 1591 | 'expat/expat.h', |
| 1592 | 'expat/expat_config.h', |
| 1593 | 'expat/expat_external.h', |
| 1594 | 'expat/internal.h', |
| 1595 | 'expat/latin1tab.h', |
| 1596 | 'expat/utf8tab.h', |
| 1597 | 'expat/xmlrole.h', |
| 1598 | 'expat/xmltok.h', |
| 1599 | 'expat/xmltok_impl.h' |
| 1600 | ] |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 1601 | |
Stefan Krah | 9e1e6f5 | 2017-08-25 14:07:50 +0200 | [diff] [blame] | 1602 | cc = sysconfig.get_config_var('CC').split()[0] |
| 1603 | ret = os.system( |
Benjamin Peterson | 66c42f8 | 2019-06-29 16:51:59 -0700 | [diff] [blame] | 1604 | '"%s" -Werror -Wno-unreachable-code -E -xc /dev/null >/dev/null 2>&1' % cc) |
Stefan Krah | 9e1e6f5 | 2017-08-25 14:07:50 +0200 | [diff] [blame] | 1605 | if ret >> 8 == 0: |
Benjamin Peterson | 66c42f8 | 2019-06-29 16:51:59 -0700 | [diff] [blame] | 1606 | extra_compile_args.append('-Wno-unreachable-code') |
Stefan Krah | 9e1e6f5 | 2017-08-25 14:07:50 +0200 | [diff] [blame] | 1607 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1608 | self.add(Extension('pyexpat', |
| 1609 | define_macros=define_macros, |
| 1610 | extra_compile_args=extra_compile_args, |
| 1611 | include_dirs=expat_inc, |
| 1612 | libraries=expat_lib, |
| 1613 | sources=['pyexpat.c'] + expat_sources, |
| 1614 | depends=expat_depends)) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1615 | |
Fredrik Lundh | 4c86ec6 | 2005-12-14 18:46:16 +0000 | [diff] [blame] | 1616 | # Fredrik Lundh's cElementTree module. Note that this also |
| 1617 | # uses expat (via the CAPI hook in pyexpat). |
| 1618 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1619 | if os.path.isfile(os.path.join(self.srcdir, 'Modules', '_elementtree.c')): |
Fredrik Lundh | 4c86ec6 | 2005-12-14 18:46:16 +0000 | [diff] [blame] | 1620 | define_macros.append(('USE_PYEXPAT_CAPI', None)) |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1621 | self.add(Extension('_elementtree', |
| 1622 | define_macros=define_macros, |
| 1623 | include_dirs=expat_inc, |
| 1624 | libraries=expat_lib, |
| 1625 | sources=['_elementtree.c'], |
| 1626 | depends=['pyexpat.c', *expat_sources, |
| 1627 | *expat_depends])) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 1628 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1629 | self.missing.append('_elementtree') |
Fredrik Lundh | 4c86ec6 | 2005-12-14 18:46:16 +0000 | [diff] [blame] | 1630 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1631 | def detect_multibytecodecs(self): |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1632 | # Hye-Shik Chang's CJKCodecs modules. |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1633 | self.add(Extension('_multibytecodec', |
| 1634 | ['cjkcodecs/multibytecodec.c'])) |
Walter Dörwald | e9eaab4 | 2007-05-22 16:02:13 +0000 | [diff] [blame] | 1635 | for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1636 | self.add(Extension('_codecs_%s' % loc, |
| 1637 | ['cjkcodecs/_codecs_%s.c' % loc])) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1638 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1639 | def detect_multiprocessing(self): |
Benjamin Peterson | e711caf | 2008-06-11 16:44:04 +0000 | [diff] [blame] | 1640 | # Richard Oudkerk's multiprocessing module |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1641 | if MS_WINDOWS: |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 1642 | multiprocessing_srcs = ['_multiprocessing/multiprocessing.c', |
| 1643 | '_multiprocessing/semaphore.c'] |
Benjamin Peterson | e711caf | 2008-06-11 16:44:04 +0000 | [diff] [blame] | 1644 | |
| 1645 | else: |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 1646 | multiprocessing_srcs = ['_multiprocessing/multiprocessing.c'] |
Mark Dickinson | a614f04 | 2009-11-28 12:48:43 +0000 | [diff] [blame] | 1647 | if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not |
| 1648 | sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): |
Benjamin Peterson | e711caf | 2008-06-11 16:44:04 +0000 | [diff] [blame] | 1649 | multiprocessing_srcs.append('_multiprocessing/semaphore.c') |
Neil Schemenauer | 5741c45 | 2019-02-08 10:48:46 -0800 | [diff] [blame] | 1650 | if (sysconfig.get_config_var('HAVE_SHM_OPEN') and |
| 1651 | sysconfig.get_config_var('HAVE_SHM_UNLINK')): |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 1652 | posixshmem_srcs = ['_multiprocessing/posixshmem.c'] |
Davin Potts | e5ef45b | 2019-02-01 22:52:23 -0600 | [diff] [blame] | 1653 | libs = [] |
Neil Schemenauer | 5741c45 | 2019-02-08 10:48:46 -0800 | [diff] [blame] | 1654 | if sysconfig.get_config_var('SHM_NEEDS_LIBRT'): |
| 1655 | # need to link with librt to get shm_open() |
Davin Potts | e5ef45b | 2019-02-01 22:52:23 -0600 | [diff] [blame] | 1656 | libs.append('rt') |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1657 | self.add(Extension('_posixshmem', posixshmem_srcs, |
| 1658 | define_macros={}, |
| 1659 | libraries=libs, |
| 1660 | include_dirs=["Modules/_multiprocessing"])) |
Benjamin Peterson | e711caf | 2008-06-11 16:44:04 +0000 | [diff] [blame] | 1661 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1662 | self.add(Extension('_multiprocessing', multiprocessing_srcs, |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1663 | include_dirs=["Modules/_multiprocessing"])) |
Guido van Rossum | a9e2024 | 2007-03-08 00:43:48 +0000 | [diff] [blame] | 1664 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1665 | def detect_uuid(self): |
Antoine Pitrou | a106aec | 2017-09-28 23:03:06 +0200 | [diff] [blame] | 1666 | # Build the _uuid module if possible |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1667 | uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"]) |
Nick Coghlan | 53efbf3 | 2017-11-26 13:04:46 +1000 | [diff] [blame] | 1668 | if uuid_incs is not None: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1669 | if self.compiler.find_library_file(self.lib_dirs, 'uuid'): |
Antoine Pitrou | a106aec | 2017-09-28 23:03:06 +0200 | [diff] [blame] | 1670 | uuid_libs = ['uuid'] |
| 1671 | else: |
| 1672 | uuid_libs = [] |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1673 | self.add(Extension('_uuid', ['_uuidmodule.c'], |
| 1674 | libraries=uuid_libs, |
| 1675 | include_dirs=uuid_incs)) |
Antoine Pitrou | a106aec | 2017-09-28 23:03:06 +0200 | [diff] [blame] | 1676 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 1677 | self.missing.append('_uuid') |
Antoine Pitrou | a106aec | 2017-09-28 23:03:06 +0200 | [diff] [blame] | 1678 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1679 | def detect_modules(self): |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1680 | self.configure_compiler() |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1681 | self.init_inc_lib_dirs() |
| 1682 | |
| 1683 | self.detect_simple_extensions() |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1684 | if TEST_EXTENSIONS: |
| 1685 | self.detect_test_extensions() |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1686 | self.detect_readline_curses() |
| 1687 | self.detect_crypt() |
| 1688 | self.detect_socket() |
| 1689 | self.detect_openssl_hashlib() |
xdegaye | 2ee077f | 2019-04-09 17:20:08 +0200 | [diff] [blame] | 1690 | self.detect_hash_builtins() |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1691 | self.detect_dbm_gdbm() |
| 1692 | self.detect_sqlite() |
| 1693 | self.detect_platform_specific_exts() |
| 1694 | self.detect_nis() |
| 1695 | self.detect_compress_exts() |
| 1696 | self.detect_expat_elementtree() |
| 1697 | self.detect_multibytecodecs() |
| 1698 | self.detect_decimal() |
| 1699 | self.detect_ctypes() |
| 1700 | self.detect_multiprocessing() |
| 1701 | if not self.detect_tkinter(): |
| 1702 | self.missing.append('_tkinter') |
| 1703 | self.detect_uuid() |
| 1704 | |
Ned Deily | cd3d8fb | 2013-08-01 23:51:27 -0700 | [diff] [blame] | 1705 | ## # Uncomment these lines if you want to play with xxmodule.c |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1706 | ## self.add(Extension('xx', ['xxmodule.c'])) |
Ned Deily | cd3d8fb | 2013-08-01 23:51:27 -0700 | [diff] [blame] | 1707 | |
Xavier de Gaye | 13f1c33 | 2016-12-10 16:45:53 +0100 | [diff] [blame] | 1708 | if 'd' not in sysconfig.get_config_var('ABIFLAGS'): |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1709 | self.add(Extension('xxlimited', ['xxlimited.c'], |
| 1710 | define_macros=[('Py_LIMITED_API', '0x03050000')])) |
Ned Deily | cd3d8fb | 2013-08-01 23:51:27 -0700 | [diff] [blame] | 1711 | |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1712 | def detect_tkinter_explicitly(self): |
| 1713 | # Build _tkinter using explicit locations for Tcl/Tk. |
| 1714 | # |
| 1715 | # This is enabled when both arguments are given to ./configure: |
| 1716 | # |
| 1717 | # --with-tcltk-includes="-I/path/to/tclincludes \ |
| 1718 | # -I/path/to/tkincludes" |
| 1719 | # --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \ |
| 1720 | # -L/path/to/tklibs -ltkm.n" |
| 1721 | # |
Martin Panter | e26da7c | 2016-06-02 10:07:09 +0000 | [diff] [blame] | 1722 | # These values can also be specified or overridden via make: |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1723 | # make TCLTK_INCLUDES="..." TCLTK_LIBS="..." |
| 1724 | # |
| 1725 | # This can be useful for building and testing tkinter with multiple |
| 1726 | # versions of Tcl/Tk. Note that a build of Tk depends on a particular |
| 1727 | # build of Tcl so you need to specify both arguments and use care when |
| 1728 | # overriding. |
| 1729 | |
| 1730 | # The _TCLTK variables are created in the Makefile sharedmods target. |
| 1731 | tcltk_includes = os.environ.get('_TCLTK_INCLUDES') |
| 1732 | tcltk_libs = os.environ.get('_TCLTK_LIBS') |
| 1733 | if not (tcltk_includes and tcltk_libs): |
| 1734 | # Resume default configuration search. |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1735 | return False |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1736 | |
| 1737 | extra_compile_args = tcltk_includes.split() |
| 1738 | extra_link_args = tcltk_libs.split() |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1739 | self.add(Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 1740 | define_macros=[('WITH_APPINIT', 1)], |
| 1741 | extra_compile_args = extra_compile_args, |
| 1742 | extra_link_args = extra_link_args)) |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1743 | return True |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1744 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1745 | def detect_tkinter_darwin(self): |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1746 | # The _tkinter module, using frameworks. Since frameworks are quite |
| 1747 | # different the UNIX search logic is not sharable. |
| 1748 | from os.path import join, exists |
| 1749 | framework_dirs = [ |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1750 | '/Library/Frameworks', |
Ronald Oussoren | 5f734f1 | 2009-03-04 21:32:48 +0000 | [diff] [blame] | 1751 | '/System/Library/Frameworks/', |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1752 | join(os.getenv('HOME'), '/Library/Frameworks') |
| 1753 | ] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1754 | |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1755 | sysroot = macosx_sdk_root() |
| 1756 | |
Skip Montanaro | 0174ddd | 2005-12-30 05:01:26 +0000 | [diff] [blame] | 1757 | # Find the directory that contains the Tcl.framework and Tk.framework |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1758 | # bundles. |
| 1759 | # XXX distutils should support -F! |
| 1760 | for F in framework_dirs: |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1761 | # both Tcl.framework and Tk.framework should be present |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1762 | |
| 1763 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1764 | for fw in 'Tcl', 'Tk': |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1765 | if is_macosx_sdk_path(F): |
| 1766 | if not exists(join(sysroot, F[1:], fw + '.framework')): |
| 1767 | break |
| 1768 | else: |
| 1769 | if not exists(join(F, fw + '.framework')): |
| 1770 | break |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1771 | else: |
| 1772 | # ok, F is now directory with both frameworks. Continure |
| 1773 | # building |
| 1774 | break |
| 1775 | else: |
| 1776 | # Tk and Tcl frameworks not found. Normal "unix" tkinter search |
| 1777 | # will now resume. |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1778 | return False |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1779 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1780 | # For 8.4a2, we must add -I options that point inside the Tcl and Tk |
| 1781 | # frameworks. In later release we should hopefully be able to pass |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1782 | # the -F option to gcc, which specifies a framework lookup path. |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1783 | # |
| 1784 | include_dirs = [ |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1785 | join(F, fw + '.framework', H) |
Nick Coghlan | 650f0d0 | 2007-04-15 12:05:43 +0000 | [diff] [blame] | 1786 | for fw in ('Tcl', 'Tk') |
| 1787 | for H in ('Headers', 'Versions/Current/PrivateHeaders') |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1788 | ] |
| 1789 | |
Tim Peters | 2c60f7a | 2003-01-29 03:49:43 +0000 | [diff] [blame] | 1790 | # For 8.4a2, the X11 headers are not included. Rather than include a |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1791 | # complicated search, this is a hard-coded path. It could bail out |
| 1792 | # if X11 libs are not found... |
| 1793 | include_dirs.append('/usr/X11R6/include') |
| 1794 | frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] |
| 1795 | |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 1796 | # All existing framework builds of Tcl/Tk don't support 64-bit |
| 1797 | # architectures. |
| 1798 | cflags = sysconfig.get_config_vars('CFLAGS')[0] |
R David Murray | 44b548d | 2016-09-08 13:59:53 -0400 | [diff] [blame] | 1799 | archs = re.findall(r'-arch\s+(\w+)', cflags) |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 1800 | |
Ronald Oussoren | d097efe | 2009-09-15 19:07:58 +0000 | [diff] [blame] | 1801 | tmpfile = os.path.join(self.build_temp, 'tk.arch') |
| 1802 | if not os.path.exists(self.build_temp): |
| 1803 | os.makedirs(self.build_temp) |
| 1804 | |
| 1805 | # Note: cannot use os.popen or subprocess here, that |
| 1806 | # requires extensions that are not available here. |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1807 | if is_macosx_sdk_path(F): |
| 1808 | os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(os.path.join(sysroot, F[1:]), tmpfile)) |
| 1809 | else: |
| 1810 | os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(F, tmpfile)) |
Ronald Oussoren | 2c12ab1 | 2010-06-03 14:42:25 +0000 | [diff] [blame] | 1811 | |
Brett Cannon | 9f5db07 | 2010-10-29 20:19:27 +0000 | [diff] [blame] | 1812 | with open(tmpfile) as fp: |
| 1813 | detected_archs = [] |
| 1814 | for ln in fp: |
| 1815 | a = ln.split()[-1] |
| 1816 | if a in archs: |
| 1817 | detected_archs.append(ln.split()[-1]) |
Ronald Oussoren | d097efe | 2009-09-15 19:07:58 +0000 | [diff] [blame] | 1818 | os.unlink(tmpfile) |
| 1819 | |
| 1820 | for a in detected_archs: |
| 1821 | frameworks.append('-arch') |
| 1822 | frameworks.append(a) |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 1823 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1824 | self.add(Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 1825 | define_macros=[('WITH_APPINIT', 1)], |
| 1826 | include_dirs=include_dirs, |
| 1827 | libraries=[], |
| 1828 | extra_compile_args=frameworks[2:], |
| 1829 | extra_link_args=frameworks)) |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1830 | return True |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1831 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1832 | def detect_tkinter(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1833 | # The _tkinter module. |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 1834 | |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1835 | # Check whether --with-tcltk-includes and --with-tcltk-libs were |
| 1836 | # configured or passed into the make target. If so, use these values |
| 1837 | # to build tkinter and bypass the searches for Tcl and TK in standard |
| 1838 | # locations. |
| 1839 | if self.detect_tkinter_explicitly(): |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1840 | return True |
Ned Deily | d819b93 | 2013-09-06 01:07:05 -0700 | [diff] [blame] | 1841 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1842 | # Rather than complicate the code below, detecting and building |
| 1843 | # AquaTk is a separate method. Only one Tkinter will be built on |
| 1844 | # Darwin - either AquaTk, if it is found, or X11 based Tk. |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1845 | if (MACOS and self.detect_tkinter_darwin()): |
| 1846 | return True |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 1847 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1848 | # Assume we haven't found any of the libraries or include files |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 1849 | # The versions with dots are used on Unix, and the versions without |
| 1850 | # dots on Windows, for detection by cygwin. |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1851 | tcllib = tklib = tcl_includes = tk_includes = None |
Guilherme Polo | 5d377bd | 2009-08-16 14:44:14 +0000 | [diff] [blame] | 1852 | for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', |
| 1853 | '8.2', '82', '8.1', '81', '8.0', '80']: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1854 | tklib = self.compiler.find_library_file(self.lib_dirs, |
Tarek Ziadé | dd07ebb | 2009-07-06 13:52:17 +0000 | [diff] [blame] | 1855 | 'tk' + version) |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1856 | tcllib = self.compiler.find_library_file(self.lib_dirs, |
Tarek Ziadé | dd07ebb | 2009-07-06 13:52:17 +0000 | [diff] [blame] | 1857 | 'tcl' + version) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 1858 | if tklib and tcllib: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1859 | # Exit the loop when we've found the Tcl/Tk libraries |
| 1860 | break |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1861 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1862 | # Now check for the header files |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1863 | if tklib and tcllib: |
Andrew M. Kuchling | 3c0aa7e | 2004-03-21 18:57:35 +0000 | [diff] [blame] | 1864 | # Check for the include files on Debian and {Free,Open}BSD, where |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1865 | # they're put in /usr/include/{tcl,tk}X.Y |
Andrew M. Kuchling | 3c0aa7e | 2004-03-21 18:57:35 +0000 | [diff] [blame] | 1866 | dotversion = version |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1867 | if '.' not in dotversion and "bsd" in HOST_PLATFORM.lower(): |
Andrew M. Kuchling | 3c0aa7e | 2004-03-21 18:57:35 +0000 | [diff] [blame] | 1868 | # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, |
| 1869 | # but the include subdirs are named like .../include/tcl8.3. |
| 1870 | dotversion = dotversion[:-1] + '.' + dotversion[-1] |
| 1871 | tcl_include_sub = [] |
| 1872 | tk_include_sub = [] |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1873 | for dir in self.inc_dirs: |
Andrew M. Kuchling | 3c0aa7e | 2004-03-21 18:57:35 +0000 | [diff] [blame] | 1874 | tcl_include_sub += [dir + os.sep + "tcl" + dotversion] |
| 1875 | tk_include_sub += [dir + os.sep + "tk" + dotversion] |
| 1876 | tk_include_sub += tcl_include_sub |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1877 | tcl_includes = find_file('tcl.h', self.inc_dirs, tcl_include_sub) |
| 1878 | tk_includes = find_file('tk.h', self.inc_dirs, tk_include_sub) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1879 | |
Martin v. Löwis | e86a59a | 2003-05-03 08:45:51 +0000 | [diff] [blame] | 1880 | if (tcllib is None or tklib is None or |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1881 | tcl_includes is None or tk_includes is None): |
Andrew M. Kuchling | 3c0aa7e | 2004-03-21 18:57:35 +0000 | [diff] [blame] | 1882 | self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1883 | return False |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1884 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1885 | # OK... everything seems to be present for Tcl/Tk. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1886 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1887 | include_dirs = [] |
| 1888 | libs = [] |
| 1889 | defs = [] |
| 1890 | added_lib_dirs = [] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1891 | for dir in tcl_includes + tk_includes: |
| 1892 | if dir not in include_dirs: |
| 1893 | include_dirs.append(dir) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1894 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1895 | # Check for various platform-specific directories |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1896 | if HOST_PLATFORM == 'sunos5': |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1897 | include_dirs.append('/usr/openwin/include') |
| 1898 | added_lib_dirs.append('/usr/openwin/lib') |
| 1899 | elif os.path.exists('/usr/X11R6/include'): |
| 1900 | include_dirs.append('/usr/X11R6/include') |
Martin v. Löwis | fba7369 | 2004-11-13 11:13:35 +0000 | [diff] [blame] | 1901 | added_lib_dirs.append('/usr/X11R6/lib64') |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1902 | added_lib_dirs.append('/usr/X11R6/lib') |
| 1903 | elif os.path.exists('/usr/X11R5/include'): |
| 1904 | include_dirs.append('/usr/X11R5/include') |
| 1905 | added_lib_dirs.append('/usr/X11R5/lib') |
| 1906 | else: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1907 | # Assume default location for X11 |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1908 | include_dirs.append('/usr/X11/include') |
| 1909 | added_lib_dirs.append('/usr/X11/lib') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1910 | |
Jason Tishler | 9181c94 | 2003-02-05 15:16:17 +0000 | [diff] [blame] | 1911 | # If Cygwin, then verify that X is installed before proceeding |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1912 | if CYGWIN: |
Jason Tishler | 9181c94 | 2003-02-05 15:16:17 +0000 | [diff] [blame] | 1913 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) |
| 1914 | if x11_inc is None: |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1915 | return False |
Jason Tishler | 9181c94 | 2003-02-05 15:16:17 +0000 | [diff] [blame] | 1916 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1917 | # Check for BLT extension |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1918 | if self.compiler.find_library_file(self.lib_dirs + added_lib_dirs, |
Tarek Ziadé | dd07ebb | 2009-07-06 13:52:17 +0000 | [diff] [blame] | 1919 | 'BLT8.0'): |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1920 | defs.append( ('WITH_BLT', 1) ) |
| 1921 | libs.append('BLT8.0') |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1922 | elif self.compiler.find_library_file(self.lib_dirs + added_lib_dirs, |
Tarek Ziadé | dd07ebb | 2009-07-06 13:52:17 +0000 | [diff] [blame] | 1923 | 'BLT'): |
Martin v. Löwis | 427a290 | 2002-12-12 20:23:38 +0000 | [diff] [blame] | 1924 | defs.append( ('WITH_BLT', 1) ) |
| 1925 | libs.append('BLT') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1926 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1927 | # Add the Tcl/Tk libraries |
Jason Tishler | cccac1a | 2003-02-05 15:06:46 +0000 | [diff] [blame] | 1928 | libs.append('tk'+ version) |
| 1929 | libs.append('tcl'+ version) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1930 | |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 1931 | # Finally, link with the X11 libraries (not appropriate on cygwin) |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1932 | if not CYGWIN: |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 1933 | libs.append('X11') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1934 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 1935 | # XXX handle these, but how to detect? |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1936 | # *** Uncomment and edit for PIL (TkImaging) extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1937 | # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1938 | # *** Uncomment and edit for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1939 | # -DWITH_TOGL togl.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1940 | # *** Uncomment these for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1941 | # -lGL -lGLU -lXext -lXmu \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1942 | |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 1943 | self.add(Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 1944 | define_macros=[('WITH_APPINIT', 1)] + defs, |
| 1945 | include_dirs=include_dirs, |
| 1946 | libraries=libs, |
| 1947 | library_dirs=added_lib_dirs)) |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1948 | return True |
| 1949 | |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 1950 | def configure_ctypes_darwin(self, ext): |
| 1951 | # Darwin (OS X) uses preconfigured files, in |
| 1952 | # the Modules/_ctypes/libffi_osx directory. |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1953 | ffi_srcdir = os.path.abspath(os.path.join(self.srcdir, 'Modules', |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 1954 | '_ctypes', 'libffi_osx')) |
| 1955 | sources = [os.path.join(ffi_srcdir, p) |
| 1956 | for p in ['ffi.c', |
Georg Brandl | fcaf910 | 2008-07-16 02:17:56 +0000 | [diff] [blame] | 1957 | 'x86/darwin64.S', |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 1958 | 'x86/x86-darwin.S', |
| 1959 | 'x86/x86-ffi_darwin.c', |
| 1960 | 'x86/x86-ffi64.c', |
| 1961 | 'powerpc/ppc-darwin.S', |
| 1962 | 'powerpc/ppc-darwin_closure.S', |
| 1963 | 'powerpc/ppc-ffi_darwin.c', |
| 1964 | 'powerpc/ppc64-darwin_closure.S', |
| 1965 | ]] |
| 1966 | |
| 1967 | # Add .S (preprocessed assembly) to C compiler source extensions. |
Tarek Ziadé | 3679727 | 2010-07-22 12:50:05 +0000 | [diff] [blame] | 1968 | self.compiler.src_extensions.append('.S') |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 1969 | |
| 1970 | include_dirs = [os.path.join(ffi_srcdir, 'include'), |
| 1971 | os.path.join(ffi_srcdir, 'powerpc')] |
| 1972 | ext.include_dirs.extend(include_dirs) |
| 1973 | ext.sources.extend(sources) |
| 1974 | return True |
| 1975 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1976 | def configure_ctypes(self, ext): |
| 1977 | if not self.use_system_libffi: |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1978 | if MACOS: |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 1979 | return self.configure_ctypes_darwin(ext) |
Zachary Ware | f40d4dd | 2016-09-17 01:25:24 -0500 | [diff] [blame] | 1980 | print('INFO: Could not locate ffi libs and/or headers') |
| 1981 | return False |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1982 | return True |
| 1983 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 1984 | def detect_ctypes(self): |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 1985 | # Thomas Heller's _ctypes module |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1986 | self.use_system_libffi = False |
| 1987 | include_dirs = [] |
| 1988 | extra_compile_args = [] |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 1989 | extra_link_args = [] |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 1990 | sources = ['_ctypes/_ctypes.c', |
| 1991 | '_ctypes/callbacks.c', |
| 1992 | '_ctypes/callproc.c', |
| 1993 | '_ctypes/stgdict.c', |
Thomas Heller | 864cc67 | 2010-08-08 17:58:53 +0000 | [diff] [blame] | 1994 | '_ctypes/cfield.c'] |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 1995 | depends = ['_ctypes/ctypes.h'] |
| 1996 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 1997 | if MACOS: |
Ronald Oussoren | 2decf22 | 2010-09-05 18:25:59 +0000 | [diff] [blame] | 1998 | sources.append('_ctypes/malloc_closure.c') |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 1999 | sources.append('_ctypes/darwin/dlfcn_simple.c') |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 2000 | extra_compile_args.append('-DMACOSX') |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 2001 | include_dirs.append('_ctypes/darwin') |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 2002 | # XXX Is this still needed? |
| 2003 | # extra_link_args.extend(['-read_only_relocs', 'warning']) |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 2004 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2005 | elif HOST_PLATFORM == 'sunos5': |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 2006 | # XXX This shouldn't be necessary; it appears that some |
| 2007 | # of the assembler code is non-PIC (i.e. it has relocations |
| 2008 | # when it shouldn't. The proper fix would be to rewrite |
| 2009 | # the assembler code to be PIC. |
| 2010 | # This only works with GCC; the Sun compiler likely refuses |
| 2011 | # this option. If you want to compile ctypes with the Sun |
| 2012 | # compiler, please research a proper solution, instead of |
| 2013 | # finding some -z option for the Sun compiler. |
| 2014 | extra_link_args.append('-mimpure-text') |
| 2015 | |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2016 | elif HOST_PLATFORM.startswith('hp-ux'): |
Thomas Heller | 3eaaeb4 | 2008-05-23 17:26:46 +0000 | [diff] [blame] | 2017 | extra_link_args.append('-fPIC') |
| 2018 | |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 2019 | ext = Extension('_ctypes', |
| 2020 | include_dirs=include_dirs, |
| 2021 | extra_compile_args=extra_compile_args, |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 2022 | extra_link_args=extra_link_args, |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 2023 | libraries=[], |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 2024 | sources=sources, |
| 2025 | depends=depends) |
Victor Stinner | cfe172d | 2019-03-01 18:21:49 +0100 | [diff] [blame] | 2026 | self.add(ext) |
| 2027 | if TEST_EXTENSIONS: |
| 2028 | # function my_sqrt() needs libm for sqrt() |
| 2029 | self.add(Extension('_ctypes_test', |
| 2030 | sources=['_ctypes/_ctypes_test.c'], |
| 2031 | libraries=['m'])) |
Thomas Heller | cf567c1 | 2006-03-08 19:51:58 +0000 | [diff] [blame] | 2032 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2033 | ffi_inc_dirs = self.inc_dirs.copy() |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2034 | if MACOS: |
Zachary Ware | 935043d | 2016-09-09 17:01:21 -0700 | [diff] [blame] | 2035 | if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"): |
| 2036 | return |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 2037 | # OS X 10.5 comes with libffi.dylib; the include files are |
| 2038 | # in /usr/include/ffi |
Victor Stinner | 96d8158 | 2019-03-01 13:53:46 +0100 | [diff] [blame] | 2039 | ffi_inc_dirs.append('/usr/include/ffi') |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 2040 | |
Benjamin Peterson | d78735d | 2010-01-01 16:04:23 +0000 | [diff] [blame] | 2041 | ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] |
Matthias Klose | 5a204fe | 2010-04-21 21:47:45 +0000 | [diff] [blame] | 2042 | if not ffi_inc or ffi_inc[0] == '': |
Victor Stinner | 96d8158 | 2019-03-01 13:53:46 +0100 | [diff] [blame] | 2043 | ffi_inc = find_file('ffi.h', [], ffi_inc_dirs) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 2044 | if ffi_inc is not None: |
| 2045 | ffi_h = ffi_inc[0] + '/ffi.h' |
Shlomi Fish | 6d51b87 | 2017-09-06 23:19:19 +0300 | [diff] [blame] | 2046 | if not os.path.exists(ffi_h): |
| 2047 | ffi_inc = None |
| 2048 | print('Header file {} does not exist'.format(ffi_h)) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 2049 | ffi_lib = None |
| 2050 | if ffi_inc is not None: |
doko@ubuntu.com | ae68365 | 2016-06-05 01:38:29 +0200 | [diff] [blame] | 2051 | for lib_name in ('ffi', 'ffi_pic'): |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2052 | if (self.compiler.find_library_file(self.lib_dirs, lib_name)): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 2053 | ffi_lib = lib_name |
| 2054 | break |
| 2055 | |
| 2056 | if ffi_inc and ffi_lib: |
| 2057 | ext.include_dirs.extend(ffi_inc) |
| 2058 | ext.libraries.append(ffi_lib) |
| 2059 | self.use_system_libffi = True |
| 2060 | |
Christian Heimes | 5bb9692 | 2018-02-25 10:22:14 +0100 | [diff] [blame] | 2061 | if sysconfig.get_config_var('HAVE_LIBDL'): |
| 2062 | # for dlopen, see bpo-32647 |
| 2063 | ext.libraries.append('dl') |
| 2064 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 2065 | def detect_decimal(self): |
| 2066 | # Stefan Krah's _decimal module |
Stefan Krah | 60187b5 | 2012-03-23 19:06:27 +0100 | [diff] [blame] | 2067 | extra_compile_args = [] |
Stefan Krah | a10e2fb | 2012-09-01 14:21:22 +0200 | [diff] [blame] | 2068 | undef_macros = [] |
Stefan Krah | 60187b5 | 2012-03-23 19:06:27 +0100 | [diff] [blame] | 2069 | if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): |
| 2070 | include_dirs = [] |
Stefan Krah | 45059eb | 2013-11-24 19:44:57 +0100 | [diff] [blame] | 2071 | libraries = [':libmpdec.so.2'] |
Stefan Krah | 60187b5 | 2012-03-23 19:06:27 +0100 | [diff] [blame] | 2072 | sources = ['_decimal/_decimal.c'] |
| 2073 | depends = ['_decimal/docstrings.h'] |
| 2074 | else: |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2075 | include_dirs = [os.path.abspath(os.path.join(self.srcdir, |
Ned Deily | 458a6fb | 2012-04-01 02:30:46 -0700 | [diff] [blame] | 2076 | 'Modules', |
| 2077 | '_decimal', |
| 2078 | 'libmpdec'))] |
Stefan Krah | bd4ed77 | 2017-12-06 18:24:17 +0100 | [diff] [blame] | 2079 | libraries = ['m'] |
Stefan Krah | 60187b5 | 2012-03-23 19:06:27 +0100 | [diff] [blame] | 2080 | sources = [ |
| 2081 | '_decimal/_decimal.c', |
| 2082 | '_decimal/libmpdec/basearith.c', |
| 2083 | '_decimal/libmpdec/constants.c', |
| 2084 | '_decimal/libmpdec/context.c', |
| 2085 | '_decimal/libmpdec/convolute.c', |
| 2086 | '_decimal/libmpdec/crt.c', |
| 2087 | '_decimal/libmpdec/difradix2.c', |
| 2088 | '_decimal/libmpdec/fnt.c', |
| 2089 | '_decimal/libmpdec/fourstep.c', |
| 2090 | '_decimal/libmpdec/io.c', |
| 2091 | '_decimal/libmpdec/memory.c', |
| 2092 | '_decimal/libmpdec/mpdecimal.c', |
| 2093 | '_decimal/libmpdec/numbertheory.c', |
| 2094 | '_decimal/libmpdec/sixstep.c', |
| 2095 | '_decimal/libmpdec/transpose.c', |
| 2096 | ] |
| 2097 | depends = [ |
| 2098 | '_decimal/docstrings.h', |
| 2099 | '_decimal/libmpdec/basearith.h', |
| 2100 | '_decimal/libmpdec/bits.h', |
| 2101 | '_decimal/libmpdec/constants.h', |
| 2102 | '_decimal/libmpdec/convolute.h', |
| 2103 | '_decimal/libmpdec/crt.h', |
| 2104 | '_decimal/libmpdec/difradix2.h', |
| 2105 | '_decimal/libmpdec/fnt.h', |
| 2106 | '_decimal/libmpdec/fourstep.h', |
| 2107 | '_decimal/libmpdec/io.h', |
Stefan Krah | 8d013a8 | 2016-04-26 16:34:41 +0200 | [diff] [blame] | 2108 | '_decimal/libmpdec/mpalloc.h', |
Stefan Krah | 60187b5 | 2012-03-23 19:06:27 +0100 | [diff] [blame] | 2109 | '_decimal/libmpdec/mpdecimal.h', |
| 2110 | '_decimal/libmpdec/numbertheory.h', |
| 2111 | '_decimal/libmpdec/sixstep.h', |
| 2112 | '_decimal/libmpdec/transpose.h', |
| 2113 | '_decimal/libmpdec/typearith.h', |
| 2114 | '_decimal/libmpdec/umodarith.h', |
| 2115 | ] |
| 2116 | |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2117 | config = { |
| 2118 | 'x64': [('CONFIG_64','1'), ('ASM','1')], |
| 2119 | 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')], |
| 2120 | 'ansi64': [('CONFIG_64','1'), ('ANSI','1')], |
| 2121 | 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')], |
| 2122 | 'ansi32': [('CONFIG_32','1'), ('ANSI','1')], |
| 2123 | 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'), |
| 2124 | ('LEGACY_COMPILER','1')], |
| 2125 | 'universal': [('UNIVERSAL','1')] |
| 2126 | } |
| 2127 | |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2128 | cc = sysconfig.get_config_var('CC') |
| 2129 | sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T') |
| 2130 | machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE') |
| 2131 | |
| 2132 | if machine: |
| 2133 | # Override automatic configuration to facilitate testing. |
| 2134 | define_macros = config[machine] |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2135 | elif MACOS: |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2136 | # Universal here means: build with the same options Python |
| 2137 | # was built with. |
| 2138 | define_macros = config['universal'] |
| 2139 | elif sizeof_size_t == 8: |
| 2140 | if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'): |
| 2141 | define_macros = config['x64'] |
| 2142 | elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'): |
| 2143 | define_macros = config['uint128'] |
| 2144 | else: |
| 2145 | define_macros = config['ansi64'] |
| 2146 | elif sizeof_size_t == 4: |
| 2147 | ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87') |
| 2148 | if ppro and ('gcc' in cc or 'clang' in cc) and \ |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2149 | not 'sunos' in HOST_PLATFORM: |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2150 | # solaris: problems with register allocation. |
| 2151 | # icc >= 11.0 works as well. |
| 2152 | define_macros = config['ppro'] |
Stefan Krah | ce23dbc | 2012-09-30 21:12:53 +0200 | [diff] [blame] | 2153 | extra_compile_args.append('-Wno-unknown-pragmas') |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2154 | else: |
| 2155 | define_macros = config['ansi32'] |
| 2156 | else: |
| 2157 | raise DistutilsError("_decimal: unsupported architecture") |
| 2158 | |
| 2159 | # Workarounds for toolchain bugs: |
| 2160 | if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'): |
| 2161 | # Some versions of gcc miscompile inline asm: |
| 2162 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 |
| 2163 | # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html |
| 2164 | extra_compile_args.append('-fno-ipa-pure-const') |
| 2165 | if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'): |
| 2166 | # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: |
| 2167 | # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html |
| 2168 | undef_macros.append('_FORTIFY_SOURCE') |
| 2169 | |
Stefan Krah | 1919b7e | 2012-03-21 18:25:23 +0100 | [diff] [blame] | 2170 | # Uncomment for extra functionality: |
| 2171 | #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2172 | self.add(Extension('_decimal', |
| 2173 | include_dirs=include_dirs, |
| 2174 | libraries=libraries, |
| 2175 | define_macros=define_macros, |
| 2176 | undef_macros=undef_macros, |
| 2177 | extra_compile_args=extra_compile_args, |
| 2178 | sources=sources, |
| 2179 | depends=depends)) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 2180 | |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 2181 | def detect_openssl_hashlib(self): |
| 2182 | # Detect SSL support for the socket module (via _ssl) |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2183 | config_vars = sysconfig.get_config_vars() |
| 2184 | |
| 2185 | def split_var(name, sep): |
| 2186 | # poor man's shlex, the re module is not available yet. |
| 2187 | value = config_vars.get(name) |
| 2188 | if not value: |
| 2189 | return () |
| 2190 | # This trick works because ax_check_openssl uses --libs-only-L, |
| 2191 | # --libs-only-l, and --cflags-only-I. |
| 2192 | value = ' ' + value |
| 2193 | sep = ' ' + sep |
| 2194 | return [v.strip() for v in value.split(sep) if v.strip()] |
| 2195 | |
| 2196 | openssl_includes = split_var('OPENSSL_INCLUDES', '-I') |
| 2197 | openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L') |
| 2198 | openssl_libs = split_var('OPENSSL_LIBS', '-l') |
| 2199 | if not openssl_libs: |
| 2200 | # libssl and libcrypto not found |
Christian Heimes | 8abc3f4 | 2019-04-09 18:40:12 +0200 | [diff] [blame] | 2201 | self.missing.extend(['_ssl', '_hashlib']) |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2202 | return None, None |
| 2203 | |
| 2204 | # Find OpenSSL includes |
| 2205 | ssl_incs = find_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2206 | 'openssl/ssl.h', self.inc_dirs, openssl_includes |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2207 | ) |
| 2208 | if ssl_incs is None: |
Christian Heimes | 8abc3f4 | 2019-04-09 18:40:12 +0200 | [diff] [blame] | 2209 | self.missing.extend(['_ssl', '_hashlib']) |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2210 | return None, None |
| 2211 | |
| 2212 | # OpenSSL 1.0.2 uses Kerberos for KRB5 ciphers |
| 2213 | krb5_h = find_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2214 | 'krb5.h', self.inc_dirs, |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2215 | ['/usr/kerberos/include'] |
| 2216 | ) |
| 2217 | if krb5_h: |
| 2218 | ssl_incs.extend(krb5_h) |
| 2219 | |
Christian Heimes | 61d478c | 2018-01-27 15:51:38 +0100 | [diff] [blame] | 2220 | if config_vars.get("HAVE_X509_VERIFY_PARAM_SET1_HOST"): |
Christian Heimes | c7f7069 | 2019-05-31 11:44:05 +0200 | [diff] [blame] | 2221 | self.add(Extension( |
| 2222 | '_ssl', ['_ssl.c'], |
| 2223 | include_dirs=openssl_includes, |
| 2224 | library_dirs=openssl_libdirs, |
| 2225 | libraries=openssl_libs, |
| 2226 | depends=['socketmodule.h', '_ssl/debughelpers.c']) |
| 2227 | ) |
Christian Heimes | 61d478c | 2018-01-27 15:51:38 +0100 | [diff] [blame] | 2228 | else: |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2229 | self.missing.append('_ssl') |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2230 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2231 | self.add(Extension('_hashlib', ['_hashopenssl.c'], |
| 2232 | depends=['hashlib.h'], |
| 2233 | include_dirs=openssl_includes, |
| 2234 | library_dirs=openssl_libdirs, |
| 2235 | libraries=openssl_libs)) |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2236 | |
xdegaye | 2ee077f | 2019-04-09 17:20:08 +0200 | [diff] [blame] | 2237 | def detect_hash_builtins(self): |
Victor Stinner | 5ec33a1 | 2019-03-01 16:43:28 +0100 | [diff] [blame] | 2238 | # We always compile these even when OpenSSL is available (issue #14693). |
| 2239 | # It's harmless and the object code is tiny (40-50 KiB per module, |
| 2240 | # only loaded when actually used). |
| 2241 | self.add(Extension('_sha256', ['sha256module.c'], |
| 2242 | depends=['hashlib.h'])) |
| 2243 | self.add(Extension('_sha512', ['sha512module.c'], |
| 2244 | depends=['hashlib.h'])) |
| 2245 | self.add(Extension('_md5', ['md5module.c'], |
| 2246 | depends=['hashlib.h'])) |
| 2247 | self.add(Extension('_sha1', ['sha1module.c'], |
| 2248 | depends=['hashlib.h'])) |
| 2249 | |
| 2250 | blake2_deps = glob(os.path.join(self.srcdir, |
| 2251 | 'Modules/_blake2/impl/*')) |
| 2252 | blake2_deps.append('hashlib.h') |
| 2253 | |
| 2254 | self.add(Extension('_blake2', |
| 2255 | ['_blake2/blake2module.c', |
| 2256 | '_blake2/blake2b_impl.c', |
| 2257 | '_blake2/blake2s_impl.c'], |
| 2258 | depends=blake2_deps)) |
| 2259 | |
| 2260 | sha3_deps = glob(os.path.join(self.srcdir, |
| 2261 | 'Modules/_sha3/kcp/*')) |
| 2262 | sha3_deps.append('hashlib.h') |
| 2263 | self.add(Extension('_sha3', |
| 2264 | ['_sha3/sha3module.c'], |
| 2265 | depends=sha3_deps)) |
| 2266 | |
| 2267 | def detect_nis(self): |
Victor Stinner | 4cbea51 | 2019-02-28 17:48:38 +0100 | [diff] [blame] | 2268 | if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6': |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2269 | self.missing.append('nis') |
| 2270 | return |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2271 | |
| 2272 | libs = [] |
| 2273 | library_dirs = [] |
| 2274 | includes_dirs = [] |
| 2275 | |
| 2276 | # bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28 |
| 2277 | # moved headers and libraries to libtirpc and libnsl. The headers |
| 2278 | # are in tircp and nsl sub directories. |
| 2279 | rpcsvc_inc = find_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2280 | 'rpcsvc/yp_prot.h', self.inc_dirs, |
| 2281 | [os.path.join(inc_dir, 'nsl') for inc_dir in self.inc_dirs] |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2282 | ) |
| 2283 | rpc_inc = find_file( |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2284 | 'rpc/rpc.h', self.inc_dirs, |
| 2285 | [os.path.join(inc_dir, 'tirpc') for inc_dir in self.inc_dirs] |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2286 | ) |
| 2287 | if rpcsvc_inc is None or rpc_inc is None: |
| 2288 | # not found |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2289 | self.missing.append('nis') |
| 2290 | return |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2291 | includes_dirs.extend(rpcsvc_inc) |
| 2292 | includes_dirs.extend(rpc_inc) |
| 2293 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2294 | if self.compiler.find_library_file(self.lib_dirs, 'nsl'): |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2295 | libs.append('nsl') |
| 2296 | else: |
| 2297 | # libnsl-devel: check for libnsl in nsl/ subdirectory |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2298 | nsl_dirs = [os.path.join(lib_dir, 'nsl') for lib_dir in self.lib_dirs] |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2299 | libnsl = self.compiler.find_library_file(nsl_dirs, 'nsl') |
| 2300 | if libnsl is not None: |
| 2301 | library_dirs.append(os.path.dirname(libnsl)) |
| 2302 | libs.append('nsl') |
| 2303 | |
Victor Stinner | 625dbf2 | 2019-03-01 15:59:39 +0100 | [diff] [blame] | 2304 | if self.compiler.find_library_file(self.lib_dirs, 'tirpc'): |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2305 | libs.append('tirpc') |
| 2306 | |
Victor Stinner | 8058bda | 2019-03-01 15:31:45 +0100 | [diff] [blame] | 2307 | self.add(Extension('nis', ['nismodule.c'], |
| 2308 | libraries=libs, |
| 2309 | library_dirs=library_dirs, |
| 2310 | include_dirs=includes_dirs)) |
Christian Heimes | 29a7df7 | 2018-01-26 23:28:46 +0100 | [diff] [blame] | 2311 | |
Christian Heimes | ff5be6e | 2018-01-20 13:19:21 +0100 | [diff] [blame] | 2312 | |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 2313 | class PyBuildInstall(install): |
| 2314 | # Suppress the warning about installation into the lib_dynload |
| 2315 | # directory, which is not in sys.path when running Python during |
| 2316 | # installation: |
| 2317 | def initialize_options (self): |
| 2318 | install.initialize_options(self) |
| 2319 | self.warn_dir=0 |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 2320 | |
Éric Araujo | e6792c1 | 2011-06-09 14:07:02 +0200 | [diff] [blame] | 2321 | # Customize subcommands to not install an egg-info file for Python |
| 2322 | sub_commands = [('install_lib', install.has_lib), |
| 2323 | ('install_headers', install.has_headers), |
| 2324 | ('install_scripts', install.has_scripts), |
| 2325 | ('install_data', install.has_data)] |
| 2326 | |
| 2327 | |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2328 | class PyBuildInstallLib(install_lib): |
| 2329 | # Do exactly what install_lib does but make sure correct access modes get |
| 2330 | # set on installed directories and files. All installed files with get |
| 2331 | # mode 644 unless they are a shared library in which case they will get |
| 2332 | # mode 755. All installed directories will get mode 755. |
| 2333 | |
doko@ubuntu.com | d5537d0 | 2013-03-21 13:21:49 -0700 | [diff] [blame] | 2334 | # this is works for EXT_SUFFIX too, which ends with SHLIB_SUFFIX |
| 2335 | shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX") |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2336 | |
| 2337 | def install(self): |
| 2338 | outfiles = install_lib.install(self) |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 2339 | self.set_file_modes(outfiles, 0o644, 0o755) |
| 2340 | self.set_dir_modes(self.install_dir, 0o755) |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2341 | return outfiles |
| 2342 | |
| 2343 | def set_file_modes(self, files, defaultMode, sharedLibMode): |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2344 | if not files: return |
| 2345 | |
| 2346 | for filename in files: |
| 2347 | if os.path.islink(filename): continue |
| 2348 | mode = defaultMode |
doko@ubuntu.com | d5537d0 | 2013-03-21 13:21:49 -0700 | [diff] [blame] | 2349 | if filename.endswith(self.shlib_suffix): mode = sharedLibMode |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2350 | log.info("changing mode of %s to %o", filename, mode) |
| 2351 | if not self.dry_run: os.chmod(filename, mode) |
| 2352 | |
| 2353 | def set_dir_modes(self, dirname, mode): |
Amaury Forgeot d'Arc | 321e533 | 2009-07-02 23:08:45 +0000 | [diff] [blame] | 2354 | for dirpath, dirnames, fnames in os.walk(dirname): |
| 2355 | if os.path.islink(dirpath): |
| 2356 | continue |
| 2357 | log.info("changing mode of %s to %o", dirpath, mode) |
| 2358 | if not self.dry_run: os.chmod(dirpath, mode) |
Michael W. Hudson | 529a505 | 2002-12-17 16:47:17 +0000 | [diff] [blame] | 2359 | |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 2360 | |
Georg Brandl | ff52f76 | 2010-12-28 09:51:43 +0000 | [diff] [blame] | 2361 | class PyBuildScripts(build_scripts): |
| 2362 | def copy_scripts(self): |
| 2363 | outfiles, updated_files = build_scripts.copy_scripts(self) |
| 2364 | fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info) |
| 2365 | minoronly = '.{0[1]}'.format(sys.version_info) |
| 2366 | newoutfiles = [] |
| 2367 | newupdated_files = [] |
| 2368 | for filename in outfiles: |
Brett Cannon | a8c3424 | 2018-04-20 14:15:40 -0700 | [diff] [blame] | 2369 | if filename.endswith('2to3'): |
Georg Brandl | ff52f76 | 2010-12-28 09:51:43 +0000 | [diff] [blame] | 2370 | newfilename = filename + fullversion |
| 2371 | else: |
| 2372 | newfilename = filename + minoronly |
Vinay Sajip | dd917f8 | 2016-08-31 08:22:29 +0100 | [diff] [blame] | 2373 | log.info('renaming %s to %s', filename, newfilename) |
Georg Brandl | ff52f76 | 2010-12-28 09:51:43 +0000 | [diff] [blame] | 2374 | os.rename(filename, newfilename) |
| 2375 | newoutfiles.append(newfilename) |
| 2376 | if filename in updated_files: |
| 2377 | newupdated_files.append(newfilename) |
| 2378 | return newoutfiles, newupdated_files |
| 2379 | |
Guido van Rossum | 14ee89c | 2003-02-20 02:52:04 +0000 | [diff] [blame] | 2380 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 2381 | def main(): |
Victor Stinner | c991f24 | 2019-03-01 17:19:04 +0100 | [diff] [blame] | 2382 | set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST') |
| 2383 | set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST') |
| 2384 | |
| 2385 | class DummyProcess: |
| 2386 | """Hack for parallel build""" |
| 2387 | ProcessPoolExecutor = None |
| 2388 | |
| 2389 | sys.modules['concurrent.futures.process'] = DummyProcess |
| 2390 | |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 2391 | # turn off warnings when deprecated modules are imported |
| 2392 | import warnings |
| 2393 | warnings.filterwarnings("ignore",category=DeprecationWarning) |
Guido van Rossum | 14ee89c | 2003-02-20 02:52:04 +0000 | [diff] [blame] | 2394 | setup(# PyPI Metadata (PEP 301) |
| 2395 | name = "Python", |
| 2396 | version = sys.version.split()[0], |
Serhiy Storchaka | 885bdc4 | 2016-02-11 13:10:36 +0200 | [diff] [blame] | 2397 | url = "http://www.python.org/%d.%d" % sys.version_info[:2], |
Guido van Rossum | 14ee89c | 2003-02-20 02:52:04 +0000 | [diff] [blame] | 2398 | maintainer = "Guido van Rossum and the Python community", |
| 2399 | maintainer_email = "python-dev@python.org", |
| 2400 | description = "A high-level object-oriented programming language", |
| 2401 | long_description = SUMMARY.strip(), |
| 2402 | license = "PSF license", |
Guido van Rossum | c1f779c | 2007-07-03 08:25:58 +0000 | [diff] [blame] | 2403 | classifiers = [x for x in CLASSIFIERS.split("\n") if x], |
Guido van Rossum | 14ee89c | 2003-02-20 02:52:04 +0000 | [diff] [blame] | 2404 | platforms = ["Many"], |
| 2405 | |
| 2406 | # Build info |
Georg Brandl | ff52f76 | 2010-12-28 09:51:43 +0000 | [diff] [blame] | 2407 | cmdclass = {'build_ext': PyBuildExt, |
| 2408 | 'build_scripts': PyBuildScripts, |
| 2409 | 'install': PyBuildInstall, |
| 2410 | 'install_lib': PyBuildInstallLib}, |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 2411 | # The struct module is defined here, because build_ext won't be |
| 2412 | # called unless there's at least one extension module defined. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 2413 | ext_modules=[Extension('_struct', ['_struct.c'])], |
Andrew M. Kuchling | aece427 | 2001-02-28 20:56:49 +0000 | [diff] [blame] | 2414 | |
Georg Brandl | ff52f76 | 2010-12-28 09:51:43 +0000 | [diff] [blame] | 2415 | # If you change the scripts installed here, you also need to |
| 2416 | # check the PyBuildScripts command above, and change the links |
| 2417 | # created by the bininstall target in Makefile.pre.in |
Benjamin Peterson | dfea192 | 2009-05-23 17:13:14 +0000 | [diff] [blame] | 2418 | scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", |
Brett Cannon | a8c3424 | 2018-04-20 14:15:40 -0700 | [diff] [blame] | 2419 | "Tools/scripts/2to3"] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 2420 | ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 2421 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 2422 | # --install-platlib |
| 2423 | if __name__ == '__main__': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 2424 | main() |