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