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