blob: bf90600eaad38a76352d891346b38a28ec9f0096 [file] [log] [blame]
Andrew M. Kuchling66012fe2001-01-26 21:56:581# Autodetecting setup.py script for building the Python extensions
2#
Fredrik Lundhade711a2001-01-24 08:00:283
Brett Cannonca5ff3a2013-06-15 21:52:594import sys, os, importlib.machinery, re, optparse
Christian Heimesaf98da12008-01-27 15:18:185from glob import glob
Eric Snow335e14d2014-01-04 22:09:286import importlib._bootstrap
7import importlib.util
Tarek Ziadéedacea32010-01-29 11:41:038import sysconfig
Michael W. Hudson529a5052002-12-17 16:47:179
10from distutils import log
Marc-André Lemburg7c6fcda2001-01-26 18:03:2411from distutils.errors import *
Andrew M. Kuchling00e0f212001-01-17 15:23:2312from distutils.core import Extension, setup
13from distutils.command.build_ext import build_ext
Andrew M. Kuchlingf52d27e2001-05-21 20:29:2714from distutils.command.install import install
Michael W. Hudson529a5052002-12-17 16:47:1715from distutils.command.install_lib import install_lib
Georg Brandlff52f762010-12-28 09:51:4316from distutils.command.build_scripts import build_scripts
Stefan Krah095b2732010-06-08 13:41:4417from distutils.spawn import find_executable
Andrew M. Kuchling00e0f212001-01-17 15:23:2318
doko@ubuntu.com1abe1c52012-06-30 18:42:4519cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
20
Victor Stinner0198f522018-12-20 15:03:0121# Set common compiler and linker flags derived from the Makefile,
22# reserved for building the interpreter and the stdlib modules.
23# See bpo-21121 and bpo-35257
24def set_compiler_flags(compiler_flags, compiler_py_flags_nodist):
25 flags = sysconfig.get_config_var(compiler_flags)
26 py_flags_nodist = sysconfig.get_config_var(compiler_py_flags_nodist)
27 sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist
28
29set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST')
30set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST')
Benjamin Petersonacb8c522014-08-10 03:01:4931
Antoine Pitrou2c0a9162014-09-26 21:31:5932class Dummy:
33 """Hack for parallel build"""
34 ProcessPoolExecutor = None
35sys.modules['concurrent.futures.process'] = Dummy
36
doko@ubuntu.com93df16b2012-06-30 12:32:0837def get_platform():
doko@ubuntu.com1abe1c52012-06-30 18:42:4538 # cross build
39 if "_PYTHON_HOST_PLATFORM" in os.environ:
40 return os.environ["_PYTHON_HOST_PLATFORM"]
doko@ubuntu.com93df16b2012-06-30 12:32:0841 # Get value of sys.platform
42 if sys.platform.startswith('osf1'):
43 return 'osf1'
44 return sys.platform
45host_platform = get_platform()
46
Gregory P. Smithb04ded42010-01-03 00:38:1047# Were we compiled --with-pydebug or with #define Py_DEBUG?
doko@ubuntu.com1abe1c52012-06-30 18:42:4548COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
Gregory P. Smithb04ded42010-01-03 00:38:1049
Andrew M. Kuchling00e0f212001-01-17 15:23:2350# This global variable is used to hold the list of modules to be disabled.
51disabled_module_list = []
52
Michael W. Hudson39230b32002-01-16 15:26:4853def add_dir_to_list(dirlist, dir):
Barry Warsaw807bd0a2010-11-24 20:30:0054 """Add the directory 'dir' to the list 'dirlist' (after any relative
55 directories) if:
56
Michael W. Hudson39230b32002-01-16 15:26:4857 1) 'dir' is not already in 'dirlist'
Barry Warsaw807bd0a2010-11-24 20:30:0058 2) 'dir' actually exists, and is a directory.
59 """
60 if dir is None or not os.path.isdir(dir) or dir in dirlist:
61 return
62 for i, path in enumerate(dirlist):
63 if not os.path.isabs(path):
64 dirlist.insert(i + 1, dir)
Barry Warsaw34520cd2010-11-27 20:03:0365 return
66 dirlist.insert(0, dir)
Michael W. Hudson39230b32002-01-16 15:26:4867
xdegaye77f51392017-11-25 16:25:3068def sysroot_paths(make_vars, subdirs):
69 """Get the paths of sysroot sub-directories.
70
71 * make_vars: a sequence of names of variables of the Makefile where
72 sysroot may be set.
73 * subdirs: a sequence of names of subdirectories used as the location for
74 headers or libraries.
75 """
76
77 dirs = []
78 for var_name in make_vars:
79 var = sysconfig.get_config_var(var_name)
80 if var is not None:
81 m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var)
82 if m is not None:
83 sysroot = m.group(1).strip('"')
84 for subdir in subdirs:
85 if os.path.isabs(subdir):
86 subdir = subdir[1:]
87 path = os.path.join(sysroot, subdir)
88 if os.path.isdir(path):
89 dirs.append(path)
90 break
91 return dirs
92
Ned Deilyc7302112019-06-18 20:28:1393MACOS_SDK_ROOT = None
94
Ronald Oussoren2c12ab12010-06-03 14:42:2595def macosx_sdk_root():
Ned Deilyc7302112019-06-18 20:28:1396 """Return the directory of the current macOS SDK.
97
98 If no SDK was explicitly configured, call the compiler to find which
99 include files paths are being searched by default. Use '/' if the
100 compiler is searching /usr/include (meaning system header files are
101 installed) or use the root of an SDK if that is being searched.
102 (The SDK may be supplied via Xcode or via the Command Line Tools).
103 The SDK paths used by Apple-supplied tool chains depend on the
104 setting of various variables; see the xcrun man page for more info.
Ronald Oussoren2c12ab12010-06-03 14:42:25105 """
Ned Deilyc7302112019-06-18 20:28:13106 global MACOS_SDK_ROOT
107
108 # If already called, return cached result.
109 if MACOS_SDK_ROOT:
110 return MACOS_SDK_ROOT
111
Ronald Oussoren2c12ab12010-06-03 14:42:25112 cflags = sysconfig.get_config_var('CFLAGS')
Miss Islington (bot)e7f86842020-04-22 16:27:24113 m = re.search(r'-isysroot\s*(\S+)', cflags)
Ned Deilyc7302112019-06-18 20:28:13114 if m is not None:
115 MACOS_SDK_ROOT = m.group(1)
Ronald Oussoren2c12ab12010-06-03 14:42:25116 else:
Ned Deilyc7302112019-06-18 20:28:13117 MACOS_SDK_ROOT = '/'
118 cc = sysconfig.get_config_var('CC')
119 tmpfile = '/tmp/setup_sdk_root.%d' % os.getpid()
120 try:
121 os.unlink(tmpfile)
122 except:
123 pass
124 ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
125 in_incdirs = False
126 try:
127 if ret >> 8 == 0:
128 with open(tmpfile) as fp:
129 for line in fp.readlines():
130 if line.startswith("#include <...>"):
131 in_incdirs = True
132 elif line.startswith("End of search list"):
133 in_incdirs = False
134 elif in_incdirs:
135 line = line.strip()
136 if line == '/usr/include':
137 MACOS_SDK_ROOT = '/'
138 elif line.endswith(".sdk/usr/include"):
139 MACOS_SDK_ROOT = line[:-12]
140 finally:
141 os.unlink(tmpfile)
142
143 return MACOS_SDK_ROOT
Ronald Oussoren2c12ab12010-06-03 14:42:25144
145def is_macosx_sdk_path(path):
146 """
147 Returns True if 'path' can be located in an OSX SDK
148 """
Ned Deily2910a7b2012-07-30 09:35:58149 return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
150 or path.startswith('/System/')
151 or path.startswith('/Library/') )
Ronald Oussoren2c12ab12010-06-03 14:42:25152
Andrew M. Kuchlingfbe73762001-01-18 18:44:20153def find_file(filename, std_dirs, paths):
154 """Searches for the directory where a given file is located,
155 and returns a possibly-empty list of additional directories, or None
156 if the file couldn't be found at all.
Fredrik Lundhade711a2001-01-24 08:00:28157
Andrew M. Kuchlingfbe73762001-01-18 18:44:20158 'filename' is the name of a file, such as readline.h or libcrypto.a.
159 'std_dirs' is the list of standard system directories; if the
160 file is found in one of them, no additional directives are needed.
161 'paths' is a list of additional locations to check; if the file is
162 found in one of them, the resulting list will contain the directory.
163 """
doko@ubuntu.com93df16b2012-06-30 12:32:08164 if host_platform == 'darwin':
Ronald Oussoren2c12ab12010-06-03 14:42:25165 # Honor the MacOSX SDK setting when one was specified.
166 # An SDK is a directory with the same structure as a real
167 # system, but with only header files and libraries.
168 sysroot = macosx_sdk_root()
Andrew M. Kuchlingfbe73762001-01-18 18:44:20169
170 # Check the standard locations
171 for dir in std_dirs:
172 f = os.path.join(dir, filename)
Ronald Oussoren2c12ab12010-06-03 14:42:25173
doko@ubuntu.com93df16b2012-06-30 12:32:08174 if host_platform == 'darwin' and is_macosx_sdk_path(dir):
Ronald Oussoren2c12ab12010-06-03 14:42:25175 f = os.path.join(sysroot, dir[1:], filename)
176
Andrew M. Kuchlingfbe73762001-01-18 18:44:20177 if os.path.exists(f): return []
178
179 # Check the additional directories
180 for dir in paths:
181 f = os.path.join(dir, filename)
Ronald Oussoren2c12ab12010-06-03 14:42:25182
doko@ubuntu.com93df16b2012-06-30 12:32:08183 if host_platform == 'darwin' and is_macosx_sdk_path(dir):
Ronald Oussoren2c12ab12010-06-03 14:42:25184 f = os.path.join(sysroot, dir[1:], filename)
185
Andrew M. Kuchlingfbe73762001-01-18 18:44:20186 if os.path.exists(f):
187 return [dir]
188
189 # Not found anywhere
Andrew M. Kuchling00e0f212001-01-17 15:23:23190 return None
191
Andrew M. Kuchlingfbe73762001-01-18 18:44:20192def find_library_file(compiler, libname, std_dirs, paths):
Andrew M. Kuchlinga246d9f2002-11-27 13:43:46193 result = compiler.find_library_file(std_dirs + paths, libname)
194 if result is None:
195 return None
Fredrik Lundhade711a2001-01-24 08:00:28196
doko@ubuntu.com93df16b2012-06-30 12:32:08197 if host_platform == 'darwin':
Ronald Oussoren2c12ab12010-06-03 14:42:25198 sysroot = macosx_sdk_root()
199
Andrew M. Kuchlinga246d9f2002-11-27 13:43:46200 # Check whether the found file is in one of the standard directories
201 dirname = os.path.dirname(result)
202 for p in std_dirs:
203 # Ensure path doesn't end with path separator
Skip Montanaro9f5178a2003-05-06 20:59:57204 p = p.rstrip(os.sep)
Ronald Oussoren2c12ab12010-06-03 14:42:25205
doko@ubuntu.com93df16b2012-06-30 12:32:08206 if host_platform == 'darwin' and is_macosx_sdk_path(p):
Ned Deily020250f2016-02-24 13:56:38207 # Note that, as of Xcode 7, Apple SDKs may contain textual stub
208 # libraries with .tbd extensions rather than the normal .dylib
209 # shared libraries installed in /. The Apple compiler tool
210 # chain handles this transparently but it can cause problems
211 # for programs that are being built with an SDK and searching
212 # for specific libraries. Distutils find_library_file() now
213 # knows to also search for and return .tbd files. But callers
214 # of find_library_file need to keep in mind that the base filename
215 # of the returned SDK library file might have a different extension
216 # from that of the library file installed on the running system,
217 # for example:
218 # /Applications/Xcode.app/Contents/Developer/Platforms/
219 # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/
220 # usr/lib/libedit.tbd
221 # vs
222 # /usr/lib/libedit.dylib
Ronald Oussoren2c12ab12010-06-03 14:42:25223 if os.path.join(sysroot, p[1:]) == dirname:
224 return [ ]
225
Andrew M. Kuchlinga246d9f2002-11-27 13:43:46226 if p == dirname:
227 return [ ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:20228
Andrew M. Kuchlinga246d9f2002-11-27 13:43:46229 # Otherwise, it must have been in one of the additional directories,
230 # so we have to figure out which one.
231 for p in paths:
232 # Ensure path doesn't end with path separator
Skip Montanaro9f5178a2003-05-06 20:59:57233 p = p.rstrip(os.sep)
Ronald Oussoren2c12ab12010-06-03 14:42:25234
doko@ubuntu.com93df16b2012-06-30 12:32:08235 if host_platform == 'darwin' and is_macosx_sdk_path(p):
Ronald Oussoren2c12ab12010-06-03 14:42:25236 if os.path.join(sysroot, p[1:]) == dirname:
237 return [ p ]
238
Andrew M. Kuchlinga246d9f2002-11-27 13:43:46239 if p == dirname:
240 return [p]
241 else:
242 assert False, "Internal error: Path not found in std_dirs or paths"
Tim Peters2c60f7a2003-01-29 03:49:43243
Andrew M. Kuchling00e0f212001-01-17 15:23:23244def module_enabled(extlist, modname):
245 """Returns whether the module 'modname' is present in the list
246 of extensions 'extlist'."""
247 extlist = [ext for ext in extlist if ext.name == modname]
248 return len(extlist)
Fredrik Lundhade711a2001-01-24 08:00:28249
Jack Jansen144ebcc2001-08-05 22:31:19250def find_module_file(module, dirlist):
251 """Find a module in a set of possible folders. If it is not found
252 return the unadorned filename"""
253 list = find_file(module, [], dirlist)
254 if not list:
255 return module
256 if len(list) > 1:
Vinay Sajipdd917f82016-08-31 07:22:29257 log.info("WARNING: multiple copies of %s found", module)
Jack Jansen144ebcc2001-08-05 22:31:19258 return os.path.join(list[0], module)
Michael W. Hudson5b109102002-01-23 15:04:41259
Andrew M. Kuchling00e0f212001-01-17 15:23:23260class PyBuildExt(build_ext):
Fredrik Lundhade711a2001-01-24 08:00:28261
Guido van Rossumd8faa362007-04-27 19:54:29262 def __init__(self, dist):
263 build_ext.__init__(self, dist)
264 self.failed = []
Benjamin Peterson5c2ac8c2014-04-30 15:06:16265 self.failed_on_import = []
Antoine Pitrou2c0a9162014-09-26 21:31:59266 if '-j' in os.environ.get('MAKEFLAGS', ''):
267 self.parallel = True
Guido van Rossumd8faa362007-04-27 19:54:29268
Andrew M. Kuchling00e0f212001-01-17 15:23:23269 def build_extensions(self):
Andrew M. Kuchling00e0f212001-01-17 15:23:23270
271 # Detect which modules should be compiled
doko@ubuntu.comd5537d02013-03-21 20:21:49272 missing = self.detect_modules()
Andrew M. Kuchling00e0f212001-01-17 15:23:23273
274 # Remove modules that are present on the disabled list
Christian Heimes679db4a2008-01-18 09:56:22275 extensions = [ext for ext in self.extensions
276 if ext.name not in disabled_module_list]
277 # move ctypes to the end, it depends on other modules
278 ext_map = dict((ext.name, i) for i, ext in enumerate(extensions))
279 if "_ctypes" in ext_map:
280 ctypes = extensions.pop(ext_map["_ctypes"])
281 extensions.append(ctypes)
282 self.extensions = extensions
Fredrik Lundhade711a2001-01-24 08:00:28283
Andrew M. Kuchling00e0f212001-01-17 15:23:23284 # Fix up the autodetected modules, prefixing all the source files
Neil Schemenauer014bf282009-02-05 16:35:45285 # with Modules/.
286 srcdir = sysconfig.get_config_var('srcdir')
Guido van Rossume0fea6c2002-10-14 20:48:09287 if not srcdir:
288 # Maybe running on Windows but not using CYGWIN?
289 raise ValueError("No source directory; cannot proceed.")
Neil Schemenauer4d491a52009-02-06 00:27:50290 srcdir = os.path.abspath(srcdir)
Neil Schemenauer014bf282009-02-05 16:35:45291 moddirlist = [os.path.join(srcdir, 'Modules')]
Michael W. Hudson5b109102002-01-23 15:04:41292
Andrew M. Kuchling3da989c2001-02-28 22:49:26293 # Fix up the paths for scripts, too
294 self.distribution.scripts = [os.path.join(srcdir, filename)
295 for filename in self.distribution.scripts]
296
Christian Heimesaf98da12008-01-27 15:18:18297 # Python header files
Neil Schemenauer014bf282009-02-05 16:35:45298 headers = [sysconfig.get_config_h_filename()]
Stefan Kraheb977da2012-02-29 13:10:53299 headers += glob(os.path.join(sysconfig.get_path('include'), "*.h"))
Christian Heimesaf98da12008-01-27 15:18:18300
xdegayec0364fc2017-05-27 16:25:03301 # The sysconfig variables built by makesetup that list the already
302 # built modules and the disabled modules as configured by the Setup
303 # files.
304 sysconf_built = sysconfig.get_config_var('MODBUILT_NAMES').split()
305 sysconf_dis = sysconfig.get_config_var('MODDISABLED_NAMES').split()
Xavier de Gaye84968b72016-10-29 14:57:20306
xdegayec0364fc2017-05-27 16:25:03307 mods_built = []
308 mods_disabled = []
Xavier de Gaye84968b72016-10-29 14:57:20309 for ext in self.extensions:
Jack Jansen144ebcc2001-08-05 22:31:19310 ext.sources = [ find_module_file(filename, moddirlist)
Andrew M. Kuchling00e0f212001-01-17 15:23:23311 for filename in ext.sources ]
Jeremy Hylton340043e2002-06-13 17:38:11312 if ext.depends is not None:
Neil Schemenauer014bf282009-02-05 16:35:45313 ext.depends = [find_module_file(filename, moddirlist)
Jeremy Hylton340043e2002-06-13 17:38:11314 for filename in ext.depends]
Christian Heimesaf98da12008-01-27 15:18:18315 else:
316 ext.depends = []
317 # re-compile extensions if a header file has been changed
318 ext.depends.extend(headers)
319
xdegayec0364fc2017-05-27 16:25:03320 # If a module has already been built or has been disabled in the
321 # Setup files, don't build it here.
322 if ext.name in sysconf_built:
323 mods_built.append(ext)
324 if ext.name in sysconf_dis:
325 mods_disabled.append(ext)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34326
xdegayec0364fc2017-05-27 16:25:03327 mods_configured = mods_built + mods_disabled
328 if mods_configured:
Xavier de Gaye84968b72016-10-29 14:57:20329 self.extensions = [x for x in self.extensions if x not in
xdegayec0364fc2017-05-27 16:25:03330 mods_configured]
331 # Remove the shared libraries built by a previous build.
332 for ext in mods_configured:
333 fullpath = self.get_ext_fullpath(ext.name)
334 if os.path.exists(fullpath):
335 os.unlink(fullpath)
Michael W. Hudson5b109102002-01-23 15:04:41336
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34337 # When you run "make CC=altcc" or something similar, you really want
338 # those environment variables passed into the setup.py phase. Here's
339 # a small set of useful ones.
340 compiler = os.environ.get('CC')
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34341 args = {}
342 # unfortunately, distutils doesn't let us provide separate C and C++
343 # compilers
344 if compiler is not None:
Martin v. Löwisd7c795e2005-04-25 07:14:03345 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
346 args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
Tarek Ziadé36797272010-07-22 12:50:05347 self.compiler.set_executables(**args)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34348
Andrew M. Kuchling00e0f212001-01-17 15:23:23349 build_ext.build_extensions(self)
350
Antoine Pitrou2c0a9162014-09-26 21:31:59351 for ext in self.extensions:
352 self.check_extension_import(ext)
353
Berker Peksag1d82a9c2014-10-01 02:11:13354 longest = max([len(e.name) for e in self.extensions], default=0)
Benjamin Peterson5c2ac8c2014-04-30 15:06:16355 if self.failed or self.failed_on_import:
356 all_failed = self.failed + self.failed_on_import
357 longest = max(longest, max([len(name) for name in all_failed]))
Guido van Rossumd8faa362007-04-27 19:54:29358
359 def print_three_column(lst):
360 lst.sort(key=str.lower)
361 # guarantee zip() doesn't drop anything
362 while len(lst) % 3:
363 lst.append("")
364 for e, f, g in zip(lst[::3], lst[1::3], lst[2::3]):
365 print("%-*s %-*s %-*s" % (longest, e, longest, f,
366 longest, g))
Guido van Rossumd8faa362007-04-27 19:54:29367
368 if missing:
369 print()
Brett Cannonae95b4f2013-07-12 15:30:32370 print("Python build finished successfully!")
371 print("The necessary bits to build these optional modules were not "
372 "found:")
Guido van Rossumd8faa362007-04-27 19:54:29373 print_three_column(missing)
Guido van Rossum04110fb2007-08-24 16:32:05374 print("To find the necessary bits, look in setup.py in"
375 " detect_modules() for the module's name.")
376 print()
Guido van Rossumd8faa362007-04-27 19:54:29377
xdegayec0364fc2017-05-27 16:25:03378 if mods_built:
379 print()
Xavier de Gaye84968b72016-10-29 14:57:20380 print("The following modules found by detect_modules() in"
381 " setup.py, have been")
382 print("built by the Makefile instead, as configured by the"
383 " Setup files:")
xdegayec0364fc2017-05-27 16:25:03384 print_three_column([ext.name for ext in mods_built])
385 print()
386
387 if mods_disabled:
388 print()
389 print("The following modules found by detect_modules() in"
390 " setup.py have not")
391 print("been built, they are *disabled* in the Setup files:")
392 print_three_column([ext.name for ext in mods_disabled])
393 print()
Xavier de Gaye84968b72016-10-29 14:57:20394
Guido van Rossumd8faa362007-04-27 19:54:29395 if self.failed:
396 failed = self.failed[:]
397 print()
398 print("Failed to build these modules:")
399 print_three_column(failed)
Guido van Rossum04110fb2007-08-24 16:32:05400 print()
Guido van Rossumd8faa362007-04-27 19:54:29401
Benjamin Peterson5c2ac8c2014-04-30 15:06:16402 if self.failed_on_import:
403 failed = self.failed_on_import[:]
404 print()
405 print("Following modules built successfully"
406 " but were removed because they could not be imported:")
407 print_three_column(failed)
408 print()
409
Christian Heimes61d478c2018-01-27 14:51:38410 if any('_ssl' in l
411 for l in (missing, self.failed, self.failed_on_import)):
412 print()
413 print("Could not build the ssl module!")
414 print("Python requires an OpenSSL 1.0.2 or 1.1 compatible "
415 "libssl with X509_VERIFY_PARAM_set1_host().")
416 print("LibreSSL 2.6.4 and earlier do not provide the necessary "
417 "APIs, https://github.com/libressl-portable/portable/issues/381")
418 print()
419
Marc-André Lemburg7c6fcda2001-01-26 18:03:24420 def build_extension(self, ext):
421
Thomas Wouters49fd7fa2006-04-21 10:40:58422 if ext.name == '_ctypes':
423 if not self.configure_ctypes(ext):
Zachary Waref40d4dd2016-09-17 06:25:24424 self.failed.append(ext.name)
Thomas Wouters49fd7fa2006-04-21 10:40:58425 return
426
Marc-André Lemburg7c6fcda2001-01-26 18:03:24427 try:
428 build_ext.build_extension(self, ext)
Guido van Rossumb940e112007-01-10 16:19:56429 except (CCompilerError, DistutilsError) as why:
Marc-André Lemburg7c6fcda2001-01-26 18:03:24430 self.announce('WARNING: building of extension "%s" failed: %s' %
431 (ext.name, sys.exc_info()[1]))
Guido van Rossumd8faa362007-04-27 19:54:29432 self.failed.append(ext.name)
Andrew M. Kuchling62686692001-05-21 20:48:09433 return
Antoine Pitrou2c0a9162014-09-26 21:31:59434
435 def check_extension_import(self, ext):
436 # Don't try to import an extension that has failed to compile
437 if ext.name in self.failed:
438 self.announce(
439 'WARNING: skipping import check for failed build "%s"' %
440 ext.name, level=1)
441 return
442
Jack Jansenf49c6f92001-11-01 14:44:15443 # Workaround for Mac OS X: The Carbon-based modules cannot be
444 # reliably imported into a command-line Python
445 if 'Carbon' in ext.extra_link_args:
Michael W. Hudson5b109102002-01-23 15:04:41446 self.announce(
447 'WARNING: skipping import check for Carbon-based "%s"' %
448 ext.name)
449 return
Georg Brandlfcaf9102008-07-16 02:17:56450
doko@ubuntu.com93df16b2012-06-30 12:32:08451 if host_platform == 'darwin' and (
Benjamin Petersonfc576352008-07-16 02:39:02452 sys.maxsize > 2**32 and '-arch' in ext.extra_link_args):
Georg Brandlfcaf9102008-07-16 02:17:56453 # Don't bother doing an import check when an extension was
454 # build with an explicit '-arch' flag on OSX. That's currently
455 # only used to build 32-bit only extensions in a 4-way
456 # universal build and loading 32-bit code into a 64-bit
457 # process will fail.
458 self.announce(
459 'WARNING: skipping import check for "%s"' %
460 ext.name)
461 return
462
Jason Tishler24cf7762002-05-22 16:46:15463 # Workaround for Cygwin: Cygwin currently has fork issues when many
464 # modules have been imported
doko@ubuntu.com93df16b2012-06-30 12:32:08465 if host_platform == 'cygwin':
Jason Tishler24cf7762002-05-22 16:46:15466 self.announce('WARNING: skipping import check for Cygwin-based "%s"'
467 % ext.name)
468 return
Michael W. Hudsonaf142892002-01-23 15:07:46469 ext_filename = os.path.join(
470 self.build_lib,
471 self.get_ext_filename(self.get_ext_fullname(ext.name)))
Guido van Rossumc3fee692008-07-17 16:23:53472
473 # If the build directory didn't exist when setup.py was
474 # started, sys.path_importer_cache has a negative result
475 # cached. Clear that cache before trying to import.
476 sys.path_importer_cache.clear()
477
doko@ubuntu.com1abe1c52012-06-30 18:42:45478 # Don't try to load extensions for cross builds
479 if cross_compiling:
480 return
481
Brett Cannonca5ff3a2013-06-15 21:52:59482 loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename)
Eric Snow335e14d2014-01-04 22:09:28483 spec = importlib.util.spec_from_file_location(ext.name, ext_filename,
484 loader=loader)
Andrew M. Kuchling62686692001-05-21 20:48:09485 try:
Brett Cannon2a17bde2014-05-30 18:55:29486 importlib._bootstrap._load(spec)
Guido van Rossumb940e112007-01-10 16:19:56487 except ImportError as why:
Benjamin Peterson5c2ac8c2014-04-30 15:06:16488 self.failed_on_import.append(ext.name)
Neal Norwitz6e2d1c72003-02-28 17:39:42489 self.announce('*** WARNING: renaming "%s" since importing it'
490 ' failed: %s' % (ext.name, why), level=3)
491 assert not self.inplace
492 basename, tail = os.path.splitext(ext_filename)
493 newname = basename + "_failed" + tail
494 if os.path.exists(newname):
495 os.remove(newname)
496 os.rename(ext_filename, newname)
497
Neal Norwitz3f5fcc82003-02-28 17:21:39498 except:
Neal Norwitz3f5fcc82003-02-28 17:21:39499 exc_type, why, tb = sys.exc_info()
Neal Norwitz6e2d1c72003-02-28 17:39:42500 self.announce('*** WARNING: importing extension "%s" '
501 'failed with %s: %s' % (ext.name, exc_type, why),
502 level=3)
Guido van Rossumd8faa362007-04-27 19:54:29503 self.failed.append(ext.name)
Fred Drake9028d0a2001-12-06 22:59:54504
Barry Warsaw5ca305a2011-04-06 19:18:12505 def add_multiarch_paths(self):
506 # Debian/Ubuntu multiarch support.
507 # https://wiki.ubuntu.com/MultiarchSpec
doko@ubuntu.com3277b352012-08-08 10:15:55508 cc = sysconfig.get_config_var('CC')
509 tmpfile = os.path.join(self.build_temp, 'multiarch')
510 if not os.path.exists(self.build_temp):
511 os.makedirs(self.build_temp)
512 ret = os.system(
513 '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
514 multiarch_path_component = ''
515 try:
516 if ret >> 8 == 0:
517 with open(tmpfile) as fp:
518 multiarch_path_component = fp.readline().strip()
519 finally:
520 os.unlink(tmpfile)
521
522 if multiarch_path_component != '':
523 add_dir_to_list(self.compiler.library_dirs,
524 '/usr/lib/' + multiarch_path_component)
525 add_dir_to_list(self.compiler.include_dirs,
526 '/usr/include/' + multiarch_path_component)
527 return
528
Barry Warsaw88e19452011-04-07 14:40:36529 if not find_executable('dpkg-architecture'):
530 return
doko@ubuntu.com1abe1c52012-06-30 18:42:45531 opt = ''
532 if cross_compiling:
533 opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE')
Barry Warsaw5ca305a2011-04-06 19:18:12534 tmpfile = os.path.join(self.build_temp, 'multiarch')
535 if not os.path.exists(self.build_temp):
536 os.makedirs(self.build_temp)
537 ret = os.system(
doko@ubuntu.com1abe1c52012-06-30 18:42:45538 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
539 (opt, tmpfile))
Barry Warsaw5ca305a2011-04-06 19:18:12540 try:
541 if ret >> 8 == 0:
542 with open(tmpfile) as fp:
543 multiarch_path_component = fp.readline().strip()
544 add_dir_to_list(self.compiler.library_dirs,
545 '/usr/lib/' + multiarch_path_component)
546 add_dir_to_list(self.compiler.include_dirs,
547 '/usr/include/' + multiarch_path_component)
548 finally:
549 os.unlink(tmpfile)
550
doko@ubuntu.com1abe1c52012-06-30 18:42:45551 def add_gcc_paths(self):
552 gcc = sysconfig.get_config_var('CC')
553 tmpfile = os.path.join(self.build_temp, 'gccpaths')
554 if not os.path.exists(self.build_temp):
555 os.makedirs(self.build_temp)
556 ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (gcc, tmpfile))
557 is_gcc = False
558 in_incdirs = False
559 inc_dirs = []
560 lib_dirs = []
561 try:
562 if ret >> 8 == 0:
563 with open(tmpfile) as fp:
564 for line in fp.readlines():
565 if line.startswith("gcc version"):
566 is_gcc = True
567 elif line.startswith("#include <...>"):
568 in_incdirs = True
569 elif line.startswith("End of search list"):
570 in_incdirs = False
571 elif is_gcc and line.startswith("LIBRARY_PATH"):
572 for d in line.strip().split("=")[1].split(":"):
573 d = os.path.normpath(d)
574 if '/gcc/' not in d:
575 add_dir_to_list(self.compiler.library_dirs,
576 d)
577 elif is_gcc and in_incdirs and '/gcc/' not in line:
578 add_dir_to_list(self.compiler.include_dirs,
579 line.strip())
580 finally:
581 os.unlink(tmpfile)
582
Andrew M. Kuchling00e0f212001-01-17 15:23:23583 def detect_modules(self):
Barry Warsaw807bd0a2010-11-24 20:30:00584 # Ensure that /usr/local is always used, but the local build
585 # directories (i.e. '.' and 'Include') must be first. See issue
586 # 10520.
doko@ubuntu.com1abe1c52012-06-30 18:42:45587 if not cross_compiling:
588 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
589 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
doko@ubuntu.comcc5addd2012-06-30 22:23:51590 # only change this for cross builds for 3.3, issues on Mageia
591 if cross_compiling:
592 self.add_gcc_paths()
Barry Warsaw5ca305a2011-04-06 19:18:12593 self.add_multiarch_paths()
Michael W. Hudson39230b32002-01-16 15:26:48594
Brett Cannon516592f2004-12-07 00:42:59595 # Add paths specified in the environment variables LDFLAGS and
Brett Cannon4810eb92004-12-31 08:11:21596 # CPPFLAGS for header and library files.
Brett Cannon5399c6d2004-12-18 20:48:09597 # We must get the values from the Makefile and not the environment
598 # directly since an inconsistently reproducible issue comes up where
599 # the environment variable is not set even though the value were passed
Brett Cannon4810eb92004-12-31 08:11:21600 # into configure and stored in the Makefile (issue found on OS X 10.3).
Brett Cannon516592f2004-12-07 00:42:59601 for env_var, arg_name, dir_list in (
Tarek Ziadé36797272010-07-22 12:50:05602 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
603 ('LDFLAGS', '-L', self.compiler.library_dirs),
604 ('CPPFLAGS', '-I', self.compiler.include_dirs)):
Brett Cannon5399c6d2004-12-18 20:48:09605 env_val = sysconfig.get_config_var(env_var)
Brett Cannon516592f2004-12-07 00:42:59606 if env_val:
Brett Cannon4810eb92004-12-31 08:11:21607 # To prevent optparse from raising an exception about any
Skip Montanaroa5c2a512008-10-07 02:51:48608 # options in env_val that it doesn't know about we strip out
Brett Cannon4810eb92004-12-31 08:11:21609 # all double dashes and any dashes followed by a character
610 # that is not for the option we are dealing with.
611 #
612 # Please note that order of the regex is important! We must
613 # strip out double-dashes first so that we don't end up with
614 # substituting "--Long" to "-Long" and thus lead to "ong" being
615 # used for a library directory.
Guido van Rossum04110fb2007-08-24 16:32:05616 env_val = re.sub(r'(^|\s+)-(-|(?!%s))' % arg_name[1],
617 ' ', env_val)
Brett Cannon84667c02004-12-07 03:25:18618 parser = optparse.OptionParser()
Brett Cannon4810eb92004-12-31 08:11:21619 # Make sure that allowing args interspersed with options is
620 # allowed
621 parser.allow_interspersed_args = True
622 parser.error = lambda msg: None
Brett Cannon84667c02004-12-07 03:25:18623 parser.add_option(arg_name, dest="dirs", action="append")
624 options = parser.parse_args(env_val.split())[0]
Brett Cannon44837712005-01-02 21:54:07625 if options.dirs:
Christian Heimes292d3512008-02-03 16:51:08626 for directory in reversed(options.dirs):
Brett Cannon44837712005-01-02 21:54:07627 add_dir_to_list(dir_list, directory)
Skip Montanarodecc6a42003-01-01 20:07:49628
Xavier de Gaye1351c312016-12-14 10:14:33629 if (not cross_compiling and
630 os.path.normpath(sys.base_prefix) != '/usr' and
631 not sysconfig.get_config_var('PYTHONFRAMEWORK')):
Ronald Oussorenf3500e12010-10-20 13:10:12632 # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
633 # (PYTHONFRAMEWORK is set) to avoid # linking problems when
634 # building a framework with different architectures than
635 # the one that is currently installed (issue #7473)
Tarek Ziadé36797272010-07-22 12:50:05636 add_dir_to_list(self.compiler.library_dirs,
Michael W. Hudson90b8e4d2002-08-02 13:55:50637 sysconfig.get_config_var("LIBDIR"))
Tarek Ziadé36797272010-07-22 12:50:05638 add_dir_to_list(self.compiler.include_dirs,
Michael W. Hudson90b8e4d2002-08-02 13:55:50639 sysconfig.get_config_var("INCLUDEDIR"))
Andrew M. Kuchlingfbe73762001-01-18 18:44:20640
xdegaye77f51392017-11-25 16:25:30641 system_lib_dirs = ['/lib64', '/usr/lib64', '/lib', '/usr/lib']
642 system_include_dirs = ['/usr/include']
Andrew M. Kuchlingfbe73762001-01-18 18:44:20643 # lib_dirs and inc_dirs are used to search for files;
644 # if a file is found in one of those directories, it can
645 # be assumed that no additional -I,-L directives are needed.
doko@ubuntu.com1abe1c52012-06-30 18:42:45646 if not cross_compiling:
xdegaye77f51392017-11-25 16:25:30647 lib_dirs = self.compiler.library_dirs + system_lib_dirs
648 inc_dirs = self.compiler.include_dirs + system_include_dirs
Christian Heimesf19529c2012-12-12 11:41:00649 else:
xdegaye77f51392017-11-25 16:25:30650 # Add the sysroot paths. 'sysroot' is a compiler option used to
651 # set the logical path of the standard system headers and
652 # libraries.
653 lib_dirs = (self.compiler.library_dirs +
654 sysroot_paths(('LDFLAGS', 'CC'), system_lib_dirs))
655 inc_dirs = (self.compiler.include_dirs +
656 sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
657 system_include_dirs))
Andrew M. Kuchling00e0f212001-01-17 15:23:23658 exts = []
Guido van Rossumd8faa362007-04-27 19:54:29659 missing = []
Andrew M. Kuchling00e0f212001-01-17 15:23:23660
Brett Cannon4454a1f2005-04-15 20:32:39661 config_h = sysconfig.get_config_h_filename()
Brett Cannon9f5db072010-10-29 20:19:27662 with open(config_h) as file:
663 config_h_vars = sysconfig.parse_config_h(file)
Brett Cannon4454a1f2005-04-15 20:32:39664
Neil Schemenauer014bf282009-02-05 16:35:45665 srcdir = sysconfig.get_config_var('srcdir')
Michael W. Hudson5b109102002-01-23 15:04:41666
Andrew M. Kuchling7883dc82003-10-24 18:26:26667 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
doko@ubuntu.com93df16b2012-06-30 12:32:08668 if host_platform in ['osf1', 'unixware7', 'openunix8']:
Skip Montanaro22e00c42003-05-06 20:43:34669 lib_dirs += ['/usr/ccs/lib']
670
Charles-François Natali5739e102012-04-12 17:07:25671 # HP-UX11iv3 keeps files in lib/hpux folders.
doko@ubuntu.com93df16b2012-06-30 12:32:08672 if host_platform == 'hp-ux11':
Charles-François Natali5739e102012-04-12 17:07:25673 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
674
doko@ubuntu.com93df16b2012-06-30 12:32:08675 if host_platform == 'darwin':
Thomas Wouters477c8d52006-05-27 19:21:47676 # This should work on any unixy platform ;-)
677 # If the user has bothered specifying additional -I and -L flags
678 # in OPT and LDFLAGS we might as well use them here.
Barry Warsaw807bd0a2010-11-24 20:30:00679 #
680 # NOTE: using shlex.split would technically be more correct, but
681 # also gives a bootstrap problem. Let's hope nobody uses
682 # directories with whitespace in the name to store libraries.
Thomas Wouters477c8d52006-05-27 19:21:47683 cflags, ldflags = sysconfig.get_config_vars(
684 'CFLAGS', 'LDFLAGS')
685 for item in cflags.split():
686 if item.startswith('-I'):
687 inc_dirs.append(item[2:])
688
689 for item in ldflags.split():
690 if item.startswith('-L'):
691 lib_dirs.append(item[2:])
692
Andrew M. Kuchling00e0f212001-01-17 15:23:23693 #
694 # The following modules are all pretty straightforward, and compile
695 # on pretty much any POSIXish platform.
696 #
Fredrik Lundhade711a2001-01-24 08:00:28697
Andrew M. Kuchling00e0f212001-01-17 15:23:23698 # array objects
699 exts.append( Extension('array', ['arraymodule.c']) )
Martin Panterc9deece2016-02-03 05:19:44700
Yury Selivanovf23746a2018-01-23 00:11:18701 # Context Variables
702 exts.append( Extension('_contextvars', ['_contextvarsmodule.c']) )
703
Martin Panterc9deece2016-02-03 05:19:44704 shared_math = 'Modules/_math.o'
Andrew M. Kuchling00e0f212001-01-17 15:23:23705 # complex math library functions
Martin Panterc9deece2016-02-03 05:19:44706 exts.append( Extension('cmath', ['cmathmodule.c'],
707 extra_objects=[shared_math],
708 depends=['_math.h', shared_math],
Benjamin Peterson8acaa312017-11-13 04:53:39709 libraries=['m']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23710 # math library functions, e.g. sin()
Martin Panterc9deece2016-02-03 05:19:44711 exts.append( Extension('math', ['mathmodule.c'],
712 extra_objects=[shared_math],
713 depends=['_math.h', shared_math],
Benjamin Peterson8acaa312017-11-13 04:53:39714 libraries=['m']) )
Victor Stinnere0be4232011-10-25 11:06:09715
716 # time libraries: librt may be needed for clock_gettime()
717 time_libs = []
718 lib = sysconfig.get_config_var('TIMEMODULE_LIB')
719 if lib:
720 time_libs.append(lib)
721
Andrew M. Kuchling00e0f212001-01-17 15:23:23722 # time operations and variables
Victor Stinner5d272cc2012-03-13 12:35:55723 exts.append( Extension('time', ['timemodule.c'],
Victor Stinnere0be4232011-10-25 11:06:09724 libraries=time_libs) )
Benjamin Peterson8acaa312017-11-13 04:53:39725 # libm is needed by delta_new() that uses round() and by accum() that
726 # uses modf().
Victor Stinnerdef80722016-04-19 13:58:11727 exts.append( Extension('_datetime', ['_datetimemodule.c'],
Benjamin Peterson8acaa312017-11-13 04:53:39728 libraries=['m']) )
Christian Heimesfe337bf2008-03-23 21:54:12729 # random number generator implemented in C
730 exts.append( Extension("_random", ["_randommodule.c"]) )
Raymond Hettinger0c410272004-01-05 10:13:35731 # bisect
732 exts.append( Extension("_bisect", ["_bisectmodule.c"]) )
Raymond Hettingerb3af1812003-11-08 10:24:38733 # heapq
Raymond Hettingerc46cb2a2004-04-19 19:06:21734 exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
Alexandre Vassalottica2d6102008-06-12 18:26:05735 # C-optimized pickle replacement
736 exts.append( Extension("_pickle", ["_pickle.c"]) )
Collin Winter670e6922007-03-21 02:57:17737 # atexit
738 exts.append( Extension("atexit", ["atexitmodule.c"]) )
Christian Heimes90540002008-05-08 14:29:10739 # _json speedups
740 exts.append( Extension("_json", ["_json.c"]) )
Marc-André Lemburg261b8e22001-02-02 12:12:44741 # Python C API test module
Mark Dickinsona06f44b2009-02-10 16:18:22742 exts.append( Extension('_testcapi', ['_testcapimodule.c'],
743 depends=['testcapi_long.h']) )
Stefan Krah9a2d99e2012-02-25 11:24:21744 # Python PEP-3118 (buffer protocol) test module
745 exts.append( Extension('_testbuffer', ['_testbuffer.c']) )
Andrew Svetlov6b2cbeb2012-12-14 15:04:59746 # Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421)
747 exts.append( Extension('_testimportmultiple', ['_testimportmultiple.c']) )
Nick Coghland5cacbb2015-05-23 12:24:10748 # Test multi-phase extension module init (PEP 489)
749 exts.append( Extension('_testmultiphase', ['_testmultiphase.c']) )
Fred Drake0e474a82007-10-11 18:01:43750 # profiler (_lsprof is for cProfile.py)
Armin Rigoa871ef22006-02-08 12:53:56751 exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23752 # static Unicode character database
Benjamin Peterson67752312016-09-15 06:53:47753 exts.append( Extension('unicodedata', ['unicodedata.c'],
754 depends=['unicodedata_db.h', 'unicodename_db.h']) )
Larry Hastings3a907972013-11-23 22:49:22755 # _opcode module
756 exts.append( Extension('_opcode', ['_opcode.c']) )
INADA Naoki9f2ce252016-10-15 06:39:19757 # asyncio speedups
758 exts.append( Extension("_asyncio", ["_asynciomodule.c"]) )
Ivan Levkivskyi38928992018-02-18 17:39:43759 # _abc speedups
760 exts.append( Extension("_abc", ["_abc.c"]) )
Antoine Pitrou94e16962018-01-15 23:27:16761 # _queue module
762 exts.append( Extension("_queue", ["_queuemodule.c"]) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23763
764 # Modules with some UNIX dependencies -- on by default:
765 # (If you have a really backward UNIX, select and socket may not be
766 # supported...)
767
768 # fcntl(2) and ioctl(2)
Antoine Pitroua3000072010-09-07 14:52:42769 libs = []
770 if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
771 # May be necessary on AIX for flock function
772 libs = ['bsd']
773 exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
Ronald Oussoren94f25282010-05-05 19:11:21774 # pwd(3)
775 exts.append( Extension('pwd', ['pwdmodule.c']) )
776 # grp(3)
777 exts.append( Extension('grp', ['grpmodule.c']) )
778 # spwd, shadow passwords
779 if (config_h_vars.get('HAVE_GETSPNAM', False) or
780 config_h_vars.get('HAVE_GETSPENT', False)):
781 exts.append( Extension('spwd', ['spwdmodule.c']) )
Guido van Rossumd8faa362007-04-27 19:54:29782 else:
Ronald Oussoren94f25282010-05-05 19:11:21783 missing.append('spwd')
Guido van Rossumd8faa362007-04-27 19:54:29784
Andrew M. Kuchling00e0f212001-01-17 15:23:23785 # select(2); not on ancient System V
786 exts.append( Extension('select', ['selectmodule.c']) )
787
Andrew M. Kuchling00e0f212001-01-17 15:23:23788 # Fred Drake's interface to the Python parser
789 exts.append( Extension('parser', ['parsermodule.c']) )
790
Andrew M. Kuchling00e0f212001-01-17 15:23:23791 # Memory-mapped files (also works on Win32).
Ronald Oussoren94f25282010-05-05 19:11:21792 exts.append( Extension('mmap', ['mmapmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23793
Andrew M. Kuchling57269d02004-08-31 13:37:25794 # Lance Ellinghaus's syslog module
Ronald Oussoren94f25282010-05-05 19:11:21795 # syslog daemon interface
796 exts.append( Extension('syslog', ['syslogmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23797
Devin Jeanpierrec5bace22017-09-06 18:15:35798 # Fuzz tests.
799 exts.append( Extension(
800 '_xxtestfuzz',
801 ['_xxtestfuzz/_xxtestfuzz.c', '_xxtestfuzz/fuzzer.c'])
802 )
803
Andrew M. Kuchling00e0f212001-01-17 15:23:23804 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34805 # Here ends the simple stuff. From here on, modules need certain
806 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23807 #
808
809 # Multimedia modules
810 # These don't work for 64-bit platforms!!!
811 # These represent audio samples or images as strings:
Victor Stinnerdef80722016-04-19 13:58:11812 #
Neal Norwitz5e4a3b82004-07-19 16:55:07813 # Operations on audio samples
Tim Petersf9cbf212004-07-23 02:50:10814 # According to #993173, this one should actually work fine on
Martin v. Löwis8fbefe22004-07-19 16:42:20815 # 64-bit platforms.
Victor Stinnerdef80722016-04-19 13:58:11816 #
Benjamin Peterson8acaa312017-11-13 04:53:39817 # audioop needs libm for floor() in multiple functions.
Victor Stinnerdef80722016-04-19 13:58:11818 exts.append( Extension('audioop', ['audioop.c'],
Benjamin Peterson8acaa312017-11-13 04:53:39819 libraries=['m']) )
Martin v. Löwis8fbefe22004-07-19 16:42:20820
Andrew M. Kuchling00e0f212001-01-17 15:23:23821 # readline
Tarek Ziadé36797272010-07-22 12:50:05822 do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
Stefan Krah095b2732010-06-08 13:41:44823 readline_termcap_library = ""
824 curses_library = ""
doko@ubuntu.com58844492012-06-30 16:25:32825 # Cannot use os.popen here in py3k.
826 tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
827 if not os.path.exists(self.build_temp):
828 os.makedirs(self.build_temp)
Stefan Krah095b2732010-06-08 13:41:44829 # Determine if readline is already linked against curses or tinfo.
doko@ubuntu.com58844492012-06-30 16:25:32830 if do_readline:
831 if cross_compiling:
832 ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \
833 % (sysconfig.get_config_var('READELF'),
834 do_readline, tmpfile))
835 elif find_executable('ldd'):
836 ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
837 else:
838 ret = 256
doko@ubuntu.com4c990712012-06-30 21:28:09839 if ret >> 8 == 0:
Brett Cannon9f5db072010-10-29 20:19:27840 with open(tmpfile) as fp:
841 for ln in fp:
842 if 'curses' in ln:
843 readline_termcap_library = re.sub(
844 r'.*lib(n?cursesw?)\.so.*', r'\1', ln
845 ).rstrip()
846 break
847 # termcap interface split out from ncurses
848 if 'tinfo' in ln:
849 readline_termcap_library = 'tinfo'
850 break
doko@ubuntu.com4c990712012-06-30 21:28:09851 if os.path.exists(tmpfile):
852 os.unlink(tmpfile)
Stefan Krah095b2732010-06-08 13:41:44853 # Issue 7384: If readline is already linked against curses,
854 # use the same library for the readline and curses modules.
855 if 'curses' in readline_termcap_library:
856 curses_library = readline_termcap_library
Tarek Ziadé36797272010-07-22 12:50:05857 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
Stefan Krah095b2732010-06-08 13:41:44858 curses_library = 'ncursesw'
Tarek Ziadé36797272010-07-22 12:50:05859 elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
Stefan Krah095b2732010-06-08 13:41:44860 curses_library = 'ncurses'
Tarek Ziadé36797272010-07-22 12:50:05861 elif self.compiler.find_library_file(lib_dirs, 'curses'):
Stefan Krah095b2732010-06-08 13:41:44862 curses_library = 'curses'
863
doko@ubuntu.com93df16b2012-06-30 12:32:08864 if host_platform == 'darwin':
Ronald Oussoren2efd9242009-09-20 14:53:22865 os_release = int(os.uname()[2].split('.')[0])
Ronald Oussoren961683a2010-03-08 07:09:59866 dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
Ned Deily04cdfa12014-06-25 20:36:14867 if (dep_target and
868 (tuple(int(n) for n in dep_target.split('.')[0:2])
869 < (10, 5) ) ):
Ronald Oussoren961683a2010-03-08 07:09:59870 os_release = 8
Ronald Oussoren2efd9242009-09-20 14:53:22871 if os_release < 9:
872 # MacOSX 10.4 has a broken readline. Don't try to build
873 # the readline module unless the user has installed a fixed
874 # readline package
875 if find_file('readline/rlconf.h', inc_dirs, []) is None:
876 do_readline = False
Jack Jansen81ae2352006-02-23 15:02:23877 if do_readline:
doko@ubuntu.com93df16b2012-06-30 12:32:08878 if host_platform == 'darwin' and os_release < 9:
Thomas Wouters477c8d52006-05-27 19:21:47879 # In every directory on the search path search for a dynamic
880 # library and then a static library, instead of first looking
Fred Drake0af17612007-09-04 19:43:19881 # for dynamic libraries on the entire path.
Martin Pantere26da7c2016-06-02 10:07:09882 # This way a statically linked custom readline gets picked up
Ronald Oussoren2c12ab12010-06-03 14:42:25883 # before the (possibly broken) dynamic library in /usr/lib.
Thomas Wouters477c8d52006-05-27 19:21:47884 readline_extra_link_args = ('-Wl,-search_paths_first',)
885 else:
886 readline_extra_link_args = ()
887
Marc-André Lemburg2efc3232001-01-26 18:23:02888 readline_libs = ['readline']
Stefan Krah095b2732010-06-08 13:41:44889 if readline_termcap_library:
890 pass # Issue 7384: Already linked against curses or tinfo.
891 elif curses_library:
892 readline_libs.append(curses_library)
Tarek Ziadé36797272010-07-22 12:50:05893 elif self.compiler.find_library_file(lib_dirs +
Tarek Ziadédd07ebb2009-07-06 13:52:17894 ['/usr/lib/termcap'],
895 'termcap'):
Marc-André Lemburg2efc3232001-01-26 18:23:02896 readline_libs.append('termcap')
Andrew M. Kuchling00e0f212001-01-17 15:23:23897 exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg7c6fcda2001-01-26 18:03:24898 library_dirs=['/usr/lib/termcap'],
Thomas Wouters477c8d52006-05-27 19:21:47899 extra_link_args=readline_extra_link_args,
Marc-André Lemburg2efc3232001-01-26 18:23:02900 libraries=readline_libs) )
Guido van Rossumd8faa362007-04-27 19:54:29901 else:
902 missing.append('readline')
903
Ronald Oussoren94f25282010-05-05 19:11:21904 # crypt module.
Tim Peters2c60f7a2003-01-29 03:49:43905
Tarek Ziadé36797272010-07-22 12:50:05906 if self.compiler.find_library_file(lib_dirs, 'crypt'):
Ronald Oussoren94f25282010-05-05 19:11:21907 libs = ['crypt']
Guido van Rossumd8faa362007-04-27 19:54:29908 else:
Ronald Oussoren94f25282010-05-05 19:11:21909 libs = []
Sean Reifscheidere2dfefb2011-02-22 10:55:44910 exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23911
Skip Montanaroba9e9782003-03-20 23:34:22912 # CSV files
913 exts.append( Extension('_csv', ['_csv.c']) )
914
Gregory P. Smithfb94c5f2010-03-14 06:49:55915 # POSIX subprocess module helper.
916 exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) )
917
Andrew M. Kuchling00e0f212001-01-17 15:23:23918 # socket(2)
Guido van Rossum47d3a7a2002-06-13 14:41:32919 exts.append( Extension('_socket', ['socketmodule.c'],
Jeremy Hylton340043e2002-06-13 17:38:11920 depends = ['socketmodule.h']) )
Marc-André Lemburga5d2b4c2002-02-16 18:23:30921 # Detect SSL support for the socket module (via _ssl)
Christian Heimesff5be6e2018-01-20 12:19:21922 ssl_ext, hashlib_ext = self._detect_openssl(inc_dirs, lib_dirs)
923 if ssl_ext is not None:
924 exts.append(ssl_ext)
Guido van Rossumd8faa362007-04-27 19:54:29925 else:
926 missing.append('_ssl')
Christian Heimesff5be6e2018-01-20 12:19:21927 if hashlib_ext is not None:
928 exts.append(hashlib_ext)
929 else:
930 missing.append('_hashlib')
Gregory P. Smithf21a5f72005-08-21 18:45:59931
Antoine Pitrou019ff192012-05-16 14:41:26932 # We always compile these even when OpenSSL is available (issue #14693).
Victor Stinner8c663fd2017-11-08 22:44:44933 # It's harmless and the object code is tiny (40-50 KiB per module,
Antoine Pitrou019ff192012-05-16 14:41:26934 # only loaded when actually used).
935 exts.append( Extension('_sha256', ['sha256module.c'],
936 depends=['hashlib.h']) )
937 exts.append( Extension('_sha512', ['sha512module.c'],
938 depends=['hashlib.h']) )
939 exts.append( Extension('_md5', ['md5module.c'],
940 depends=['hashlib.h']) )
941 exts.append( Extension('_sha1', ['sha1module.c'],
942 depends=['hashlib.h']) )
Gregory P. Smith2f21eb32007-09-09 06:44:34943
Christian Heimes3c397e42016-09-06 20:35:14944 blake2_deps = glob(os.path.join(os.getcwd(), srcdir,
945 'Modules/_blake2/impl/*'))
Christian Heimes121b9482016-09-06 20:03:25946 blake2_deps.append('hashlib.h')
947
Christian Heimes121b9482016-09-06 20:03:25948 exts.append( Extension('_blake2',
949 ['_blake2/blake2module.c',
950 '_blake2/blake2b_impl.c',
951 '_blake2/blake2s_impl.c'],
Christian Heimes121b9482016-09-06 20:03:25952 depends=blake2_deps) )
953
Christian Heimes6fe2a752016-09-07 09:58:24954 sha3_deps = glob(os.path.join(os.getcwd(), srcdir,
955 'Modules/_sha3/kcp/*'))
956 sha3_deps.append('hashlib.h')
957 exts.append( Extension('_sha3',
958 ['_sha3/sha3module.c'],
959 depends=sha3_deps))
960
Georg Brandl489cb4f2009-07-11 10:08:49961 # Modules that provide persistent dictionary-like semantics. You will
962 # probably want to arrange for at least one of them to be available on
963 # your machine, though none are defined by default because of library
964 # dependencies. The Python module dbm/__init__.py provides an
965 # implementation independent wrapper for these; dbm/dumb.py provides
966 # similar functionality (but slower of course) implemented in Python.
967
968 # Sleepycat^WOracle Berkeley DB interface.
969 # http://www.oracle.com/database/berkeley-db/db/index.html
970 #
971 # This requires the Sleepycat^WOracle DB code. The supported versions
972 # are set below. Visit the URL above to download
973 # a release. Most open source OSes come with one or more
974 # versions of BerkeleyDB already installed.
975
doko@ubuntu.com15bac0f2012-07-01 08:35:54976 max_db_ver = (5, 3)
Georg Brandl489cb4f2009-07-11 10:08:49977 min_db_ver = (3, 3)
978 db_setup_debug = False # verbose debug prints from this script?
979
980 def allow_db_ver(db_ver):
981 """Returns a boolean if the given BerkeleyDB version is acceptable.
982
983 Args:
984 db_ver: A tuple of the version to verify.
985 """
986 if not (min_db_ver <= db_ver <= max_db_ver):
987 return False
988 return True
989
990 def gen_db_minor_ver_nums(major):
991 if major == 4:
992 for x in range(max_db_ver[1]+1):
993 if allow_db_ver((4, x)):
994 yield x
995 elif major == 3:
996 for x in (3,):
997 if allow_db_ver((3, x)):
998 yield x
999 else:
1000 raise ValueError("unknown major BerkeleyDB version", major)
1001
1002 # construct a list of paths to look for the header file in on
1003 # top of the normal inc_dirs.
1004 db_inc_paths = [
1005 '/usr/include/db4',
1006 '/usr/local/include/db4',
1007 '/opt/sfw/include/db4',
1008 '/usr/include/db3',
1009 '/usr/local/include/db3',
1010 '/opt/sfw/include/db3',
1011 # Fink defaults (http://fink.sourceforge.net/)
1012 '/sw/include/db4',
1013 '/sw/include/db3',
1014 ]
1015 # 4.x minor number specific paths
1016 for x in gen_db_minor_ver_nums(4):
1017 db_inc_paths.append('/usr/include/db4%d' % x)
1018 db_inc_paths.append('/usr/include/db4.%d' % x)
1019 db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
1020 db_inc_paths.append('/usr/local/include/db4%d' % x)
1021 db_inc_paths.append('/pkg/db-4.%d/include' % x)
1022 db_inc_paths.append('/opt/db-4.%d/include' % x)
1023 # MacPorts default (http://www.macports.org/)
1024 db_inc_paths.append('/opt/local/include/db4%d' % x)
1025 # 3.x minor number specific paths
1026 for x in gen_db_minor_ver_nums(3):
1027 db_inc_paths.append('/usr/include/db3%d' % x)
1028 db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
1029 db_inc_paths.append('/usr/local/include/db3%d' % x)
1030 db_inc_paths.append('/pkg/db-3.%d/include' % x)
1031 db_inc_paths.append('/opt/db-3.%d/include' % x)
1032
doko@ubuntu.com1abe1c52012-06-30 18:42:451033 if cross_compiling:
1034 db_inc_paths = []
1035
Georg Brandl489cb4f2009-07-11 10:08:491036 # Add some common subdirectories for Sleepycat DB to the list,
1037 # based on the standard include directories. This way DB3/4 gets
1038 # picked up when it is installed in a non-standard prefix and
1039 # the user has added that prefix into inc_dirs.
1040 std_variants = []
1041 for dn in inc_dirs:
1042 std_variants.append(os.path.join(dn, 'db3'))
1043 std_variants.append(os.path.join(dn, 'db4'))
1044 for x in gen_db_minor_ver_nums(4):
1045 std_variants.append(os.path.join(dn, "db4%d"%x))
1046 std_variants.append(os.path.join(dn, "db4.%d"%x))
1047 for x in gen_db_minor_ver_nums(3):
1048 std_variants.append(os.path.join(dn, "db3%d"%x))
1049 std_variants.append(os.path.join(dn, "db3.%d"%x))
1050
1051 db_inc_paths = std_variants + db_inc_paths
1052 db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
1053
1054 db_ver_inc_map = {}
1055
doko@ubuntu.com93df16b2012-06-30 12:32:081056 if host_platform == 'darwin':
Ronald Oussoren2c12ab12010-06-03 14:42:251057 sysroot = macosx_sdk_root()
1058
Georg Brandl489cb4f2009-07-11 10:08:491059 class db_found(Exception): pass
1060 try:
1061 # See whether there is a Sleepycat header in the standard
1062 # search path.
1063 for d in inc_dirs + db_inc_paths:
1064 f = os.path.join(d, "db.h")
doko@ubuntu.com93df16b2012-06-30 12:32:081065 if host_platform == 'darwin' and is_macosx_sdk_path(d):
Ronald Oussoren2c12ab12010-06-03 14:42:251066 f = os.path.join(sysroot, d[1:], "db.h")
1067
Georg Brandl489cb4f2009-07-11 10:08:491068 if db_setup_debug: print("db: looking for db.h in", f)
1069 if os.path.exists(f):
Brett Cannon9f5db072010-10-29 20:19:271070 with open(f, 'rb') as file:
1071 f = file.read()
Benjamin Peterson019f3612009-08-12 18:18:031072 m = re.search(br"#define\WDB_VERSION_MAJOR\W(\d+)", f)
Georg Brandl489cb4f2009-07-11 10:08:491073 if m:
1074 db_major = int(m.group(1))
Benjamin Peterson019f3612009-08-12 18:18:031075 m = re.search(br"#define\WDB_VERSION_MINOR\W(\d+)", f)
Georg Brandl489cb4f2009-07-11 10:08:491076 db_minor = int(m.group(1))
1077 db_ver = (db_major, db_minor)
1078
1079 # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
1080 if db_ver == (4, 6):
Benjamin Peterson019f3612009-08-12 18:18:031081 m = re.search(br"#define\WDB_VERSION_PATCH\W(\d+)", f)
Georg Brandl489cb4f2009-07-11 10:08:491082 db_patch = int(m.group(1))
1083 if db_patch < 21:
1084 print("db.h:", db_ver, "patch", db_patch,
1085 "being ignored (4.6.x must be >= 4.6.21)")
1086 continue
1087
1088 if ( (db_ver not in db_ver_inc_map) and
1089 allow_db_ver(db_ver) ):
1090 # save the include directory with the db.h version
1091 # (first occurrence only)
1092 db_ver_inc_map[db_ver] = d
1093 if db_setup_debug:
1094 print("db.h: found", db_ver, "in", d)
1095 else:
1096 # we already found a header for this library version
1097 if db_setup_debug: print("db.h: ignoring", d)
1098 else:
1099 # ignore this header, it didn't contain a version number
1100 if db_setup_debug:
1101 print("db.h: no version number version in", d)
1102
1103 db_found_vers = list(db_ver_inc_map.keys())
1104 db_found_vers.sort()
1105
1106 while db_found_vers:
1107 db_ver = db_found_vers.pop()
1108 db_incdir = db_ver_inc_map[db_ver]
1109
1110 # check lib directories parallel to the location of the header
1111 db_dirs_to_check = [
1112 db_incdir.replace("include", 'lib64'),
1113 db_incdir.replace("include", 'lib'),
1114 ]
Ronald Oussoren2c12ab12010-06-03 14:42:251115
doko@ubuntu.com93df16b2012-06-30 12:32:081116 if host_platform != 'darwin':
Ronald Oussoren2c12ab12010-06-03 14:42:251117 db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_check))
1118
1119 else:
1120 # Same as other branch, but takes OSX SDK into account
1121 tmp = []
1122 for dn in db_dirs_to_check:
1123 if is_macosx_sdk_path(dn):
1124 if os.path.isdir(os.path.join(sysroot, dn[1:])):
1125 tmp.append(dn)
1126 else:
1127 if os.path.isdir(dn):
1128 tmp.append(dn)
Ronald Oussorendc969e52010-06-27 12:37:461129 db_dirs_to_check = tmp
Ronald Oussoren2c12ab12010-06-03 14:42:251130
1131 db_dirs_to_check = tmp
Georg Brandl489cb4f2009-07-11 10:08:491132
Ezio Melotti42da6632011-03-15 03:18:481133 # Look for a version specific db-X.Y before an ambiguous dbX
Georg Brandl489cb4f2009-07-11 10:08:491134 # XXX should we -ever- look for a dbX name? Do any
1135 # systems really not name their library by version and
1136 # symlink to more general names?
1137 for dblib in (('db-%d.%d' % db_ver),
1138 ('db%d%d' % db_ver),
1139 ('db%d' % db_ver[0])):
1140 dblib_file = self.compiler.find_library_file(
1141 db_dirs_to_check + lib_dirs, dblib )
1142 if dblib_file:
1143 dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
1144 raise db_found
1145 else:
1146 if db_setup_debug: print("db lib: ", dblib, "not found")
1147
1148 except db_found:
1149 if db_setup_debug:
1150 print("bsddb using BerkeleyDB lib:", db_ver, dblib)
1151 print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir)
Georg Brandl489cb4f2009-07-11 10:08:491152 dblibs = [dblib]
doko@ubuntu.coma3818a32014-04-17 15:52:481153 # Only add the found library and include directories if they aren't
1154 # already being searched. This avoids an explicit runtime library
1155 # dependency.
1156 if db_incdir in inc_dirs:
1157 db_incs = None
1158 else:
1159 db_incs = [db_incdir]
1160 if dblib_dir[0] in lib_dirs:
1161 dblib_dir = None
Georg Brandl489cb4f2009-07-11 10:08:491162 else:
1163 if db_setup_debug: print("db: no appropriate library found")
1164 db_incs = None
1165 dblibs = []
1166 dblib_dir = None
1167
Thomas Wouters49fd7fa2006-04-21 10:40:581168 # The sqlite interface
Thomas Wouters89f507f2006-12-13 04:49:301169 sqlite_setup_debug = False # verbose debug prints from this script?
Thomas Wouters49fd7fa2006-04-21 10:40:581170
1171 # We hunt for #define SQLITE_VERSION "n.n.n"
Miss Islington (bot)967f14e2019-04-26 16:15:311172 # We need to find >= sqlite version 3.3.9, for sqlite3_prepare_v2
Thomas Wouters49fd7fa2006-04-21 10:40:581173 sqlite_incdir = sqlite_libdir = None
1174 sqlite_inc_paths = [ '/usr/include',
1175 '/usr/include/sqlite',
1176 '/usr/include/sqlite3',
1177 '/usr/local/include',
1178 '/usr/local/include/sqlite',
1179 '/usr/local/include/sqlite3',
doko@ubuntu.com1abe1c52012-06-30 18:42:451180 ]
1181 if cross_compiling:
1182 sqlite_inc_paths = []
Miss Islington (bot)967f14e2019-04-26 16:15:311183 MIN_SQLITE_VERSION_NUMBER = (3, 3, 9)
Thomas Wouters49fd7fa2006-04-21 10:40:581184 MIN_SQLITE_VERSION = ".".join([str(x)
1185 for x in MIN_SQLITE_VERSION_NUMBER])
Thomas Wouters477c8d52006-05-27 19:21:471186
1187 # Scan the default include directories before the SQLite specific
1188 # ones. This allows one to override the copy of sqlite on OSX,
1189 # where /usr/include contains an old version of sqlite.
doko@ubuntu.com93df16b2012-06-30 12:32:081190 if host_platform == 'darwin':
Ronald Oussoren2c12ab12010-06-03 14:42:251191 sysroot = macosx_sdk_root()
1192
Ned Deily9b635832012-08-05 22:13:331193 for d_ in inc_dirs + sqlite_inc_paths:
1194 d = d_
doko@ubuntu.com93df16b2012-06-30 12:32:081195 if host_platform == 'darwin' and is_macosx_sdk_path(d):
Ned Deily9b635832012-08-05 22:13:331196 d = os.path.join(sysroot, d[1:])
Ronald Oussoren2c12ab12010-06-03 14:42:251197
Ned Deily9b635832012-08-05 22:13:331198 f = os.path.join(d, "sqlite3.h")
Thomas Wouters49fd7fa2006-04-21 10:40:581199 if os.path.exists(f):
Guido van Rossum452bf512007-02-09 05:32:431200 if sqlite_setup_debug: print("sqlite: found %s"%f)
Brett Cannon9f5db072010-10-29 20:19:271201 with open(f) as file:
1202 incf = file.read()
Thomas Wouters49fd7fa2006-04-21 10:40:581203 m = re.search(
Petri Lehtinened909bc2013-02-23 16:05:281204 r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"([\d\.]*)"', incf)
Thomas Wouters49fd7fa2006-04-21 10:40:581205 if m:
1206 sqlite_version = m.group(1)
1207 sqlite_version_tuple = tuple([int(x)
1208 for x in sqlite_version.split(".")])
1209 if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER:
1210 # we win!
Thomas Wouters89f507f2006-12-13 04:49:301211 if sqlite_setup_debug:
Guido van Rossum452bf512007-02-09 05:32:431212 print("%s/sqlite3.h: version %s"%(d, sqlite_version))
Thomas Wouters49fd7fa2006-04-21 10:40:581213 sqlite_incdir = d
1214 break
1215 else:
1216 if sqlite_setup_debug:
Miss Islington (bot)967f14e2019-04-26 16:15:311217 print("%s: version %s is too old, need >= %s"%(d,
Guido van Rossum452bf512007-02-09 05:32:431218 sqlite_version, MIN_SQLITE_VERSION))
Thomas Wouters49fd7fa2006-04-21 10:40:581219 elif sqlite_setup_debug:
Guido van Rossum452bf512007-02-09 05:32:431220 print("sqlite: %s had no SQLITE_VERSION"%(f,))
Thomas Wouters49fd7fa2006-04-21 10:40:581221
1222 if sqlite_incdir:
1223 sqlite_dirs_to_check = [
1224 os.path.join(sqlite_incdir, '..', 'lib64'),
1225 os.path.join(sqlite_incdir, '..', 'lib'),
1226 os.path.join(sqlite_incdir, '..', '..', 'lib64'),
1227 os.path.join(sqlite_incdir, '..', '..', 'lib'),
1228 ]
Tarek Ziadé36797272010-07-22 12:50:051229 sqlite_libfile = self.compiler.find_library_file(
Thomas Wouters49fd7fa2006-04-21 10:40:581230 sqlite_dirs_to_check + lib_dirs, 'sqlite3')
Benjamin Petersonf10a79a2008-10-11 00:49:571231 if sqlite_libfile:
1232 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))]
Thomas Wouters49fd7fa2006-04-21 10:40:581233
1234 if sqlite_incdir and sqlite_libdir:
Thomas Wouters477c8d52006-05-27 19:21:471235 sqlite_srcs = ['_sqlite/cache.c',
Thomas Wouters49fd7fa2006-04-21 10:40:581236 '_sqlite/connection.c',
Thomas Wouters49fd7fa2006-04-21 10:40:581237 '_sqlite/cursor.c',
1238 '_sqlite/microprotocols.c',
1239 '_sqlite/module.c',
1240 '_sqlite/prepare_protocol.c',
1241 '_sqlite/row.c',
1242 '_sqlite/statement.c',
1243 '_sqlite/util.c', ]
1244
Thomas Wouters49fd7fa2006-04-21 10:40:581245 sqlite_defines = []
doko@ubuntu.com93df16b2012-06-30 12:32:081246 if host_platform != "win32":
Thomas Wouters49fd7fa2006-04-21 10:40:581247 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
1248 else:
1249 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
1250
Benjamin Peterson076ed002010-10-31 17:11:021251 # Enable support for loadable extensions in the sqlite3 module
1252 # if --enable-loadable-sqlite-extensions configure option is used.
1253 if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
1254 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
Thomas Wouters477c8d52006-05-27 19:21:471255
doko@ubuntu.com93df16b2012-06-30 12:32:081256 if host_platform == 'darwin':
Thomas Wouters477c8d52006-05-27 19:21:471257 # In every directory on the search path search for a dynamic
1258 # library and then a static library, instead of first looking
Ezio Melotti13925002011-03-16 09:05:331259 # for dynamic libraries on the entire path.
1260 # This way a statically linked custom sqlite gets picked up
Thomas Wouters477c8d52006-05-27 19:21:471261 # before the dynamic library in /usr/lib.
1262 sqlite_extra_link_args = ('-Wl,-search_paths_first',)
1263 else:
1264 sqlite_extra_link_args = ()
Thomas Wouters49fd7fa2006-04-21 10:40:581265
Brett Cannonc5011fe2011-06-07 03:09:101266 include_dirs = ["Modules/_sqlite"]
1267 # Only include the directory where sqlite was found if it does
1268 # not already exist in set include directories, otherwise you
1269 # can end up with a bad search path order.
1270 if sqlite_incdir not in self.compiler.include_dirs:
1271 include_dirs.append(sqlite_incdir)
doko@ubuntu.coma3818a32014-04-17 15:52:481272 # avoid a runtime library path for a system library dir
1273 if sqlite_libdir and sqlite_libdir[0] in lib_dirs:
1274 sqlite_libdir = None
Thomas Wouters49fd7fa2006-04-21 10:40:581275 exts.append(Extension('_sqlite3', sqlite_srcs,
1276 define_macros=sqlite_defines,
Brett Cannonc5011fe2011-06-07 03:09:101277 include_dirs=include_dirs,
Thomas Wouters49fd7fa2006-04-21 10:40:581278 library_dirs=sqlite_libdir,
Thomas Wouters477c8d52006-05-27 19:21:471279 extra_link_args=sqlite_extra_link_args,
Thomas Wouters49fd7fa2006-04-21 10:40:581280 libraries=["sqlite3",]))
Guido van Rossumd8faa362007-04-27 19:54:291281 else:
1282 missing.append('_sqlite3')
Skip Montanaro22e00c42003-05-06 20:43:341283
Ross Lagerwall0b63b562012-04-15 06:19:351284 dbm_setup_debug = False # verbose debug prints from this script?
Benjamin Petersond78735d2010-01-01 16:04:231285 dbm_order = ['gdbm']
Andrew M. Kuchling00e0f212001-01-17 15:23:231286 # The standard Unix dbm module:
doko@ubuntu.com93df16b2012-06-30 12:32:081287 if host_platform not in ['cygwin']:
Matthias Klose55708cc2009-04-30 08:06:491288 config_args = [arg.strip("'")
1289 for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
Benjamin Petersond78735d2010-01-01 16:04:231290 dbm_args = [arg for arg in config_args
Matthias Klose55708cc2009-04-30 08:06:491291 if arg.startswith('--with-dbmliborder=')]
1292 if dbm_args:
Benjamin Petersond78735d2010-01-01 16:04:231293 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
Matthias Klose55708cc2009-04-30 08:06:491294 else:
Georg Brandl489cb4f2009-07-11 10:08:491295 dbm_order = "ndbm:gdbm:bdb".split(":")
Matthias Klose55708cc2009-04-30 08:06:491296 dbmext = None
1297 for cand in dbm_order:
1298 if cand == "ndbm":
1299 if find_file("ndbm.h", inc_dirs, []) is not None:
Nick Coghlan50f147a2012-06-17 08:27:111300 # Some systems have -lndbm, others have -lgdbm_compat,
1301 # others don't have either
Tarek Ziadé36797272010-07-22 12:50:051302 if self.compiler.find_library_file(lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171303 'ndbm'):
Matthias Klose55708cc2009-04-30 08:06:491304 ndbm_libs = ['ndbm']
Nick Coghlan50f147a2012-06-17 08:27:111305 elif self.compiler.find_library_file(lib_dirs,
1306 'gdbm_compat'):
1307 ndbm_libs = ['gdbm_compat']
Matthias Klose55708cc2009-04-30 08:06:491308 else:
1309 ndbm_libs = []
Ross Lagerwall0b63b562012-04-15 06:19:351310 if dbm_setup_debug: print("building dbm using ndbm")
Matthias Klose55708cc2009-04-30 08:06:491311 dbmext = Extension('_dbm', ['_dbmmodule.c'],
1312 define_macros=[
1313 ('HAVE_NDBM_H',None),
1314 ],
1315 libraries=ndbm_libs)
1316 break
1317
1318 elif cand == "gdbm":
Tarek Ziadé36797272010-07-22 12:50:051319 if self.compiler.find_library_file(lib_dirs, 'gdbm'):
Matthias Klose55708cc2009-04-30 08:06:491320 gdbm_libs = ['gdbm']
Tarek Ziadé36797272010-07-22 12:50:051321 if self.compiler.find_library_file(lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171322 'gdbm_compat'):
Matthias Klose55708cc2009-04-30 08:06:491323 gdbm_libs.append('gdbm_compat')
1324 if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
Ross Lagerwall0b63b562012-04-15 06:19:351325 if dbm_setup_debug: print("building dbm using gdbm")
Matthias Klose55708cc2009-04-30 08:06:491326 dbmext = Extension(
1327 '_dbm', ['_dbmmodule.c'],
1328 define_macros=[
1329 ('HAVE_GDBM_NDBM_H', None),
1330 ],
1331 libraries = gdbm_libs)
1332 break
1333 if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
Ross Lagerwall0b63b562012-04-15 06:19:351334 if dbm_setup_debug: print("building dbm using gdbm")
Matthias Klose55708cc2009-04-30 08:06:491335 dbmext = Extension(
1336 '_dbm', ['_dbmmodule.c'],
1337 define_macros=[
1338 ('HAVE_GDBM_DASH_NDBM_H', None),
1339 ],
1340 libraries = gdbm_libs)
1341 break
Georg Brandl489cb4f2009-07-11 10:08:491342 elif cand == "bdb":
doko@ubuntu.coma3818a32014-04-17 15:52:481343 if dblibs:
Ross Lagerwall0b63b562012-04-15 06:19:351344 if dbm_setup_debug: print("building dbm using bdb")
Georg Brandl489cb4f2009-07-11 10:08:491345 dbmext = Extension('_dbm', ['_dbmmodule.c'],
1346 library_dirs=dblib_dir,
1347 runtime_library_dirs=dblib_dir,
1348 include_dirs=db_incs,
1349 define_macros=[
1350 ('HAVE_BERKDB_H', None),
1351 ('DB_DBM_HSEARCH', None),
1352 ],
1353 libraries=dblibs)
Matthias Klose55708cc2009-04-30 08:06:491354 break
1355 if dbmext is not None:
1356 exts.append(dbmext)
Guido van Rossumd8faa362007-04-27 19:54:291357 else:
Georg Brandl0a7ac7d2008-05-26 10:29:351358 missing.append('_dbm')
Fredrik Lundhade711a2001-01-24 08:00:281359
Andrew M. Kuchling00e0f212001-01-17 15:23:231360 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
Benjamin Petersond78735d2010-01-01 16:04:231361 if ('gdbm' in dbm_order and
Tarek Ziadé36797272010-07-22 12:50:051362 self.compiler.find_library_file(lib_dirs, 'gdbm')):
Georg Brandl0a7ac7d2008-05-26 10:29:351363 exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
Andrew M. Kuchling00e0f212001-01-17 15:23:231364 libraries = ['gdbm'] ) )
Guido van Rossumd8faa362007-04-27 19:54:291365 else:
Georg Brandl0a7ac7d2008-05-26 10:29:351366 missing.append('_gdbm')
Andrew M. Kuchling00e0f212001-01-17 15:23:231367
Andrew M. Kuchling00e0f212001-01-17 15:23:231368 # Unix-only modules
doko@ubuntu.com93df16b2012-06-30 12:32:081369 if host_platform != 'win32':
Andrew M. Kuchling00e0f212001-01-17 15:23:231370 # Steen Lumholt's termios module
1371 exts.append( Extension('termios', ['termios.c']) )
1372 # Jeremy Hylton's rlimit interface
Antoine Pitrou6103ab12009-10-24 20:11:211373 exts.append( Extension('resource', ['resource.c']) )
Guido van Rossumd8faa362007-04-27 19:54:291374 else:
Christian Heimes29a7df72018-01-26 22:28:461375 missing.extend(['resource', 'termios'])
1376
1377 nis = self._detect_nis(inc_dirs, lib_dirs)
1378 if nis is not None:
1379 exts.append(nis)
1380 else:
1381 missing.append('nis')
Andrew M. Kuchling00e0f212001-01-17 15:23:231382
Skip Montanaro72092942004-02-07 12:50:191383 # Curses support, requiring the System V version of curses, often
Fredrik Lundhade711a2001-01-24 08:00:281384 # provided by the ncurses library.
Victor Stinneraa35b002011-11-28 23:08:121385 curses_defines = []
Victor Stinner756c6ec2011-11-26 23:19:531386 curses_includes = []
Victor Stinneraa35b002011-11-28 23:08:121387 panel_library = 'panel'
1388 if curses_library == 'ncursesw':
1389 curses_defines.append(('HAVE_NCURSESW', '1'))
Xavier de Gayee13c3202016-12-13 15:04:141390 if not cross_compiling:
1391 curses_includes.append('/usr/include/ncursesw')
Victor Stinneraa35b002011-11-28 23:08:121392 # Bug 1464056: If _curses.so links with ncursesw,
1393 # _curses_panel.so must link with panelw.
1394 panel_library = 'panelw'
doko@ubuntu.com93df16b2012-06-30 12:32:081395 if host_platform == 'darwin':
Ned Deily69192232012-06-21 06:47:141396 # On OS X, there is no separate /usr/lib/libncursesw nor
1397 # libpanelw. If we are here, we found a locally-supplied
Mike53f7a7c2017-12-14 11:04:531398 # version of libncursesw. There should also be a
Ned Deily69192232012-06-21 06:47:141399 # libpanelw. _XOPEN_SOURCE defines are usually excluded
1400 # for OS X but we need _XOPEN_SOURCE_EXTENDED here for
1401 # ncurses wide char support
1402 curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
doko@ubuntu.com93df16b2012-06-30 12:32:081403 elif host_platform == 'darwin' and curses_library == 'ncurses':
Ned Deily69192232012-06-21 06:47:141404 # Building with the system-suppied combined libncurses/libpanel
1405 curses_defines.append(('HAVE_NCURSESW', '1'))
1406 curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
Victor Stinneraa35b002011-11-28 23:08:121407
Stefan Krah095b2732010-06-08 13:41:441408 if curses_library.startswith('ncurses'):
Stefan Krah095b2732010-06-08 13:41:441409 curses_libs = [curses_library]
Martin v. Löwisa55e55e2006-02-11 15:55:141410 exts.append( Extension('_curses', ['_cursesmodule.c'],
Victor Stinner756c6ec2011-11-26 23:19:531411 include_dirs=curses_includes,
Nadeem Vawda9e2e9902011-07-31 13:01:111412 define_macros=curses_defines,
Martin v. Löwisa55e55e2006-02-11 15:55:141413 libraries = curses_libs) )
doko@ubuntu.com93df16b2012-06-30 12:32:081414 elif curses_library == 'curses' and host_platform != 'darwin':
Michael W. Hudson5b109102002-01-23 15:04:411415 # OSX has an old Berkeley curses, not good enough for
1416 # the _curses module.
Tarek Ziadé36797272010-07-22 12:50:051417 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
Andrew M. Kuchling00e0f212001-01-17 15:23:231418 curses_libs = ['curses', 'terminfo']
Tarek Ziadé36797272010-07-22 12:50:051419 elif (self.compiler.find_library_file(lib_dirs, 'termcap')):
Andrew M. Kuchling00e0f212001-01-17 15:23:231420 curses_libs = ['curses', 'termcap']
Neal Norwitz0b27ff92003-03-31 15:53:491421 else:
1422 curses_libs = ['curses']
Fredrik Lundhade711a2001-01-24 08:00:281423
Andrew M. Kuchling00e0f212001-01-17 15:23:231424 exts.append( Extension('_curses', ['_cursesmodule.c'],
Nadeem Vawda9e2e9902011-07-31 13:01:111425 define_macros=curses_defines,
Andrew M. Kuchling00e0f212001-01-17 15:23:231426 libraries = curses_libs) )
Guido van Rossumd8faa362007-04-27 19:54:291427 else:
1428 missing.append('_curses')
Fredrik Lundhade711a2001-01-24 08:00:281429
Andrew M. Kuchling00e0f212001-01-17 15:23:231430 # If the curses module is enabled, check for the panel module
Andrew M. Kuchlinge7ffbb22001-12-06 15:57:161431 if (module_enabled(exts, '_curses') and
Tarek Ziadé36797272010-07-22 12:50:051432 self.compiler.find_library_file(lib_dirs, panel_library)):
Andrew M. Kuchling00e0f212001-01-17 15:23:231433 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
Victor Stinner756c6ec2011-11-26 23:19:531434 include_dirs=curses_includes,
Ned Deily69192232012-06-21 06:47:141435 define_macros=curses_defines,
Thomas Wouters0e3f5912006-08-11 14:57:121436 libraries = [panel_library] + curses_libs) )
Guido van Rossumd8faa362007-04-27 19:54:291437 else:
1438 missing.append('_curses_panel')
Fredrik Lundhade711a2001-01-24 08:00:281439
Barry Warsaw259b1e12002-08-13 20:09:261440 # Andrew Kuchling's zlib module. Note that some versions of zlib
1441 # 1.1.3 have security problems. See CERT Advisory CA-2002-07:
1442 # http://www.cert.org/advisories/CA-2002-07.html
1443 #
1444 # zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to
1445 # patch its zlib 1.1.3 package instead of upgrading to 1.1.4. For
1446 # now, we still accept 1.1.3, because we think it's difficult to
1447 # exploit this in Python, and we'd rather make it RedHat's problem
1448 # than our problem <wink>.
1449 #
1450 # You can upgrade zlib to version 1.1.4 yourself by going to
1451 # http://www.gzip.org/zlib/
Guido van Rossume6970912001-04-15 15:16:121452 zlib_inc = find_file('zlib.h', [], inc_dirs)
Christian Heimes1dc54002008-03-24 02:19:291453 have_zlib = False
Guido van Rossume6970912001-04-15 15:16:121454 if zlib_inc is not None:
1455 zlib_h = zlib_inc[0] + '/zlib.h'
1456 version = '"0.0.0"'
Barry Warsaw259b1e12002-08-13 20:09:261457 version_req = '"1.1.3"'
Ned Deily507c5912013-10-19 04:32:001458 if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
1459 zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
Brett Cannon9f5db072010-10-29 20:19:271460 with open(zlib_h) as fp:
1461 while 1:
1462 line = fp.readline()
1463 if not line:
1464 break
1465 if line.startswith('#define ZLIB_VERSION'):
1466 version = line.split()[2]
1467 break
Guido van Rossume6970912001-04-15 15:16:121468 if version >= version_req:
Tarek Ziadé36797272010-07-22 12:50:051469 if (self.compiler.find_library_file(lib_dirs, 'z')):
doko@ubuntu.com93df16b2012-06-30 12:32:081470 if host_platform == "darwin":
Thomas Wouters0e3f5912006-08-11 14:57:121471 zlib_extra_link_args = ('-Wl,-search_paths_first',)
1472 else:
1473 zlib_extra_link_args = ()
Guido van Rossume6970912001-04-15 15:16:121474 exts.append( Extension('zlib', ['zlibmodule.c'],
Thomas Wouters0e3f5912006-08-11 14:57:121475 libraries = ['z'],
1476 extra_link_args = zlib_extra_link_args))
Christian Heimes1dc54002008-03-24 02:19:291477 have_zlib = True
Guido van Rossumd8faa362007-04-27 19:54:291478 else:
1479 missing.append('zlib')
1480 else:
1481 missing.append('zlib')
1482 else:
1483 missing.append('zlib')
Andrew M. Kuchling00e0f212001-01-17 15:23:231484
Christian Heimes1dc54002008-03-24 02:19:291485 # Helper module for various ascii-encoders. Uses zlib for an optimized
1486 # crc32 if we have it. Otherwise binascii uses its own.
1487 if have_zlib:
1488 extra_compile_args = ['-DUSE_ZLIB_CRC32']
1489 libraries = ['z']
1490 extra_link_args = zlib_extra_link_args
1491 else:
1492 extra_compile_args = []
1493 libraries = []
1494 extra_link_args = []
1495 exts.append( Extension('binascii', ['binascii.c'],
1496 extra_compile_args = extra_compile_args,
1497 libraries = libraries,
1498 extra_link_args = extra_link_args) )
1499
Gustavo Niemeyerf8ca8362002-11-05 16:50:051500 # Gustavo Niemeyer's bz2 module.
Tarek Ziadé36797272010-07-22 12:50:051501 if (self.compiler.find_library_file(lib_dirs, 'bz2')):
doko@ubuntu.com93df16b2012-06-30 12:32:081502 if host_platform == "darwin":
Thomas Wouters0e3f5912006-08-11 14:57:121503 bz2_extra_link_args = ('-Wl,-search_paths_first',)
1504 else:
1505 bz2_extra_link_args = ()
Antoine Pitrou37dc5f82011-04-03 15:05:461506 exts.append( Extension('_bz2', ['_bz2module.c'],
Thomas Wouters0e3f5912006-08-11 14:57:121507 libraries = ['bz2'],
1508 extra_link_args = bz2_extra_link_args) )
Guido van Rossumd8faa362007-04-27 19:54:291509 else:
Antoine Pitrou37dc5f82011-04-03 15:05:461510 missing.append('_bz2')
Gustavo Niemeyerf8ca8362002-11-05 16:50:051511
Nadeem Vawda3ff069e2011-11-29 22:25:061512 # LZMA compression support.
1513 if self.compiler.find_library_file(lib_dirs, 'lzma'):
1514 exts.append( Extension('_lzma', ['_lzmamodule.c'],
1515 libraries = ['lzma']) )
1516 else:
1517 missing.append('_lzma')
1518
Andrew M. Kuchling00e0f212001-01-17 15:23:231519 # Interface to the Expat XML parser
1520 #
Benjamin Petersona28e7022010-01-09 18:53:061521 # Expat was written by James Clark and is now maintained by a group of
1522 # developers on SourceForge; see www.libexpat.org for more information.
1523 # The pyexpat module was written by Paul Prescod after a prototype by
1524 # Jack Jansen. The Expat source is included in Modules/expat/. Usage
1525 # of a system shared libexpat.so is possible with --with-system-expat
Benjamin Petersonc73206c2010-10-31 16:38:191526 # configure option.
Fred Drakefc8341d2002-06-17 17:55:301527 #
1528 # More information on Expat can be found at www.libexpat.org.
1529 #
Benjamin Petersonb2d90462009-12-31 03:23:101530 if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
1531 expat_inc = []
1532 define_macros = []
Stefan Krah9e1e6f52017-08-25 12:07:501533 extra_compile_args = []
Benjamin Petersonb2d90462009-12-31 03:23:101534 expat_lib = ['expat']
1535 expat_sources = []
Christian Heimesd489c7a2013-02-09 16:02:061536 expat_depends = []
Benjamin Petersonb2d90462009-12-31 03:23:101537 else:
1538 expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')]
1539 define_macros = [
1540 ('HAVE_EXPAT_CONFIG_H', '1'),
Victor Stinner93d0cb52017-08-18 21:43:541541 # bpo-30947: Python uses best available entropy sources to
1542 # call XML_SetHashSalt(), expat entropy sources are not needed
1543 ('XML_POOR_ENTROPY', '1'),
Benjamin Petersonb2d90462009-12-31 03:23:101544 ]
Stefan Krah9e1e6f52017-08-25 12:07:501545 extra_compile_args = []
Benjamin Petersonb2d90462009-12-31 03:23:101546 expat_lib = []
1547 expat_sources = ['expat/xmlparse.c',
1548 'expat/xmlrole.c',
1549 'expat/xmltok.c']
Christian Heimesd489c7a2013-02-09 16:02:061550 expat_depends = ['expat/ascii.h',
1551 'expat/asciitab.h',
1552 'expat/expat.h',
1553 'expat/expat_config.h',
1554 'expat/expat_external.h',
1555 'expat/internal.h',
1556 'expat/latin1tab.h',
1557 'expat/utf8tab.h',
1558 'expat/xmlrole.h',
1559 'expat/xmltok.h',
1560 'expat/xmltok_impl.h'
1561 ]
Thomas Wouters477c8d52006-05-27 19:21:471562
Stefan Krah9e1e6f52017-08-25 12:07:501563 cc = sysconfig.get_config_var('CC').split()[0]
1564 ret = os.system(
Miss Islington (bot)ffa419a2019-06-29 23:16:441565 '"%s" -Werror -Wno-unreachable-code -E -xc /dev/null >/dev/null 2>&1' % cc)
Stefan Krah9e1e6f52017-08-25 12:07:501566 if ret >> 8 == 0:
Miss Islington (bot)ffa419a2019-06-29 23:16:441567 extra_compile_args.append('-Wno-unreachable-code')
Stefan Krah9e1e6f52017-08-25 12:07:501568
Fred Drake2d59a492003-10-21 15:41:151569 exts.append(Extension('pyexpat',
1570 define_macros = define_macros,
Stefan Krah9e1e6f52017-08-25 12:07:501571 extra_compile_args = extra_compile_args,
Benjamin Petersonb2d90462009-12-31 03:23:101572 include_dirs = expat_inc,
1573 libraries = expat_lib,
Christian Heimesd489c7a2013-02-09 16:02:061574 sources = ['pyexpat.c'] + expat_sources,
1575 depends = expat_depends,
Fred Drake2d59a492003-10-21 15:41:151576 ))
Andrew M. Kuchling00e0f212001-01-17 15:23:231577
Fredrik Lundh4c86ec62005-12-14 18:46:161578 # Fredrik Lundh's cElementTree module. Note that this also
1579 # uses expat (via the CAPI hook in pyexpat).
1580
Thomas Wouters49fd7fa2006-04-21 10:40:581581 if os.path.isfile(os.path.join(srcdir, 'Modules', '_elementtree.c')):
Fredrik Lundh4c86ec62005-12-14 18:46:161582 define_macros.append(('USE_PYEXPAT_CAPI', None))
1583 exts.append(Extension('_elementtree',
1584 define_macros = define_macros,
Benjamin Petersonb2d90462009-12-31 03:23:101585 include_dirs = expat_inc,
1586 libraries = expat_lib,
Fredrik Lundh4c86ec62005-12-14 18:46:161587 sources = ['_elementtree.c'],
Christian Heimesd489c7a2013-02-09 16:02:061588 depends = ['pyexpat.c'] + expat_sources +
1589 expat_depends,
Fredrik Lundh4c86ec62005-12-14 18:46:161590 ))
Guido van Rossumd8faa362007-04-27 19:54:291591 else:
1592 missing.append('_elementtree')
Fredrik Lundh4c86ec62005-12-14 18:46:161593
Hye-Shik Chang3e2a3062004-01-17 14:29:291594 # Hye-Shik Chang's CJKCodecs modules.
Walter Dörwalde9eaab42007-05-22 16:02:131595 exts.append(Extension('_multibytecodec',
1596 ['cjkcodecs/multibytecodec.c']))
1597 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
1598 exts.append(Extension('_codecs_%s' % loc,
1599 ['cjkcodecs/_codecs_%s.c' % loc]))
Hye-Shik Chang3e2a3062004-01-17 14:29:291600
Stefan Krah1919b7e2012-03-21 17:25:231601 # Stefan Krah's _decimal module
1602 exts.append(self._decimal_ext())
1603
Thomas Hellercf567c12006-03-08 19:51:581604 # Thomas Heller's _ctypes module
Thomas Wouters49fd7fa2006-04-21 10:40:581605 self.detect_ctypes(inc_dirs, lib_dirs)
Thomas Hellercf567c12006-03-08 19:51:581606
Benjamin Petersone711caf2008-06-11 16:44:041607 # Richard Oudkerk's multiprocessing module
doko@ubuntu.com93df16b2012-06-30 12:32:081608 if host_platform == 'win32': # Windows
Benjamin Petersone711caf2008-06-11 16:44:041609 macros = dict()
1610 libraries = ['ws2_32']
1611
doko@ubuntu.com93df16b2012-06-30 12:32:081612 elif host_platform == 'darwin': # Mac OSX
Benjamin Peterson965ce872009-04-05 21:24:581613 macros = dict()
Benjamin Petersone711caf2008-06-11 16:44:041614 libraries = []
1615
doko@ubuntu.com93df16b2012-06-30 12:32:081616 elif host_platform == 'cygwin': # Cygwin
Benjamin Peterson965ce872009-04-05 21:24:581617 macros = dict()
Benjamin Petersone711caf2008-06-11 16:44:041618 libraries = []
Benjamin Peterson41181742008-07-02 20:22:541619
doko@ubuntu.com93df16b2012-06-30 12:32:081620 elif host_platform.startswith('openbsd'):
Benjamin Peterson965ce872009-04-05 21:24:581621 macros = dict()
Benjamin Petersone5384b02008-10-04 22:00:421622 libraries = []
1623
doko@ubuntu.com93df16b2012-06-30 12:32:081624 elif host_platform.startswith('netbsd'):
Benjamin Peterson965ce872009-04-05 21:24:581625 macros = dict()
Jesse Noller32d68c22009-03-31 18:48:421626 libraries = []
1627
Benjamin Petersone711caf2008-06-11 16:44:041628 else: # Linux and other unices
Benjamin Peterson965ce872009-04-05 21:24:581629 macros = dict()
Benjamin Petersone711caf2008-06-11 16:44:041630 libraries = ['rt']
1631
doko@ubuntu.com93df16b2012-06-30 12:32:081632 if host_platform == 'win32':
Benjamin Petersone711caf2008-06-11 16:44:041633 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
1634 '_multiprocessing/semaphore.c',
Benjamin Petersone711caf2008-06-11 16:44:041635 ]
1636
1637 else:
1638 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
Benjamin Petersone711caf2008-06-11 16:44:041639 ]
Mark Dickinsona614f042009-11-28 12:48:431640 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not
1641 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
Benjamin Petersone711caf2008-06-11 16:44:041642 multiprocessing_srcs.append('_multiprocessing/semaphore.c')
1643
Antoine Pitroua6a4dc82017-09-07 16:56:241644 exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
1645 define_macros=list(macros.items()),
1646 include_dirs=["Modules/_multiprocessing"]))
Benjamin Petersone711caf2008-06-11 16:44:041647 # End multiprocessing
Guido van Rossuma9e20242007-03-08 00:43:481648
Andrew M. Kuchling00e0f212001-01-17 15:23:231649 # Platform-specific libraries
doko@ubuntu.com93df16b2012-06-30 12:32:081650 if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')):
Guido van Rossum0c016a92003-02-13 16:12:211651 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
Guido van Rossumd8faa362007-04-27 19:54:291652 else:
1653 missing.append('ossaudiodev')
Andrew M. Kuchling00e0f212001-01-17 15:23:231654
doko@ubuntu.com93df16b2012-06-30 12:32:081655 if host_platform == 'darwin':
Benjamin Petersonebacd262008-05-29 21:09:511656 exts.append(
Ronald Oussoren84151202010-04-18 20:46:111657 Extension('_scproxy', ['_scproxy.c'],
1658 extra_link_args=[
1659 '-framework', 'SystemConfiguration',
1660 '-framework', 'CoreFoundation',
1661 ]))
Benjamin Petersonebacd262008-05-29 21:09:511662
Andrew M. Kuchlingfbe73762001-01-18 18:44:201663 self.extensions.extend(exts)
1664
1665 # Call the method for detecting whether _tkinter can be compiled
1666 self.detect_tkinter(inc_dirs, lib_dirs)
Fredrik Lundhade711a2001-01-24 08:00:281667
Guido van Rossumd8faa362007-04-27 19:54:291668 if '_tkinter' not in [e.name for e in self.extensions]:
1669 missing.append('_tkinter')
1670
Antoine Pitroua106aec2017-09-28 21:03:061671 # Build the _uuid module if possible
1672 uuid_incs = find_file("uuid.h", inc_dirs, ["/usr/include/uuid"])
Nick Coghlan53efbf32017-11-26 03:04:461673 if uuid_incs is not None:
Antoine Pitroua106aec2017-09-28 21:03:061674 if self.compiler.find_library_file(lib_dirs, 'uuid'):
1675 uuid_libs = ['uuid']
1676 else:
1677 uuid_libs = []
Antoine Pitroua106aec2017-09-28 21:03:061678 self.extensions.append(Extension('_uuid', ['_uuidmodule.c'],
1679 libraries=uuid_libs,
1680 include_dirs=uuid_incs))
1681 else:
1682 missing.append('_uuid')
1683
Ned Deilycd3d8fb2013-08-02 06:51:271684## # Uncomment these lines if you want to play with xxmodule.c
1685## ext = Extension('xx', ['xxmodule.c'])
1686## self.extensions.append(ext)
1687
Xavier de Gaye13f1c332016-12-10 15:45:531688 if 'd' not in sysconfig.get_config_var('ABIFLAGS'):
Ned Deilycd3d8fb2013-08-02 06:51:271689 ext = Extension('xxlimited', ['xxlimited.c'],
Benjamin Peterson24ac8772015-06-03 05:04:461690 define_macros=[('Py_LIMITED_API', '0x03050000')])
Ned Deilycd3d8fb2013-08-02 06:51:271691 self.extensions.append(ext)
1692
Guido van Rossumd8faa362007-04-27 19:54:291693 return missing
1694
Ned Deilyd819b932013-09-06 08:07:051695 def detect_tkinter_explicitly(self):
1696 # Build _tkinter using explicit locations for Tcl/Tk.
1697 #
1698 # This is enabled when both arguments are given to ./configure:
1699 #
1700 # --with-tcltk-includes="-I/path/to/tclincludes \
1701 # -I/path/to/tkincludes"
1702 # --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
1703 # -L/path/to/tklibs -ltkm.n"
1704 #
Martin Pantere26da7c2016-06-02 10:07:091705 # These values can also be specified or overridden via make:
Ned Deilyd819b932013-09-06 08:07:051706 # make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
1707 #
1708 # This can be useful for building and testing tkinter with multiple
1709 # versions of Tcl/Tk. Note that a build of Tk depends on a particular
1710 # build of Tcl so you need to specify both arguments and use care when
1711 # overriding.
1712
1713 # The _TCLTK variables are created in the Makefile sharedmods target.
1714 tcltk_includes = os.environ.get('_TCLTK_INCLUDES')
1715 tcltk_libs = os.environ.get('_TCLTK_LIBS')
1716 if not (tcltk_includes and tcltk_libs):
1717 # Resume default configuration search.
1718 return 0
1719
1720 extra_compile_args = tcltk_includes.split()
1721 extra_link_args = tcltk_libs.split()
1722 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1723 define_macros=[('WITH_APPINIT', 1)],
1724 extra_compile_args = extra_compile_args,
1725 extra_link_args = extra_link_args,
1726 )
1727 self.extensions.append(ext)
1728 return 1
1729
Jack Jansen0b06be72002-06-21 14:48:381730 def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
1731 # The _tkinter module, using frameworks. Since frameworks are quite
1732 # different the UNIX search logic is not sharable.
1733 from os.path import join, exists
1734 framework_dirs = [
Tim Peters2c60f7a2003-01-29 03:49:431735 '/Library/Frameworks',
Ronald Oussoren5f734f12009-03-04 21:32:481736 '/System/Library/Frameworks/',
Jack Jansen0b06be72002-06-21 14:48:381737 join(os.getenv('HOME'), '/Library/Frameworks')
1738 ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:201739
Ronald Oussoren2c12ab12010-06-03 14:42:251740 sysroot = macosx_sdk_root()
1741
Skip Montanaro0174ddd2005-12-30 05:01:261742 # Find the directory that contains the Tcl.framework and Tk.framework
Jack Jansen0b06be72002-06-21 14:48:381743 # bundles.
1744 # XXX distutils should support -F!
1745 for F in framework_dirs:
Tim Peters2c60f7a2003-01-29 03:49:431746 # both Tcl.framework and Tk.framework should be present
Ronald Oussoren2c12ab12010-06-03 14:42:251747
1748
Jack Jansen0b06be72002-06-21 14:48:381749 for fw in 'Tcl', 'Tk':
Ronald Oussoren2c12ab12010-06-03 14:42:251750 if is_macosx_sdk_path(F):
1751 if not exists(join(sysroot, F[1:], fw + '.framework')):
1752 break
1753 else:
1754 if not exists(join(F, fw + '.framework')):
1755 break
Jack Jansen0b06be72002-06-21 14:48:381756 else:
1757 # ok, F is now directory with both frameworks. Continure
1758 # building
1759 break
1760 else:
1761 # Tk and Tcl frameworks not found. Normal "unix" tkinter search
1762 # will now resume.
1763 return 0
Tim Peters2c60f7a2003-01-29 03:49:431764
Jack Jansen0b06be72002-06-21 14:48:381765 # For 8.4a2, we must add -I options that point inside the Tcl and Tk
1766 # frameworks. In later release we should hopefully be able to pass
Tim Peters2c60f7a2003-01-29 03:49:431767 # the -F option to gcc, which specifies a framework lookup path.
Jack Jansen0b06be72002-06-21 14:48:381768 #
1769 include_dirs = [
Tim Peters2c60f7a2003-01-29 03:49:431770 join(F, fw + '.framework', H)
Nick Coghlan650f0d02007-04-15 12:05:431771 for fw in ('Tcl', 'Tk')
1772 for H in ('Headers', 'Versions/Current/PrivateHeaders')
Jack Jansen0b06be72002-06-21 14:48:381773 ]
1774
Tim Peters2c60f7a2003-01-29 03:49:431775 # For 8.4a2, the X11 headers are not included. Rather than include a
Jack Jansen0b06be72002-06-21 14:48:381776 # complicated search, this is a hard-coded path. It could bail out
1777 # if X11 libs are not found...
1778 include_dirs.append('/usr/X11R6/include')
1779 frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
1780
Georg Brandlfcaf9102008-07-16 02:17:561781 # All existing framework builds of Tcl/Tk don't support 64-bit
1782 # architectures.
1783 cflags = sysconfig.get_config_vars('CFLAGS')[0]
R David Murray44b548d2016-09-08 17:59:531784 archs = re.findall(r'-arch\s+(\w+)', cflags)
Georg Brandlfcaf9102008-07-16 02:17:561785
Ronald Oussorend097efe2009-09-15 19:07:581786 tmpfile = os.path.join(self.build_temp, 'tk.arch')
1787 if not os.path.exists(self.build_temp):
1788 os.makedirs(self.build_temp)
1789
1790 # Note: cannot use os.popen or subprocess here, that
1791 # requires extensions that are not available here.
Ronald Oussoren2c12ab12010-06-03 14:42:251792 if is_macosx_sdk_path(F):
1793 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(os.path.join(sysroot, F[1:]), tmpfile))
1794 else:
1795 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(F, tmpfile))
Ronald Oussoren2c12ab12010-06-03 14:42:251796
Brett Cannon9f5db072010-10-29 20:19:271797 with open(tmpfile) as fp:
1798 detected_archs = []
1799 for ln in fp:
1800 a = ln.split()[-1]
1801 if a in archs:
1802 detected_archs.append(ln.split()[-1])
Ronald Oussorend097efe2009-09-15 19:07:581803 os.unlink(tmpfile)
1804
1805 for a in detected_archs:
1806 frameworks.append('-arch')
1807 frameworks.append(a)
Georg Brandlfcaf9102008-07-16 02:17:561808
Jack Jansen0b06be72002-06-21 14:48:381809 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1810 define_macros=[('WITH_APPINIT', 1)],
1811 include_dirs = include_dirs,
1812 libraries = [],
Georg Brandlfcaf9102008-07-16 02:17:561813 extra_compile_args = frameworks[2:],
Jack Jansen0b06be72002-06-21 14:48:381814 extra_link_args = frameworks,
1815 )
1816 self.extensions.append(ext)
1817 return 1
1818
Andrew M. Kuchlingfbe73762001-01-18 18:44:201819 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:231820 # The _tkinter module.
Michael W. Hudson5b109102002-01-23 15:04:411821
Ned Deilyd819b932013-09-06 08:07:051822 # Check whether --with-tcltk-includes and --with-tcltk-libs were
1823 # configured or passed into the make target. If so, use these values
1824 # to build tkinter and bypass the searches for Tcl and TK in standard
1825 # locations.
1826 if self.detect_tkinter_explicitly():
1827 return
1828
Jack Jansen0b06be72002-06-21 14:48:381829 # Rather than complicate the code below, detecting and building
1830 # AquaTk is a separate method. Only one Tkinter will be built on
1831 # Darwin - either AquaTk, if it is found, or X11 based Tk.
doko@ubuntu.com93df16b2012-06-30 12:32:081832 if (host_platform == 'darwin' and
Skip Montanaro0174ddd2005-12-30 05:01:261833 self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
Tim Peters2c60f7a2003-01-29 03:49:431834 return
Jack Jansen0b06be72002-06-21 14:48:381835
Andrew M. Kuchlingfbe73762001-01-18 18:44:201836 # Assume we haven't found any of the libraries or include files
Martin v. Löwis3db5b8c2001-07-24 06:54:011837 # The versions with dots are used on Unix, and the versions without
1838 # dots on Windows, for detection by cygwin.
Andrew M. Kuchlingfbe73762001-01-18 18:44:201839 tcllib = tklib = tcl_includes = tk_includes = None
Guilherme Polo5d377bd2009-08-16 14:44:141840 for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
1841 '8.2', '82', '8.1', '81', '8.0', '80']:
Tarek Ziadé36797272010-07-22 12:50:051842 tklib = self.compiler.find_library_file(lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171843 'tk' + version)
Tarek Ziadé36797272010-07-22 12:50:051844 tcllib = self.compiler.find_library_file(lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171845 'tcl' + version)
Michael W. Hudson5b109102002-01-23 15:04:411846 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:231847 # Exit the loop when we've found the Tcl/Tk libraries
1848 break
Andrew M. Kuchling00e0f212001-01-17 15:23:231849
Fredrik Lundhade711a2001-01-24 08:00:281850 # Now check for the header files
Andrew M. Kuchlingfbe73762001-01-18 18:44:201851 if tklib and tcllib:
Andrew M. Kuchling3c0aa7e2004-03-21 18:57:351852 # Check for the include files on Debian and {Free,Open}BSD, where
Andrew M. Kuchlingfbe73762001-01-18 18:44:201853 # they're put in /usr/include/{tcl,tk}X.Y
Andrew M. Kuchling3c0aa7e2004-03-21 18:57:351854 dotversion = version
doko@ubuntu.com93df16b2012-06-30 12:32:081855 if '.' not in dotversion and "bsd" in host_platform.lower():
Andrew M. Kuchling3c0aa7e2004-03-21 18:57:351856 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a,
1857 # but the include subdirs are named like .../include/tcl8.3.
1858 dotversion = dotversion[:-1] + '.' + dotversion[-1]
1859 tcl_include_sub = []
1860 tk_include_sub = []
1861 for dir in inc_dirs:
1862 tcl_include_sub += [dir + os.sep + "tcl" + dotversion]
1863 tk_include_sub += [dir + os.sep + "tk" + dotversion]
1864 tk_include_sub += tcl_include_sub
1865 tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub)
1866 tk_includes = find_file('tk.h', inc_dirs, tk_include_sub)
Andrew M. Kuchling00e0f212001-01-17 15:23:231867
Martin v. Löwise86a59a2003-05-03 08:45:511868 if (tcllib is None or tklib is None or
Andrew M. Kuchlingfbe73762001-01-18 18:44:201869 tcl_includes is None or tk_includes is None):
Andrew M. Kuchling3c0aa7e2004-03-21 18:57:351870 self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2)
Andrew M. Kuchlingfbe73762001-01-18 18:44:201871 return
Fredrik Lundhade711a2001-01-24 08:00:281872
Andrew M. Kuchlingfbe73762001-01-18 18:44:201873 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:231874
Andrew M. Kuchlingfbe73762001-01-18 18:44:201875 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
1876 for dir in tcl_includes + tk_includes:
1877 if dir not in include_dirs:
1878 include_dirs.append(dir)
Fredrik Lundhade711a2001-01-24 08:00:281879
Andrew M. Kuchlingfbe73762001-01-18 18:44:201880 # Check for various platform-specific directories
doko@ubuntu.com93df16b2012-06-30 12:32:081881 if host_platform == 'sunos5':
Andrew M. Kuchlingfbe73762001-01-18 18:44:201882 include_dirs.append('/usr/openwin/include')
1883 added_lib_dirs.append('/usr/openwin/lib')
1884 elif os.path.exists('/usr/X11R6/include'):
1885 include_dirs.append('/usr/X11R6/include')
Martin v. Löwisfba73692004-11-13 11:13:351886 added_lib_dirs.append('/usr/X11R6/lib64')
Andrew M. Kuchlingfbe73762001-01-18 18:44:201887 added_lib_dirs.append('/usr/X11R6/lib')
1888 elif os.path.exists('/usr/X11R5/include'):
1889 include_dirs.append('/usr/X11R5/include')
1890 added_lib_dirs.append('/usr/X11R5/lib')
1891 else:
Fredrik Lundhade711a2001-01-24 08:00:281892 # Assume default location for X11
Andrew M. Kuchlingfbe73762001-01-18 18:44:201893 include_dirs.append('/usr/X11/include')
1894 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:231895
Jason Tishler9181c942003-02-05 15:16:171896 # If Cygwin, then verify that X is installed before proceeding
doko@ubuntu.com93df16b2012-06-30 12:32:081897 if host_platform == 'cygwin':
Jason Tishler9181c942003-02-05 15:16:171898 x11_inc = find_file('X11/Xlib.h', [], include_dirs)
1899 if x11_inc is None:
1900 return
1901
Andrew M. Kuchlingfbe73762001-01-18 18:44:201902 # Check for BLT extension
Tarek Ziadé36797272010-07-22 12:50:051903 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171904 'BLT8.0'):
Andrew M. Kuchlingfbe73762001-01-18 18:44:201905 defs.append( ('WITH_BLT', 1) )
1906 libs.append('BLT8.0')
Tarek Ziadé36797272010-07-22 12:50:051907 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
Tarek Ziadédd07ebb2009-07-06 13:52:171908 'BLT'):
Martin v. Löwis427a2902002-12-12 20:23:381909 defs.append( ('WITH_BLT', 1) )
1910 libs.append('BLT')
Andrew M. Kuchling00e0f212001-01-17 15:23:231911
Andrew M. Kuchlingfbe73762001-01-18 18:44:201912 # Add the Tcl/Tk libraries
Jason Tishlercccac1a2003-02-05 15:06:461913 libs.append('tk'+ version)
1914 libs.append('tcl'+ version)
Fredrik Lundhade711a2001-01-24 08:00:281915
doko@ubuntu.com93df16b2012-06-30 12:32:081916 if host_platform in ['aix3', 'aix4']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:201917 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:231918
Martin v. Löwis3db5b8c2001-07-24 06:54:011919 # Finally, link with the X11 libraries (not appropriate on cygwin)
doko@ubuntu.com93df16b2012-06-30 12:32:081920 if host_platform != "cygwin":
Martin v. Löwis3db5b8c2001-07-24 06:54:011921 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:231922
Andrew M. Kuchlingfbe73762001-01-18 18:44:201923 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1924 define_macros=[('WITH_APPINIT', 1)] + defs,
1925 include_dirs = include_dirs,
1926 libraries = libs,
1927 library_dirs = added_lib_dirs,
1928 )
1929 self.extensions.append(ext)
Fredrik Lundhade711a2001-01-24 08:00:281930
Andrew M. Kuchlingfbe73762001-01-18 18:44:201931 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:231932 # *** Uncomment and edit for PIL (TkImaging) extension only:
Fredrik Lundhade711a2001-01-24 08:00:281933 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:231934 # *** Uncomment and edit for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:281935 # -DWITH_TOGL togl.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:231936 # *** Uncomment these for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:281937 # -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling00e0f212001-01-17 15:23:231938
Christian Heimes78644762008-03-04 23:39:231939 def configure_ctypes_darwin(self, ext):
1940 # Darwin (OS X) uses preconfigured files, in
1941 # the Modules/_ctypes/libffi_osx directory.
Neil Schemenauer014bf282009-02-05 16:35:451942 srcdir = sysconfig.get_config_var('srcdir')
Christian Heimes78644762008-03-04 23:39:231943 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
1944 '_ctypes', 'libffi_osx'))
1945 sources = [os.path.join(ffi_srcdir, p)
1946 for p in ['ffi.c',
Georg Brandlfcaf9102008-07-16 02:17:561947 'x86/darwin64.S',
Christian Heimes78644762008-03-04 23:39:231948 'x86/x86-darwin.S',
1949 'x86/x86-ffi_darwin.c',
1950 'x86/x86-ffi64.c',
1951 'powerpc/ppc-darwin.S',
1952 'powerpc/ppc-darwin_closure.S',
1953 'powerpc/ppc-ffi_darwin.c',
1954 'powerpc/ppc64-darwin_closure.S',
1955 ]]
1956
1957 # Add .S (preprocessed assembly) to C compiler source extensions.
Tarek Ziadé36797272010-07-22 12:50:051958 self.compiler.src_extensions.append('.S')
Christian Heimes78644762008-03-04 23:39:231959
1960 include_dirs = [os.path.join(ffi_srcdir, 'include'),
1961 os.path.join(ffi_srcdir, 'powerpc')]
1962 ext.include_dirs.extend(include_dirs)
1963 ext.sources.extend(sources)
1964 return True
1965
Thomas Wouters49fd7fa2006-04-21 10:40:581966 def configure_ctypes(self, ext):
1967 if not self.use_system_libffi:
doko@ubuntu.com93df16b2012-06-30 12:32:081968 if host_platform == 'darwin':
Christian Heimes78644762008-03-04 23:39:231969 return self.configure_ctypes_darwin(ext)
Zachary Waref40d4dd2016-09-17 06:25:241970 print('INFO: Could not locate ffi libs and/or headers')
1971 return False
Thomas Wouters49fd7fa2006-04-21 10:40:581972 return True
1973
1974 def detect_ctypes(self, inc_dirs, lib_dirs):
1975 self.use_system_libffi = False
1976 include_dirs = []
1977 extra_compile_args = []
Thomas Wouters0e3f5912006-08-11 14:57:121978 extra_link_args = []
Thomas Hellercf567c12006-03-08 19:51:581979 sources = ['_ctypes/_ctypes.c',
1980 '_ctypes/callbacks.c',
1981 '_ctypes/callproc.c',
1982 '_ctypes/stgdict.c',
Thomas Heller864cc672010-08-08 17:58:531983 '_ctypes/cfield.c']
Thomas Hellercf567c12006-03-08 19:51:581984 depends = ['_ctypes/ctypes.h']
1985
doko@ubuntu.com93df16b2012-06-30 12:32:081986 if host_platform == 'darwin':
Ronald Oussoren2decf222010-09-05 18:25:591987 sources.append('_ctypes/malloc_closure.c')
Thomas Hellercf567c12006-03-08 19:51:581988 sources.append('_ctypes/darwin/dlfcn_simple.c')
Christian Heimes78644762008-03-04 23:39:231989 extra_compile_args.append('-DMACOSX')
Thomas Hellercf567c12006-03-08 19:51:581990 include_dirs.append('_ctypes/darwin')
1991# XXX Is this still needed?
1992## extra_link_args.extend(['-read_only_relocs', 'warning'])
1993
doko@ubuntu.com93df16b2012-06-30 12:32:081994 elif host_platform == 'sunos5':
Thomas Wouters0e3f5912006-08-11 14:57:121995 # XXX This shouldn't be necessary; it appears that some
1996 # of the assembler code is non-PIC (i.e. it has relocations
1997 # when it shouldn't. The proper fix would be to rewrite
1998 # the assembler code to be PIC.
1999 # This only works with GCC; the Sun compiler likely refuses
2000 # this option. If you want to compile ctypes with the Sun
2001 # compiler, please research a proper solution, instead of
2002 # finding some -z option for the Sun compiler.
2003 extra_link_args.append('-mimpure-text')
2004
doko@ubuntu.com93df16b2012-06-30 12:32:082005 elif host_platform.startswith('hp-ux'):
Thomas Heller3eaaeb42008-05-23 17:26:462006 extra_link_args.append('-fPIC')
2007
Thomas Hellercf567c12006-03-08 19:51:582008 ext = Extension('_ctypes',
2009 include_dirs=include_dirs,
2010 extra_compile_args=extra_compile_args,
Thomas Wouters0e3f5912006-08-11 14:57:122011 extra_link_args=extra_link_args,
Thomas Wouters49fd7fa2006-04-21 10:40:582012 libraries=[],
Thomas Hellercf567c12006-03-08 19:51:582013 sources=sources,
2014 depends=depends)
Benjamin Peterson8acaa312017-11-13 04:53:392015 # function my_sqrt() needs libm for sqrt()
Thomas Hellercf567c12006-03-08 19:51:582016 ext_test = Extension('_ctypes_test',
Victor Stinnerdef80722016-04-19 13:58:112017 sources=['_ctypes/_ctypes_test.c'],
Benjamin Peterson8acaa312017-11-13 04:53:392018 libraries=['m'])
Thomas Hellercf567c12006-03-08 19:51:582019 self.extensions.extend([ext, ext_test])
2020
doko@ubuntu.com93df16b2012-06-30 12:32:082021 if host_platform == 'darwin':
Zachary Ware935043d2016-09-10 00:01:212022 if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
2023 return
Christian Heimes78644762008-03-04 23:39:232024 # OS X 10.5 comes with libffi.dylib; the include files are
2025 # in /usr/include/ffi
2026 inc_dirs.append('/usr/include/ffi')
2027
Benjamin Petersond78735d2010-01-01 16:04:232028 ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
Matthias Klose5a204fe2010-04-21 21:47:452029 if not ffi_inc or ffi_inc[0] == '':
Benjamin Petersond78735d2010-01-01 16:04:232030 ffi_inc = find_file('ffi.h', [], inc_dirs)
Thomas Wouters49fd7fa2006-04-21 10:40:582031 if ffi_inc is not None:
2032 ffi_h = ffi_inc[0] + '/ffi.h'
Shlomi Fish6d51b872017-09-06 20:19:192033 if not os.path.exists(ffi_h):
2034 ffi_inc = None
2035 print('Header file {} does not exist'.format(ffi_h))
Thomas Wouters49fd7fa2006-04-21 10:40:582036 ffi_lib = None
2037 if ffi_inc is not None:
doko@ubuntu.comae683652016-06-04 23:38:292038 for lib_name in ('ffi', 'ffi_pic'):
Tarek Ziadé36797272010-07-22 12:50:052039 if (self.compiler.find_library_file(lib_dirs, lib_name)):
Thomas Wouters49fd7fa2006-04-21 10:40:582040 ffi_lib = lib_name
2041 break
2042
2043 if ffi_inc and ffi_lib:
2044 ext.include_dirs.extend(ffi_inc)
2045 ext.libraries.append(ffi_lib)
2046 self.use_system_libffi = True
2047
Miss Islington (bot)4cb37332018-02-25 12:07:242048 if sysconfig.get_config_var('HAVE_LIBDL'):
2049 # for dlopen, see bpo-32647
2050 ext.libraries.append('dl')
2051
Stefan Krah1919b7e2012-03-21 17:25:232052 def _decimal_ext(self):
Stefan Krah60187b52012-03-23 18:06:272053 extra_compile_args = []
Stefan Kraha10e2fb2012-09-01 12:21:222054 undef_macros = []
Stefan Krah60187b52012-03-23 18:06:272055 if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
2056 include_dirs = []
Stefan Krah45059eb2013-11-24 18:44:572057 libraries = [':libmpdec.so.2']
Stefan Krah60187b52012-03-23 18:06:272058 sources = ['_decimal/_decimal.c']
2059 depends = ['_decimal/docstrings.h']
2060 else:
Ned Deily458a6fb2012-04-01 09:30:462061 srcdir = sysconfig.get_config_var('srcdir')
2062 include_dirs = [os.path.abspath(os.path.join(srcdir,
2063 'Modules',
2064 '_decimal',
2065 'libmpdec'))]
Stefan Krahbd4ed772017-12-06 17:24:172066 libraries = ['m']
Stefan Krah60187b52012-03-23 18:06:272067 sources = [
2068 '_decimal/_decimal.c',
2069 '_decimal/libmpdec/basearith.c',
2070 '_decimal/libmpdec/constants.c',
2071 '_decimal/libmpdec/context.c',
2072 '_decimal/libmpdec/convolute.c',
2073 '_decimal/libmpdec/crt.c',
2074 '_decimal/libmpdec/difradix2.c',
2075 '_decimal/libmpdec/fnt.c',
2076 '_decimal/libmpdec/fourstep.c',
2077 '_decimal/libmpdec/io.c',
2078 '_decimal/libmpdec/memory.c',
2079 '_decimal/libmpdec/mpdecimal.c',
2080 '_decimal/libmpdec/numbertheory.c',
2081 '_decimal/libmpdec/sixstep.c',
2082 '_decimal/libmpdec/transpose.c',
2083 ]
2084 depends = [
2085 '_decimal/docstrings.h',
2086 '_decimal/libmpdec/basearith.h',
2087 '_decimal/libmpdec/bits.h',
2088 '_decimal/libmpdec/constants.h',
2089 '_decimal/libmpdec/convolute.h',
2090 '_decimal/libmpdec/crt.h',
2091 '_decimal/libmpdec/difradix2.h',
2092 '_decimal/libmpdec/fnt.h',
2093 '_decimal/libmpdec/fourstep.h',
2094 '_decimal/libmpdec/io.h',
Stefan Krah8d013a82016-04-26 14:34:412095 '_decimal/libmpdec/mpalloc.h',
Stefan Krah60187b52012-03-23 18:06:272096 '_decimal/libmpdec/mpdecimal.h',
2097 '_decimal/libmpdec/numbertheory.h',
2098 '_decimal/libmpdec/sixstep.h',
2099 '_decimal/libmpdec/transpose.h',
2100 '_decimal/libmpdec/typearith.h',
2101 '_decimal/libmpdec/umodarith.h',
2102 ]
2103
Stefan Krah1919b7e2012-03-21 17:25:232104 config = {
2105 'x64': [('CONFIG_64','1'), ('ASM','1')],
2106 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
2107 'ansi64': [('CONFIG_64','1'), ('ANSI','1')],
2108 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')],
2109 'ansi32': [('CONFIG_32','1'), ('ANSI','1')],
2110 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'),
2111 ('LEGACY_COMPILER','1')],
2112 'universal': [('UNIVERSAL','1')]
2113 }
2114
Stefan Krah1919b7e2012-03-21 17:25:232115 cc = sysconfig.get_config_var('CC')
2116 sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
2117 machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE')
2118
2119 if machine:
2120 # Override automatic configuration to facilitate testing.
2121 define_macros = config[machine]
doko@ubuntu.com93df16b2012-06-30 12:32:082122 elif host_platform == 'darwin':
Stefan Krah1919b7e2012-03-21 17:25:232123 # Universal here means: build with the same options Python
2124 # was built with.
2125 define_macros = config['universal']
2126 elif sizeof_size_t == 8:
2127 if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'):
2128 define_macros = config['x64']
2129 elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'):
2130 define_macros = config['uint128']
2131 else:
2132 define_macros = config['ansi64']
2133 elif sizeof_size_t == 4:
2134 ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
2135 if ppro and ('gcc' in cc or 'clang' in cc) and \
doko@ubuntu.com93df16b2012-06-30 12:32:082136 not 'sunos' in host_platform:
Stefan Krah1919b7e2012-03-21 17:25:232137 # solaris: problems with register allocation.
2138 # icc >= 11.0 works as well.
2139 define_macros = config['ppro']
Stefan Krahce23dbc2012-09-30 19:12:532140 extra_compile_args.append('-Wno-unknown-pragmas')
Stefan Krah1919b7e2012-03-21 17:25:232141 else:
2142 define_macros = config['ansi32']
2143 else:
2144 raise DistutilsError("_decimal: unsupported architecture")
2145
2146 # Workarounds for toolchain bugs:
2147 if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'):
2148 # Some versions of gcc miscompile inline asm:
2149 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
2150 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
2151 extra_compile_args.append('-fno-ipa-pure-const')
2152 if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'):
2153 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
2154 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
2155 undef_macros.append('_FORTIFY_SOURCE')
2156
Stefan Krah1919b7e2012-03-21 17:25:232157 # Uncomment for extra functionality:
2158 #define_macros.append(('EXTRA_FUNCTIONALITY', 1))
2159 ext = Extension (
2160 '_decimal',
2161 include_dirs=include_dirs,
Stefan Krahbd4ed772017-12-06 17:24:172162 libraries=libraries,
Stefan Krah1919b7e2012-03-21 17:25:232163 define_macros=define_macros,
2164 undef_macros=undef_macros,
2165 extra_compile_args=extra_compile_args,
2166 sources=sources,
2167 depends=depends
2168 )
2169 return ext
Thomas Wouters49fd7fa2006-04-21 10:40:582170
Christian Heimesff5be6e2018-01-20 12:19:212171 def _detect_openssl(self, inc_dirs, lib_dirs):
2172 config_vars = sysconfig.get_config_vars()
2173
2174 def split_var(name, sep):
2175 # poor man's shlex, the re module is not available yet.
2176 value = config_vars.get(name)
2177 if not value:
2178 return ()
2179 # This trick works because ax_check_openssl uses --libs-only-L,
2180 # --libs-only-l, and --cflags-only-I.
2181 value = ' ' + value
2182 sep = ' ' + sep
2183 return [v.strip() for v in value.split(sep) if v.strip()]
2184
2185 openssl_includes = split_var('OPENSSL_INCLUDES', '-I')
2186 openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L')
2187 openssl_libs = split_var('OPENSSL_LIBS', '-l')
2188 if not openssl_libs:
2189 # libssl and libcrypto not found
2190 return None, None
2191
2192 # Find OpenSSL includes
2193 ssl_incs = find_file(
2194 'openssl/ssl.h', inc_dirs, openssl_includes
2195 )
2196 if ssl_incs is None:
2197 return None, None
2198
2199 # OpenSSL 1.0.2 uses Kerberos for KRB5 ciphers
2200 krb5_h = find_file(
2201 'krb5.h', inc_dirs,
2202 ['/usr/kerberos/include']
2203 )
2204 if krb5_h:
2205 ssl_incs.extend(krb5_h)
2206
Christian Heimes61d478c2018-01-27 14:51:382207 if config_vars.get("HAVE_X509_VERIFY_PARAM_SET1_HOST"):
2208 ssl_ext = Extension(
2209 '_ssl', ['_ssl.c'],
2210 include_dirs=openssl_includes,
2211 library_dirs=openssl_libdirs,
2212 libraries=openssl_libs,
2213 depends=['socketmodule.h']
2214 )
2215 else:
2216 ssl_ext = None
Christian Heimesff5be6e2018-01-20 12:19:212217
2218 hashlib_ext = Extension(
2219 '_hashlib', ['_hashopenssl.c'],
2220 depends=['hashlib.h'],
2221 include_dirs=openssl_includes,
2222 library_dirs=openssl_libdirs,
2223 libraries=openssl_libs,
2224 )
2225
2226 return ssl_ext, hashlib_ext
2227
Christian Heimes29a7df72018-01-26 22:28:462228 def _detect_nis(self, inc_dirs, lib_dirs):
2229 if host_platform in {'win32', 'cygwin', 'qnx6'}:
2230 return None
2231
2232 libs = []
2233 library_dirs = []
2234 includes_dirs = []
2235
2236 # bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28
2237 # moved headers and libraries to libtirpc and libnsl. The headers
2238 # are in tircp and nsl sub directories.
2239 rpcsvc_inc = find_file(
2240 'rpcsvc/yp_prot.h', inc_dirs,
2241 [os.path.join(inc_dir, 'nsl') for inc_dir in inc_dirs]
2242 )
2243 rpc_inc = find_file(
2244 'rpc/rpc.h', inc_dirs,
2245 [os.path.join(inc_dir, 'tirpc') for inc_dir in inc_dirs]
2246 )
2247 if rpcsvc_inc is None or rpc_inc is None:
2248 # not found
2249 return None
2250 includes_dirs.extend(rpcsvc_inc)
2251 includes_dirs.extend(rpc_inc)
2252
2253 if self.compiler.find_library_file(lib_dirs, 'nsl'):
2254 libs.append('nsl')
2255 else:
2256 # libnsl-devel: check for libnsl in nsl/ subdirectory
2257 nsl_dirs = [os.path.join(lib_dir, 'nsl') for lib_dir in lib_dirs]
2258 libnsl = self.compiler.find_library_file(nsl_dirs, 'nsl')
2259 if libnsl is not None:
2260 library_dirs.append(os.path.dirname(libnsl))
2261 libs.append('nsl')
2262
2263 if self.compiler.find_library_file(lib_dirs, 'tirpc'):
2264 libs.append('tirpc')
2265
2266 return Extension(
2267 'nis', ['nismodule.c'],
2268 libraries=libs,
2269 library_dirs=library_dirs,
2270 include_dirs=includes_dirs
2271 )
2272
Christian Heimesff5be6e2018-01-20 12:19:212273
Andrew M. Kuchlingf52d27e2001-05-21 20:29:272274class PyBuildInstall(install):
2275 # Suppress the warning about installation into the lib_dynload
2276 # directory, which is not in sys.path when running Python during
2277 # installation:
2278 def initialize_options (self):
2279 install.initialize_options(self)
2280 self.warn_dir=0
Michael W. Hudson5b109102002-01-23 15:04:412281
Éric Araujoe6792c12011-06-09 12:07:022282 # Customize subcommands to not install an egg-info file for Python
2283 sub_commands = [('install_lib', install.has_lib),
2284 ('install_headers', install.has_headers),
2285 ('install_scripts', install.has_scripts),
2286 ('install_data', install.has_data)]
2287
2288
Michael W. Hudson529a5052002-12-17 16:47:172289class PyBuildInstallLib(install_lib):
2290 # Do exactly what install_lib does but make sure correct access modes get
2291 # set on installed directories and files. All installed files with get
2292 # mode 644 unless they are a shared library in which case they will get
2293 # mode 755. All installed directories will get mode 755.
2294
doko@ubuntu.comd5537d02013-03-21 20:21:492295 # this is works for EXT_SUFFIX too, which ends with SHLIB_SUFFIX
2296 shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX")
Michael W. Hudson529a5052002-12-17 16:47:172297
2298 def install(self):
2299 outfiles = install_lib.install(self)
Guido van Rossumcd16bf62007-06-13 18:07:492300 self.set_file_modes(outfiles, 0o644, 0o755)
2301 self.set_dir_modes(self.install_dir, 0o755)
Michael W. Hudson529a5052002-12-17 16:47:172302 return outfiles
2303
2304 def set_file_modes(self, files, defaultMode, sharedLibMode):
2305 if not self.is_chmod_supported(): return
2306 if not files: return
2307
2308 for filename in files:
2309 if os.path.islink(filename): continue
2310 mode = defaultMode
doko@ubuntu.comd5537d02013-03-21 20:21:492311 if filename.endswith(self.shlib_suffix): mode = sharedLibMode
Michael W. Hudson529a5052002-12-17 16:47:172312 log.info("changing mode of %s to %o", filename, mode)
2313 if not self.dry_run: os.chmod(filename, mode)
2314
2315 def set_dir_modes(self, dirname, mode):
2316 if not self.is_chmod_supported(): return
Amaury Forgeot d'Arc321e5332009-07-02 23:08:452317 for dirpath, dirnames, fnames in os.walk(dirname):
2318 if os.path.islink(dirpath):
2319 continue
2320 log.info("changing mode of %s to %o", dirpath, mode)
2321 if not self.dry_run: os.chmod(dirpath, mode)
Michael W. Hudson529a5052002-12-17 16:47:172322
2323 def is_chmod_supported(self):
2324 return hasattr(os, 'chmod')
2325
Georg Brandlff52f762010-12-28 09:51:432326class PyBuildScripts(build_scripts):
2327 def copy_scripts(self):
2328 outfiles, updated_files = build_scripts.copy_scripts(self)
2329 fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info)
2330 minoronly = '.{0[1]}'.format(sys.version_info)
2331 newoutfiles = []
2332 newupdated_files = []
2333 for filename in outfiles:
Vinay Sajip7ded1f02012-05-26 02:45:292334 if filename.endswith(('2to3', 'pyvenv')):
Georg Brandlff52f762010-12-28 09:51:432335 newfilename = filename + fullversion
2336 else:
2337 newfilename = filename + minoronly
Vinay Sajipdd917f82016-08-31 07:22:292338 log.info('renaming %s to %s', filename, newfilename)
Georg Brandlff52f762010-12-28 09:51:432339 os.rename(filename, newfilename)
2340 newoutfiles.append(newfilename)
2341 if filename in updated_files:
2342 newupdated_files.append(newfilename)
2343 return newoutfiles, newupdated_files
2344
Guido van Rossum14ee89c2003-02-20 02:52:042345SUMMARY = """
2346Python is an interpreted, interactive, object-oriented programming
2347language. It is often compared to Tcl, Perl, Scheme or Java.
2348
2349Python combines remarkable power with very clear syntax. It has
2350modules, classes, exceptions, very high level dynamic data types, and
2351dynamic typing. There are interfaces to many system calls and
2352libraries, as well as to various windowing systems (X11, Motif, Tk,
2353Mac, MFC). New built-in modules are easily written in C or C++. Python
2354is also usable as an extension language for applications that need a
2355programmable interface.
2356
2357The Python implementation is portable: it runs on many brands of UNIX,
Jesus Ceaf1af7052012-10-05 00:48:462358on Windows, DOS, Mac, Amiga... If your favorite system isn't
Guido van Rossum14ee89c2003-02-20 02:52:042359listed here, it may still be supported, if there's a C compiler for
2360it. Ask around on comp.lang.python -- or just try compiling Python
2361yourself.
2362"""
2363
2364CLASSIFIERS = """
Guido van Rossum14ee89c2003-02-20 02:52:042365Development Status :: 6 - Mature
2366License :: OSI Approved :: Python Software Foundation License
2367Natural Language :: English
2368Programming Language :: C
2369Programming Language :: Python
2370Topic :: Software Development
2371"""
2372
Andrew M. Kuchling00e0f212001-01-17 15:23:232373def main():
Andrew M. Kuchling62686692001-05-21 20:48:092374 # turn off warnings when deprecated modules are imported
2375 import warnings
2376 warnings.filterwarnings("ignore",category=DeprecationWarning)
Guido van Rossum14ee89c2003-02-20 02:52:042377 setup(# PyPI Metadata (PEP 301)
2378 name = "Python",
2379 version = sys.version.split()[0],
Serhiy Storchaka885bdc42016-02-11 11:10:362380 url = "http://www.python.org/%d.%d" % sys.version_info[:2],
Guido van Rossum14ee89c2003-02-20 02:52:042381 maintainer = "Guido van Rossum and the Python community",
2382 maintainer_email = "python-dev@python.org",
2383 description = "A high-level object-oriented programming language",
2384 long_description = SUMMARY.strip(),
2385 license = "PSF license",
Guido van Rossumc1f779c2007-07-03 08:25:582386 classifiers = [x for x in CLASSIFIERS.split("\n") if x],
Guido van Rossum14ee89c2003-02-20 02:52:042387 platforms = ["Many"],
2388
2389 # Build info
Georg Brandlff52f762010-12-28 09:51:432390 cmdclass = {'build_ext': PyBuildExt,
2391 'build_scripts': PyBuildScripts,
2392 'install': PyBuildInstall,
2393 'install_lib': PyBuildInstallLib},
Andrew M. Kuchling00e0f212001-01-17 15:23:232394 # The struct module is defined here, because build_ext won't be
2395 # called unless there's at least one extension module defined.
Thomas Wouters477c8d52006-05-27 19:21:472396 ext_modules=[Extension('_struct', ['_struct.c'])],
Andrew M. Kuchlingaece4272001-02-28 20:56:492397
Georg Brandlff52f762010-12-28 09:51:432398 # If you change the scripts installed here, you also need to
2399 # check the PyBuildScripts command above, and change the links
2400 # created by the bininstall target in Makefile.pre.in
Benjamin Petersondfea1922009-05-23 17:13:142401 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
Éric Araujo859aad62012-06-24 04:07:412402 "Tools/scripts/2to3", "Tools/scripts/pyvenv"]
Andrew M. Kuchling00e0f212001-01-17 15:23:232403 )
Fredrik Lundhade711a2001-01-24 08:00:282404
Andrew M. Kuchling00e0f212001-01-17 15:23:232405# --install-platlib
2406if __name__ == '__main__':
Andrew M. Kuchling00e0f212001-01-17 15:23:232407 main()