OLD | NEW |
1 # Autodetecting setup.py script for building the Python extensions | 1 # Autodetecting setup.py script for building the Python extensions |
2 # | 2 # |
3 | 3 |
4 __version__ = "$Revision$" | 4 __version__ = "$Revision$" |
5 | 5 |
6 import sys, os, imp, re, optparse | 6 import sys, os, imp, re, optparse |
7 from glob import glob | 7 from glob import glob |
8 from platform import machine as platform_machine | 8 from platform import machine as platform_machine |
9 import sysconfig | 9 import sysconfig |
10 | 10 |
11 from distutils import log | 11 from distutils import log |
12 from distutils import text_file | 12 from distutils import text_file |
13 from distutils.errors import * | 13 from distutils.errors import * |
14 from distutils.core import Extension, setup | 14 from distutils.core import Extension, setup |
15 from distutils.command.build_ext import build_ext | 15 from distutils.command.build_ext import build_ext |
16 from distutils.command.install import install | 16 from distutils.command.install import install |
17 from distutils.command.install_lib import install_lib | 17 from distutils.command.install_lib import install_lib |
18 from distutils.spawn import find_executable | 18 from distutils.spawn import find_executable |
19 | 19 |
| 20 cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ |
| 21 |
| 22 def get_platform(): |
| 23 # cross build |
| 24 if "_PYTHON_HOST_PLATFORM" in os.environ: |
| 25 return os.environ["_PYTHON_HOST_PLATFORM"] |
| 26 # Get value of sys.platform |
| 27 if sys.platform.startswith('osf1'): |
| 28 return 'osf1' |
| 29 return sys.platform |
| 30 host_platform = get_platform() |
| 31 |
20 # Were we compiled --with-pydebug or with #define Py_DEBUG? | 32 # Were we compiled --with-pydebug or with #define Py_DEBUG? |
21 COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') | 33 COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_AR
GS")) |
22 | 34 |
23 # This global variable is used to hold the list of modules to be disabled. | 35 # This global variable is used to hold the list of modules to be disabled. |
24 disabled_module_list = [] | 36 disabled_module_list = [] |
25 | 37 |
26 def add_dir_to_list(dirlist, dir): | 38 def add_dir_to_list(dirlist, dir): |
27 """Add the directory 'dir' to the list 'dirlist' (at the front) if | 39 """Add the directory 'dir' to the list 'dirlist' (at the front) if |
28 1) 'dir' is not already in 'dirlist' | 40 1) 'dir' is not already in 'dirlist' |
29 2) 'dir' actually exists, and is a directory.""" | 41 2) 'dir' actually exists, and is a directory.""" |
30 if dir is not None and os.path.isdir(dir) and dir not in dirlist: | 42 if dir is not None and os.path.isdir(dir) and dir not in dirlist: |
31 dirlist.insert(0, dir) | 43 dirlist.insert(0, dir) |
(...skipping 23 matching lines...) Expand all Loading... |
55 """Searches for the directory where a given file is located, | 67 """Searches for the directory where a given file is located, |
56 and returns a possibly-empty list of additional directories, or None | 68 and returns a possibly-empty list of additional directories, or None |
57 if the file couldn't be found at all. | 69 if the file couldn't be found at all. |
58 | 70 |
59 'filename' is the name of a file, such as readline.h or libcrypto.a. | 71 'filename' is the name of a file, such as readline.h or libcrypto.a. |
60 'std_dirs' is the list of standard system directories; if the | 72 'std_dirs' is the list of standard system directories; if the |
61 file is found in one of them, no additional directives are needed. | 73 file is found in one of them, no additional directives are needed. |
62 'paths' is a list of additional locations to check; if the file is | 74 'paths' is a list of additional locations to check; if the file is |
63 found in one of them, the resulting list will contain the directory. | 75 found in one of them, the resulting list will contain the directory. |
64 """ | 76 """ |
65 if sys.platform == 'darwin': | 77 if host_platform == 'darwin': |
66 # Honor the MacOSX SDK setting when one was specified. | 78 # Honor the MacOSX SDK setting when one was specified. |
67 # An SDK is a directory with the same structure as a real | 79 # An SDK is a directory with the same structure as a real |
68 # system, but with only header files and libraries. | 80 # system, but with only header files and libraries. |
69 sysroot = macosx_sdk_root() | 81 sysroot = macosx_sdk_root() |
70 | 82 |
71 # Check the standard locations | 83 # Check the standard locations |
72 for dir in std_dirs: | 84 for dir in std_dirs: |
73 f = os.path.join(dir, filename) | 85 f = os.path.join(dir, filename) |
74 | 86 |
75 if sys.platform == 'darwin' and is_macosx_sdk_path(dir): | 87 if host_platform == 'darwin' and is_macosx_sdk_path(dir): |
76 f = os.path.join(sysroot, dir[1:], filename) | 88 f = os.path.join(sysroot, dir[1:], filename) |
77 | 89 |
78 if os.path.exists(f): return [] | 90 if os.path.exists(f): return [] |
79 | 91 |
80 # Check the additional directories | 92 # Check the additional directories |
81 for dir in paths: | 93 for dir in paths: |
82 f = os.path.join(dir, filename) | 94 f = os.path.join(dir, filename) |
83 | 95 |
84 if sys.platform == 'darwin' and is_macosx_sdk_path(dir): | 96 if host_platform == 'darwin' and is_macosx_sdk_path(dir): |
85 f = os.path.join(sysroot, dir[1:], filename) | 97 f = os.path.join(sysroot, dir[1:], filename) |
86 | 98 |
87 if os.path.exists(f): | 99 if os.path.exists(f): |
88 return [dir] | 100 return [dir] |
89 | 101 |
90 # Not found anywhere | 102 # Not found anywhere |
91 return None | 103 return None |
92 | 104 |
93 def find_library_file(compiler, libname, std_dirs, paths): | 105 def find_library_file(compiler, libname, std_dirs, paths): |
94 result = compiler.find_library_file(std_dirs + paths, libname) | 106 result = compiler.find_library_file(std_dirs + paths, libname) |
95 if result is None: | 107 if result is None: |
96 return None | 108 return None |
97 | 109 |
98 if sys.platform == 'darwin': | 110 if host_platform == 'darwin': |
99 sysroot = macosx_sdk_root() | 111 sysroot = macosx_sdk_root() |
100 | 112 |
101 # Check whether the found file is in one of the standard directories | 113 # Check whether the found file is in one of the standard directories |
102 dirname = os.path.dirname(result) | 114 dirname = os.path.dirname(result) |
103 for p in std_dirs: | 115 for p in std_dirs: |
104 # Ensure path doesn't end with path separator | 116 # Ensure path doesn't end with path separator |
105 p = p.rstrip(os.sep) | 117 p = p.rstrip(os.sep) |
106 | 118 |
107 if sys.platform == 'darwin' and is_macosx_sdk_path(p): | 119 if host_platform == 'darwin' and is_macosx_sdk_path(p): |
108 if os.path.join(sysroot, p[1:]) == dirname: | 120 if os.path.join(sysroot, p[1:]) == dirname: |
109 return [ ] | 121 return [ ] |
110 | 122 |
111 if p == dirname: | 123 if p == dirname: |
112 return [ ] | 124 return [ ] |
113 | 125 |
114 # Otherwise, it must have been in one of the additional directories, | 126 # Otherwise, it must have been in one of the additional directories, |
115 # so we have to figure out which one. | 127 # so we have to figure out which one. |
116 for p in paths: | 128 for p in paths: |
117 # Ensure path doesn't end with path separator | 129 # Ensure path doesn't end with path separator |
118 p = p.rstrip(os.sep) | 130 p = p.rstrip(os.sep) |
119 | 131 |
120 if sys.platform == 'darwin' and is_macosx_sdk_path(p): | 132 if host_platform == 'darwin' and is_macosx_sdk_path(p): |
121 if os.path.join(sysroot, p[1:]) == dirname: | 133 if os.path.join(sysroot, p[1:]) == dirname: |
122 return [ p ] | 134 return [ p ] |
123 | 135 |
124 if p == dirname: | 136 if p == dirname: |
125 return [p] | 137 return [p] |
126 else: | 138 else: |
127 assert False, "Internal error: Path not found in std_dirs or paths" | 139 assert False, "Internal error: Path not found in std_dirs or paths" |
128 | 140 |
129 def module_enabled(extlist, modname): | 141 def module_enabled(extlist, modname): |
130 """Returns whether the module 'modname' is present in the list | 142 """Returns whether the module 'modname' is present in the list |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 # with Modules/ and adding Python's include directory to the path. | 179 # with Modules/ and adding Python's include directory to the path. |
168 (srcdir,) = sysconfig.get_config_vars('srcdir') | 180 (srcdir,) = sysconfig.get_config_vars('srcdir') |
169 if not srcdir: | 181 if not srcdir: |
170 # Maybe running on Windows but not using CYGWIN? | 182 # Maybe running on Windows but not using CYGWIN? |
171 raise ValueError("No source directory; cannot proceed.") | 183 raise ValueError("No source directory; cannot proceed.") |
172 srcdir = os.path.abspath(srcdir) | 184 srcdir = os.path.abspath(srcdir) |
173 moddirlist = [os.path.join(srcdir, 'Modules')] | 185 moddirlist = [os.path.join(srcdir, 'Modules')] |
174 | 186 |
175 # Platform-dependent module source and include directories | 187 # Platform-dependent module source and include directories |
176 incdirlist = [] | 188 incdirlist = [] |
177 platform = self.get_platform() | 189 |
178 if platform == 'darwin' and ("--disable-toolbox-glue" not in | 190 if host_platform == 'darwin' and ("--disable-toolbox-glue" not in |
179 sysconfig.get_config_var("CONFIG_ARGS")): | 191 sysconfig.get_config_var("CONFIG_ARGS")): |
180 # Mac OS X also includes some mac-specific modules | 192 # Mac OS X also includes some mac-specific modules |
181 macmoddir = os.path.join(srcdir, 'Mac/Modules') | 193 macmoddir = os.path.join(srcdir, 'Mac/Modules') |
182 moddirlist.append(macmoddir) | 194 moddirlist.append(macmoddir) |
183 incdirlist.append(os.path.join(srcdir, 'Mac/Include')) | 195 incdirlist.append(os.path.join(srcdir, 'Mac/Include')) |
184 | 196 |
185 # Fix up the paths for scripts, too | 197 # Fix up the paths for scripts, too |
186 self.distribution.scripts = [os.path.join(srcdir, filename) | 198 self.distribution.scripts = [os.path.join(srcdir, filename) |
187 for filename in self.distribution.scripts] | 199 for filename in self.distribution.scripts] |
188 | 200 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 self.failed.append(ext.name) | 293 self.failed.append(ext.name) |
282 return | 294 return |
283 # Workaround for Mac OS X: The Carbon-based modules cannot be | 295 # Workaround for Mac OS X: The Carbon-based modules cannot be |
284 # reliably imported into a command-line Python | 296 # reliably imported into a command-line Python |
285 if 'Carbon' in ext.extra_link_args: | 297 if 'Carbon' in ext.extra_link_args: |
286 self.announce( | 298 self.announce( |
287 'WARNING: skipping import check for Carbon-based "%s"' % | 299 'WARNING: skipping import check for Carbon-based "%s"' % |
288 ext.name) | 300 ext.name) |
289 return | 301 return |
290 | 302 |
291 if self.get_platform() == 'darwin' and ( | 303 if host_platform == 'darwin' and ( |
292 sys.maxint > 2**32 and '-arch' in ext.extra_link_args): | 304 sys.maxint > 2**32 and '-arch' in ext.extra_link_args): |
293 # Don't bother doing an import check when an extension was | 305 # Don't bother doing an import check when an extension was |
294 # build with an explicit '-arch' flag on OSX. That's currently | 306 # build with an explicit '-arch' flag on OSX. That's currently |
295 # only used to build 32-bit only extensions in a 4-way | 307 # only used to build 32-bit only extensions in a 4-way |
296 # universal build and loading 32-bit code into a 64-bit | 308 # universal build and loading 32-bit code into a 64-bit |
297 # process will fail. | 309 # process will fail. |
298 self.announce( | 310 self.announce( |
299 'WARNING: skipping import check for "%s"' % | 311 'WARNING: skipping import check for "%s"' % |
300 ext.name) | 312 ext.name) |
301 return | 313 return |
302 | 314 |
303 # Workaround for Cygwin: Cygwin currently has fork issues when many | 315 # Workaround for Cygwin: Cygwin currently has fork issues when many |
304 # modules have been imported | 316 # modules have been imported |
305 if self.get_platform() == 'cygwin': | 317 if host_platform == 'cygwin': |
306 self.announce('WARNING: skipping import check for Cygwin-based "%s"' | 318 self.announce('WARNING: skipping import check for Cygwin-based "%s"' |
307 % ext.name) | 319 % ext.name) |
308 return | 320 return |
309 ext_filename = os.path.join( | 321 ext_filename = os.path.join( |
310 self.build_lib, | 322 self.build_lib, |
311 self.get_ext_filename(self.get_ext_fullname(ext.name))) | 323 self.get_ext_filename(self.get_ext_fullname(ext.name))) |
| 324 |
| 325 # Don't try to load extensions for cross builds |
| 326 if cross_compiling: |
| 327 return |
| 328 |
312 try: | 329 try: |
313 imp.load_dynamic(ext.name, ext_filename) | 330 imp.load_dynamic(ext.name, ext_filename) |
314 except ImportError, why: | 331 except ImportError, why: |
315 self.failed.append(ext.name) | 332 self.failed.append(ext.name) |
316 self.announce('*** WARNING: renaming "%s" since importing it' | 333 self.announce('*** WARNING: renaming "%s" since importing it' |
317 ' failed: %s' % (ext.name, why), level=3) | 334 ' failed: %s' % (ext.name, why), level=3) |
318 assert not self.inplace | 335 assert not self.inplace |
319 basename, tail = os.path.splitext(ext_filename) | 336 basename, tail = os.path.splitext(ext_filename) |
320 newname = basename + "_failed" + tail | 337 newname = basename + "_failed" + tail |
321 if os.path.exists(newname): | 338 if os.path.exists(newname): |
(...skipping 10 matching lines...) Expand all Loading... |
332 for filename in self._built_objects: | 349 for filename in self._built_objects: |
333 os.remove(filename) | 350 os.remove(filename) |
334 except AttributeError: | 351 except AttributeError: |
335 self.announce('unable to remove files (ignored)') | 352 self.announce('unable to remove files (ignored)') |
336 except: | 353 except: |
337 exc_type, why, tb = sys.exc_info() | 354 exc_type, why, tb = sys.exc_info() |
338 self.announce('*** WARNING: importing extension "%s" ' | 355 self.announce('*** WARNING: importing extension "%s" ' |
339 'failed with %s: %s' % (ext.name, exc_type, why), | 356 'failed with %s: %s' % (ext.name, exc_type, why), |
340 level=3) | 357 level=3) |
341 self.failed.append(ext.name) | 358 self.failed.append(ext.name) |
342 | |
343 def get_platform(self): | |
344 # Get value of sys.platform | |
345 for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']: | |
346 if sys.platform.startswith(platform): | |
347 return platform | |
348 return sys.platform | |
349 | 359 |
350 def add_multiarch_paths(self): | 360 def add_multiarch_paths(self): |
351 # Debian/Ubuntu multiarch support. | 361 # Debian/Ubuntu multiarch support. |
352 # https://wiki.ubuntu.com/MultiarchSpec | 362 # https://wiki.ubuntu.com/MultiarchSpec |
353 cc = sysconfig.get_config_var('CC') | 363 cc = sysconfig.get_config_var('CC') |
354 tmpfile = os.path.join(self.build_temp, 'multiarch') | 364 tmpfile = os.path.join(self.build_temp, 'multiarch') |
355 if not os.path.exists(self.build_temp): | 365 if not os.path.exists(self.build_temp): |
356 os.makedirs(self.build_temp) | 366 os.makedirs(self.build_temp) |
357 ret = os.system( | 367 ret = os.system( |
358 '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile)) | 368 '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile)) |
359 multiarch_path_component = '' | 369 multiarch_path_component = '' |
360 try: | 370 try: |
361 if ret >> 8 == 0: | 371 if ret >> 8 == 0: |
362 with open(tmpfile) as fp: | 372 with open(tmpfile) as fp: |
363 multiarch_path_component = fp.readline().strip() | 373 multiarch_path_component = fp.readline().strip() |
364 finally: | 374 finally: |
365 os.unlink(tmpfile) | 375 os.unlink(tmpfile) |
366 | 376 |
367 if multiarch_path_component != '': | 377 if multiarch_path_component != '': |
368 add_dir_to_list(self.compiler.library_dirs, | 378 add_dir_to_list(self.compiler.library_dirs, |
369 '/usr/lib/' + multiarch_path_component) | 379 '/usr/lib/' + multiarch_path_component) |
370 add_dir_to_list(self.compiler.include_dirs, | 380 add_dir_to_list(self.compiler.include_dirs, |
371 '/usr/include/' + multiarch_path_component) | 381 '/usr/include/' + multiarch_path_component) |
372 return | 382 return |
373 | 383 |
374 if not find_executable('dpkg-architecture'): | 384 if not find_executable('dpkg-architecture'): |
375 return | 385 return |
| 386 opt = '' |
| 387 if cross_compiling: |
| 388 opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') |
376 tmpfile = os.path.join(self.build_temp, 'multiarch') | 389 tmpfile = os.path.join(self.build_temp, 'multiarch') |
377 if not os.path.exists(self.build_temp): | 390 if not os.path.exists(self.build_temp): |
378 os.makedirs(self.build_temp) | 391 os.makedirs(self.build_temp) |
379 ret = os.system( | 392 ret = os.system( |
380 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % | 393 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % |
381 tmpfile) | 394 (opt, tmpfile)) |
382 try: | 395 try: |
383 if ret >> 8 == 0: | 396 if ret >> 8 == 0: |
384 with open(tmpfile) as fp: | 397 with open(tmpfile) as fp: |
385 multiarch_path_component = fp.readline().strip() | 398 multiarch_path_component = fp.readline().strip() |
386 add_dir_to_list(self.compiler.library_dirs, | 399 add_dir_to_list(self.compiler.library_dirs, |
387 '/usr/lib/' + multiarch_path_component) | 400 '/usr/lib/' + multiarch_path_component) |
388 add_dir_to_list(self.compiler.include_dirs, | 401 add_dir_to_list(self.compiler.include_dirs, |
389 '/usr/include/' + multiarch_path_component) | 402 '/usr/include/' + multiarch_path_component) |
| 403 finally: |
| 404 os.unlink(tmpfile) |
| 405 |
| 406 def add_gcc_paths(self): |
| 407 gcc = sysconfig.get_config_var('CC') |
| 408 tmpfile = os.path.join(self.build_temp, 'gccpaths') |
| 409 if not os.path.exists(self.build_temp): |
| 410 os.makedirs(self.build_temp) |
| 411 ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (gcc, tmpfile
)) |
| 412 is_gcc = False |
| 413 in_incdirs = False |
| 414 inc_dirs = [] |
| 415 lib_dirs = [] |
| 416 try: |
| 417 if ret >> 8 == 0: |
| 418 with open(tmpfile) as fp: |
| 419 for line in fp.readlines(): |
| 420 if line.startswith("gcc version"): |
| 421 is_gcc = True |
| 422 elif line.startswith("#include <...>"): |
| 423 in_incdirs = True |
| 424 elif line.startswith("End of search list"): |
| 425 in_incdirs = False |
| 426 elif is_gcc and line.startswith("LIBRARY_PATH"): |
| 427 for d in line.strip().split("=")[1].split(":"): |
| 428 d = os.path.normpath(d) |
| 429 if '/gcc/' not in d: |
| 430 add_dir_to_list(self.compiler.library_dirs, |
| 431 d) |
| 432 elif is_gcc and in_incdirs and '/gcc/' not in line: |
| 433 add_dir_to_list(self.compiler.include_dirs, |
| 434 line.strip()) |
390 finally: | 435 finally: |
391 os.unlink(tmpfile) | 436 os.unlink(tmpfile) |
392 | 437 |
393 def detect_modules(self): | 438 def detect_modules(self): |
394 # Ensure that /usr/local is always used | 439 # Ensure that /usr/local is always used |
395 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') | 440 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
396 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 441 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
397 self.add_multiarch_paths() | 442 self.add_multiarch_paths() |
398 | 443 |
399 # Add paths specified in the environment variables LDFLAGS and | 444 # Add paths specified in the environment variables LDFLAGS and |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 sysconfig.get_config_var("INCLUDEDIR")) | 487 sysconfig.get_config_var("INCLUDEDIR")) |
443 | 488 |
444 try: | 489 try: |
445 have_unicode = unicode | 490 have_unicode = unicode |
446 except NameError: | 491 except NameError: |
447 have_unicode = 0 | 492 have_unicode = 0 |
448 | 493 |
449 # lib_dirs and inc_dirs are used to search for files; | 494 # lib_dirs and inc_dirs are used to search for files; |
450 # if a file is found in one of those directories, it can | 495 # if a file is found in one of those directories, it can |
451 # be assumed that no additional -I,-L directives are needed. | 496 # be assumed that no additional -I,-L directives are needed. |
452 lib_dirs = self.compiler.library_dirs + [ | 497 inc_dirs = self.compiler.include_dirs[:] |
453 '/lib64', '/usr/lib64', | 498 lib_dirs = self.compiler.library_dirs[:] |
454 '/lib', '/usr/lib', | 499 if not cross_compiling: |
455 ] | 500 for d in ( |
456 inc_dirs = self.compiler.include_dirs + ['/usr/include'] | 501 '/usr/include', |
| 502 ): |
| 503 add_dir_to_list(inc_dirs, d) |
| 504 for d in ( |
| 505 '/lib64', '/usr/lib64', |
| 506 '/lib', '/usr/lib', |
| 507 ): |
| 508 add_dir_to_list(lib_dirs, d) |
457 exts = [] | 509 exts = [] |
458 missing = [] | 510 missing = [] |
459 | 511 |
460 config_h = sysconfig.get_config_h_filename() | 512 config_h = sysconfig.get_config_h_filename() |
461 config_h_vars = sysconfig.parse_config_h(open(config_h)) | 513 config_h_vars = sysconfig.parse_config_h(open(config_h)) |
462 | 514 |
463 platform = self.get_platform() | |
464 srcdir = sysconfig.get_config_var('srcdir') | 515 srcdir = sysconfig.get_config_var('srcdir') |
465 | 516 |
466 # Check for AtheOS which has libraries in non-standard locations | 517 # Check for AtheOS which has libraries in non-standard locations |
467 if platform == 'atheos': | 518 if host_platform == 'atheos': |
468 lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] | 519 lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] |
469 lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) | 520 lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) |
470 inc_dirs += ['/system/include', '/atheos/autolnk/include'] | 521 inc_dirs += ['/system/include', '/atheos/autolnk/include'] |
471 inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) | 522 inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) |
472 | 523 |
473 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) | 524 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) |
474 if platform in ['osf1', 'unixware7', 'openunix8']: | 525 if host_platform in ['osf1', 'unixware7', 'openunix8']: |
475 lib_dirs += ['/usr/ccs/lib'] | 526 lib_dirs += ['/usr/ccs/lib'] |
476 | 527 |
477 # HP-UX11iv3 keeps files in lib/hpux folders. | 528 # HP-UX11iv3 keeps files in lib/hpux folders. |
478 if platform == 'hp-ux11': | 529 if host_platform == 'hp-ux11': |
479 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] | 530 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] |
480 | 531 |
481 if platform == 'darwin': | 532 if host_platform == 'darwin': |
482 # This should work on any unixy platform ;-) | 533 # This should work on any unixy platform ;-) |
483 # If the user has bothered specifying additional -I and -L flags | 534 # If the user has bothered specifying additional -I and -L flags |
484 # in OPT and LDFLAGS we might as well use them here. | 535 # in OPT and LDFLAGS we might as well use them here. |
485 # NOTE: using shlex.split would technically be more correct, but | 536 # NOTE: using shlex.split would technically be more correct, but |
486 # also gives a bootstrap problem. Let's hope nobody uses directories | 537 # also gives a bootstrap problem. Let's hope nobody uses directories |
487 # with whitespace in the name to store libraries. | 538 # with whitespace in the name to store libraries. |
488 cflags, ldflags = sysconfig.get_config_vars( | 539 cflags, ldflags = sysconfig.get_config_vars( |
489 'CFLAGS', 'LDFLAGS') | 540 'CFLAGS', 'LDFLAGS') |
490 for item in cflags.split(): | 541 for item in cflags.split(): |
491 if item.startswith('-I'): | 542 if item.startswith('-I'): |
492 inc_dirs.append(item[2:]) | 543 inc_dirs.append(item[2:]) |
493 | 544 |
494 for item in ldflags.split(): | 545 for item in ldflags.split(): |
495 if item.startswith('-L'): | 546 if item.startswith('-L'): |
496 lib_dirs.append(item[2:]) | 547 lib_dirs.append(item[2:]) |
497 | 548 |
498 # Check for MacOS X, which doesn't need libm.a at all | 549 # Check for MacOS X, which doesn't need libm.a at all |
499 math_libs = ['m'] | 550 math_libs = ['m'] |
500 if platform in ['darwin', 'beos']: | 551 if host_platform in ['darwin', 'beos']: |
501 math_libs = [] | 552 math_libs = [] |
502 | 553 |
503 # XXX Omitted modules: gl, pure, dl, SGI-specific modules | 554 # XXX Omitted modules: gl, pure, dl, SGI-specific modules |
504 | 555 |
505 # | 556 # |
506 # The following modules are all pretty straightforward, and compile | 557 # The following modules are all pretty straightforward, and compile |
507 # on pretty much any POSIXish platform. | 558 # on pretty much any POSIXish platform. |
508 # | 559 # |
509 | 560 |
510 # Some modules that are normally always on: | 561 # Some modules that are normally always on: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 exts.append( Extension('unicodedata', ['unicodedata.c']) ) | 613 exts.append( Extension('unicodedata', ['unicodedata.c']) ) |
563 else: | 614 else: |
564 missing.append('unicodedata') | 615 missing.append('unicodedata') |
565 # access to ISO C locale support | 616 # access to ISO C locale support |
566 data = open('pyconfig.h').read() | 617 data = open('pyconfig.h').read() |
567 m = re.search(r"#s*define\s+WITH_LIBINTL\s+1\s*", data) | 618 m = re.search(r"#s*define\s+WITH_LIBINTL\s+1\s*", data) |
568 if m is not None: | 619 if m is not None: |
569 locale_libs = ['intl'] | 620 locale_libs = ['intl'] |
570 else: | 621 else: |
571 locale_libs = [] | 622 locale_libs = [] |
572 if platform == 'darwin': | 623 if host_platform == 'darwin': |
573 locale_extra_link_args = ['-framework', 'CoreFoundation'] | 624 locale_extra_link_args = ['-framework', 'CoreFoundation'] |
574 else: | 625 else: |
575 locale_extra_link_args = [] | 626 locale_extra_link_args = [] |
576 | 627 |
577 | 628 |
578 exts.append( Extension('_locale', ['_localemodule.c'], | 629 exts.append( Extension('_locale', ['_localemodule.c'], |
579 libraries=locale_libs, | 630 libraries=locale_libs, |
580 extra_link_args=locale_extra_link_args) ) | 631 extra_link_args=locale_extra_link_args) ) |
581 | 632 |
582 # Modules with some UNIX dependencies -- on by default: | 633 # Modules with some UNIX dependencies -- on by default: |
(...skipping 21 matching lines...) Expand all Loading... |
604 exts.append( Extension('select', ['selectmodule.c']) ) | 655 exts.append( Extension('select', ['selectmodule.c']) ) |
605 | 656 |
606 # Fred Drake's interface to the Python parser | 657 # Fred Drake's interface to the Python parser |
607 exts.append( Extension('parser', ['parsermodule.c']) ) | 658 exts.append( Extension('parser', ['parsermodule.c']) ) |
608 | 659 |
609 # cStringIO and cPickle | 660 # cStringIO and cPickle |
610 exts.append( Extension('cStringIO', ['cStringIO.c']) ) | 661 exts.append( Extension('cStringIO', ['cStringIO.c']) ) |
611 exts.append( Extension('cPickle', ['cPickle.c']) ) | 662 exts.append( Extension('cPickle', ['cPickle.c']) ) |
612 | 663 |
613 # Memory-mapped files (also works on Win32). | 664 # Memory-mapped files (also works on Win32). |
614 if platform not in ['atheos']: | 665 if host_platform not in ['atheos']: |
615 exts.append( Extension('mmap', ['mmapmodule.c']) ) | 666 exts.append( Extension('mmap', ['mmapmodule.c']) ) |
616 else: | 667 else: |
617 missing.append('mmap') | 668 missing.append('mmap') |
618 | 669 |
619 # Lance Ellinghaus's syslog module | 670 # Lance Ellinghaus's syslog module |
620 # syslog daemon interface | 671 # syslog daemon interface |
621 exts.append( Extension('syslog', ['syslogmodule.c']) ) | 672 exts.append( Extension('syslog', ['syslogmodule.c']) ) |
622 | 673 |
623 # George Neville-Neil's timing module: | 674 # George Neville-Neil's timing module: |
624 # Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html | 675 # Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 # use the same library for the readline and curses modules. | 720 # use the same library for the readline and curses modules. |
670 if 'curses' in readline_termcap_library: | 721 if 'curses' in readline_termcap_library: |
671 curses_library = readline_termcap_library | 722 curses_library = readline_termcap_library |
672 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): | 723 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): |
673 curses_library = 'ncursesw' | 724 curses_library = 'ncursesw' |
674 elif self.compiler.find_library_file(lib_dirs, 'ncurses'): | 725 elif self.compiler.find_library_file(lib_dirs, 'ncurses'): |
675 curses_library = 'ncurses' | 726 curses_library = 'ncurses' |
676 elif self.compiler.find_library_file(lib_dirs, 'curses'): | 727 elif self.compiler.find_library_file(lib_dirs, 'curses'): |
677 curses_library = 'curses' | 728 curses_library = 'curses' |
678 | 729 |
679 if platform == 'darwin': | 730 if host_platform == 'darwin': |
680 os_release = int(os.uname()[2].split('.')[0]) | 731 os_release = int(os.uname()[2].split('.')[0]) |
681 dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') | 732 dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') |
682 if dep_target and dep_target.split('.') < ['10', '5']: | 733 if dep_target and dep_target.split('.') < ['10', '5']: |
683 os_release = 8 | 734 os_release = 8 |
684 if os_release < 9: | 735 if os_release < 9: |
685 # MacOSX 10.4 has a broken readline. Don't try to build | 736 # MacOSX 10.4 has a broken readline. Don't try to build |
686 # the readline module unless the user has installed a fixed | 737 # the readline module unless the user has installed a fixed |
687 # readline package | 738 # readline package |
688 if find_file('readline/rlconf.h', inc_dirs, []) is None: | 739 if find_file('readline/rlconf.h', inc_dirs, []) is None: |
689 do_readline = False | 740 do_readline = False |
690 if do_readline: | 741 if do_readline: |
691 if platform == 'darwin' and os_release < 9: | 742 if host_platform == 'darwin' and os_release < 9: |
692 # In every directory on the search path search for a dynamic | 743 # In every directory on the search path search for a dynamic |
693 # library and then a static library, instead of first looking | 744 # library and then a static library, instead of first looking |
694 # for dynamic libraries on the entiry path. | 745 # for dynamic libraries on the entiry path. |
695 # This way a staticly linked custom readline gets picked up | 746 # This way a staticly linked custom readline gets picked up |
696 # before the (possibly broken) dynamic library in /usr/lib. | 747 # before the (possibly broken) dynamic library in /usr/lib. |
697 readline_extra_link_args = ('-Wl,-search_paths_first',) | 748 readline_extra_link_args = ('-Wl,-search_paths_first',) |
698 else: | 749 else: |
699 readline_extra_link_args = () | 750 readline_extra_link_args = () |
700 | 751 |
701 readline_libs = ['readline'] | 752 readline_libs = ['readline'] |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 # find out which version of OpenSSL we have | 810 # find out which version of OpenSSL we have |
760 openssl_ver = 0 | 811 openssl_ver = 0 |
761 openssl_ver_re = re.compile( | 812 openssl_ver_re = re.compile( |
762 '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) | 813 '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) |
763 | 814 |
764 # look for the openssl version header on the compiler search path. | 815 # look for the openssl version header on the compiler search path. |
765 opensslv_h = find_file('openssl/opensslv.h', [], | 816 opensslv_h = find_file('openssl/opensslv.h', [], |
766 inc_dirs + search_for_ssl_incs_in) | 817 inc_dirs + search_for_ssl_incs_in) |
767 if opensslv_h: | 818 if opensslv_h: |
768 name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') | 819 name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') |
769 if sys.platform == 'darwin' and is_macosx_sdk_path(name): | 820 if host_platform == 'darwin' and is_macosx_sdk_path(name): |
770 name = os.path.join(macosx_sdk_root(), name[1:]) | 821 name = os.path.join(macosx_sdk_root(), name[1:]) |
771 try: | 822 try: |
772 incfile = open(name, 'r') | 823 incfile = open(name, 'r') |
773 for line in incfile: | 824 for line in incfile: |
774 m = openssl_ver_re.match(line) | 825 m = openssl_ver_re.match(line) |
775 if m: | 826 if m: |
776 openssl_ver = eval(m.group(1)) | 827 openssl_ver = eval(m.group(1)) |
777 except IOError, msg: | 828 except IOError, msg: |
778 print "IOError while reading opensshv.h:", msg | 829 print "IOError while reading opensshv.h:", msg |
779 pass | 830 pass |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 db_inc_paths.append('/opt/db-4.%d/include' % x) | 933 db_inc_paths.append('/opt/db-4.%d/include' % x) |
883 # MacPorts default (http://www.macports.org/) | 934 # MacPorts default (http://www.macports.org/) |
884 db_inc_paths.append('/opt/local/include/db4%d' % x) | 935 db_inc_paths.append('/opt/local/include/db4%d' % x) |
885 # 3.x minor number specific paths | 936 # 3.x minor number specific paths |
886 for x in gen_db_minor_ver_nums(3): | 937 for x in gen_db_minor_ver_nums(3): |
887 db_inc_paths.append('/usr/include/db3%d' % x) | 938 db_inc_paths.append('/usr/include/db3%d' % x) |
888 db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) | 939 db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) |
889 db_inc_paths.append('/usr/local/include/db3%d' % x) | 940 db_inc_paths.append('/usr/local/include/db3%d' % x) |
890 db_inc_paths.append('/pkg/db-3.%d/include' % x) | 941 db_inc_paths.append('/pkg/db-3.%d/include' % x) |
891 db_inc_paths.append('/opt/db-3.%d/include' % x) | 942 db_inc_paths.append('/opt/db-3.%d/include' % x) |
| 943 |
| 944 if cross_compiling: |
| 945 db_inc_paths = [] |
892 | 946 |
893 # Add some common subdirectories for Sleepycat DB to the list, | 947 # Add some common subdirectories for Sleepycat DB to the list, |
894 # based on the standard include directories. This way DB3/4 gets | 948 # based on the standard include directories. This way DB3/4 gets |
895 # picked up when it is installed in a non-standard prefix and | 949 # picked up when it is installed in a non-standard prefix and |
896 # the user has added that prefix into inc_dirs. | 950 # the user has added that prefix into inc_dirs. |
897 std_variants = [] | 951 std_variants = [] |
898 for dn in inc_dirs: | 952 for dn in inc_dirs: |
899 std_variants.append(os.path.join(dn, 'db3')) | 953 std_variants.append(os.path.join(dn, 'db3')) |
900 std_variants.append(os.path.join(dn, 'db4')) | 954 std_variants.append(os.path.join(dn, 'db4')) |
901 for x in gen_db_minor_ver_nums(4): | 955 for x in gen_db_minor_ver_nums(4): |
902 std_variants.append(os.path.join(dn, "db4%d"%x)) | 956 std_variants.append(os.path.join(dn, "db4%d"%x)) |
903 std_variants.append(os.path.join(dn, "db4.%d"%x)) | 957 std_variants.append(os.path.join(dn, "db4.%d"%x)) |
904 for x in gen_db_minor_ver_nums(3): | 958 for x in gen_db_minor_ver_nums(3): |
905 std_variants.append(os.path.join(dn, "db3%d"%x)) | 959 std_variants.append(os.path.join(dn, "db3%d"%x)) |
906 std_variants.append(os.path.join(dn, "db3.%d"%x)) | 960 std_variants.append(os.path.join(dn, "db3.%d"%x)) |
907 | 961 |
908 db_inc_paths = std_variants + db_inc_paths | 962 db_inc_paths = std_variants + db_inc_paths |
909 db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] | 963 db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] |
910 | 964 |
911 db_ver_inc_map = {} | 965 db_ver_inc_map = {} |
912 | 966 |
913 if sys.platform == 'darwin': | 967 if host_platform == 'darwin': |
914 sysroot = macosx_sdk_root() | 968 sysroot = macosx_sdk_root() |
915 | 969 |
916 class db_found(Exception): pass | 970 class db_found(Exception): pass |
917 try: | 971 try: |
918 # See whether there is a Sleepycat header in the standard | 972 # See whether there is a Sleepycat header in the standard |
919 # search path. | 973 # search path. |
920 for d in inc_dirs + db_inc_paths: | 974 for d in inc_dirs + db_inc_paths: |
921 f = os.path.join(d, "db.h") | 975 f = os.path.join(d, "db.h") |
922 | 976 |
923 if sys.platform == 'darwin' and is_macosx_sdk_path(d): | 977 if host_platform == 'darwin' and is_macosx_sdk_path(d): |
924 f = os.path.join(sysroot, d[1:], "db.h") | 978 f = os.path.join(sysroot, d[1:], "db.h") |
925 | 979 |
926 if db_setup_debug: print "db: looking for db.h in", f | 980 if db_setup_debug: print "db: looking for db.h in", f |
927 if os.path.exists(f): | 981 if os.path.exists(f): |
928 f = open(f).read() | 982 f = open(f).read() |
929 m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f) | 983 m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f) |
930 if m: | 984 if m: |
931 db_major = int(m.group(1)) | 985 db_major = int(m.group(1)) |
932 m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f) | 986 m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f) |
933 db_minor = int(m.group(1)) | 987 db_minor = int(m.group(1)) |
(...skipping 29 matching lines...) Expand all Loading... |
963 while db_found_vers: | 1017 while db_found_vers: |
964 db_ver = db_found_vers.pop() | 1018 db_ver = db_found_vers.pop() |
965 db_incdir = db_ver_inc_map[db_ver] | 1019 db_incdir = db_ver_inc_map[db_ver] |
966 | 1020 |
967 # check lib directories parallel to the location of the header | 1021 # check lib directories parallel to the location of the header |
968 db_dirs_to_check = [ | 1022 db_dirs_to_check = [ |
969 db_incdir.replace("include", 'lib64'), | 1023 db_incdir.replace("include", 'lib64'), |
970 db_incdir.replace("include", 'lib'), | 1024 db_incdir.replace("include", 'lib'), |
971 ] | 1025 ] |
972 | 1026 |
973 if sys.platform != 'darwin': | 1027 if host_platform != 'darwin': |
974 db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) | 1028 db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) |
975 | 1029 |
976 else: | 1030 else: |
977 # Same as other branch, but takes OSX SDK into account | 1031 # Same as other branch, but takes OSX SDK into account |
978 tmp = [] | 1032 tmp = [] |
979 for dn in db_dirs_to_check: | 1033 for dn in db_dirs_to_check: |
980 if is_macosx_sdk_path(dn): | 1034 if is_macosx_sdk_path(dn): |
981 if os.path.isdir(os.path.join(sysroot, dn[1:])): | 1035 if os.path.isdir(os.path.join(sysroot, dn[1:])): |
982 tmp.append(dn) | 1036 tmp.append(dn) |
983 else: | 1037 else: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 # We hunt for #define SQLITE_VERSION "n.n.n" | 1085 # We hunt for #define SQLITE_VERSION "n.n.n" |
1032 # We need to find >= sqlite version 3.0.8 | 1086 # We need to find >= sqlite version 3.0.8 |
1033 sqlite_incdir = sqlite_libdir = None | 1087 sqlite_incdir = sqlite_libdir = None |
1034 sqlite_inc_paths = [ '/usr/include', | 1088 sqlite_inc_paths = [ '/usr/include', |
1035 '/usr/include/sqlite', | 1089 '/usr/include/sqlite', |
1036 '/usr/include/sqlite3', | 1090 '/usr/include/sqlite3', |
1037 '/usr/local/include', | 1091 '/usr/local/include', |
1038 '/usr/local/include/sqlite', | 1092 '/usr/local/include/sqlite', |
1039 '/usr/local/include/sqlite3', | 1093 '/usr/local/include/sqlite3', |
1040 ] | 1094 ] |
| 1095 if cross_compiling: |
| 1096 sqlite_inc_paths = [] |
1041 MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) | 1097 MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) |
1042 MIN_SQLITE_VERSION = ".".join([str(x) | 1098 MIN_SQLITE_VERSION = ".".join([str(x) |
1043 for x in MIN_SQLITE_VERSION_NUMBER]) | 1099 for x in MIN_SQLITE_VERSION_NUMBER]) |
1044 | 1100 |
1045 # Scan the default include directories before the SQLite specific | 1101 # Scan the default include directories before the SQLite specific |
1046 # ones. This allows one to override the copy of sqlite on OSX, | 1102 # ones. This allows one to override the copy of sqlite on OSX, |
1047 # where /usr/include contains an old version of sqlite. | 1103 # where /usr/include contains an old version of sqlite. |
1048 if sys.platform == 'darwin': | 1104 if host_platform == 'darwin': |
1049 sysroot = macosx_sdk_root() | 1105 sysroot = macosx_sdk_root() |
1050 | 1106 |
1051 for d_ in inc_dirs + sqlite_inc_paths: | 1107 for d_ in inc_dirs + sqlite_inc_paths: |
1052 d = d_ | 1108 d = d_ |
1053 if sys.platform == 'darwin' and is_macosx_sdk_path(d): | 1109 if host_platform == 'darwin' and is_macosx_sdk_path(d): |
1054 d = os.path.join(sysroot, d[1:]) | 1110 d = os.path.join(sysroot, d[1:]) |
1055 | 1111 |
1056 f = os.path.join(d, "sqlite3.h") | 1112 f = os.path.join(d, "sqlite3.h") |
1057 if os.path.exists(f): | 1113 if os.path.exists(f): |
1058 if sqlite_setup_debug: print "sqlite: found %s"%f | 1114 if sqlite_setup_debug: print "sqlite: found %s"%f |
1059 incf = open(f).read() | 1115 incf = open(f).read() |
1060 m = re.search( | 1116 m = re.search( |
1061 r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf) | 1117 r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf) |
1062 if m: | 1118 if m: |
1063 sqlite_version = m.group(1) | 1119 sqlite_version = m.group(1) |
(...skipping 29 matching lines...) Expand all Loading... |
1093 '_sqlite/connection.c', | 1149 '_sqlite/connection.c', |
1094 '_sqlite/cursor.c', | 1150 '_sqlite/cursor.c', |
1095 '_sqlite/microprotocols.c', | 1151 '_sqlite/microprotocols.c', |
1096 '_sqlite/module.c', | 1152 '_sqlite/module.c', |
1097 '_sqlite/prepare_protocol.c', | 1153 '_sqlite/prepare_protocol.c', |
1098 '_sqlite/row.c', | 1154 '_sqlite/row.c', |
1099 '_sqlite/statement.c', | 1155 '_sqlite/statement.c', |
1100 '_sqlite/util.c', ] | 1156 '_sqlite/util.c', ] |
1101 | 1157 |
1102 sqlite_defines = [] | 1158 sqlite_defines = [] |
1103 if sys.platform != "win32": | 1159 if host_platform != "win32": |
1104 sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) | 1160 sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) |
1105 else: | 1161 else: |
1106 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) | 1162 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) |
1107 | 1163 |
1108 # Comment this out if you want the sqlite3 module to be able to load
extensions. | 1164 # Comment this out if you want the sqlite3 module to be able to load
extensions. |
1109 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) | 1165 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) |
1110 | 1166 |
1111 if sys.platform == 'darwin': | 1167 if host_platform == 'darwin': |
1112 # In every directory on the search path search for a dynamic | 1168 # In every directory on the search path search for a dynamic |
1113 # library and then a static library, instead of first looking | 1169 # library and then a static library, instead of first looking |
1114 # for dynamic libraries on the entire path. | 1170 # for dynamic libraries on the entire path. |
1115 # This way a statically linked custom sqlite gets picked up | 1171 # This way a statically linked custom sqlite gets picked up |
1116 # before the dynamic library in /usr/lib. | 1172 # before the dynamic library in /usr/lib. |
1117 sqlite_extra_link_args = ('-Wl,-search_paths_first',) | 1173 sqlite_extra_link_args = ('-Wl,-search_paths_first',) |
1118 else: | 1174 else: |
1119 sqlite_extra_link_args = () | 1175 sqlite_extra_link_args = () |
1120 | 1176 |
1121 exts.append(Extension('_sqlite3', sqlite_srcs, | 1177 exts.append(Extension('_sqlite3', sqlite_srcs, |
(...skipping 13 matching lines...) Expand all Loading... |
1135 # accidentally building this module with a later version of the | 1191 # accidentally building this module with a later version of the |
1136 # underlying db library. May BSD-ish Unixes incorporate db 1.85 | 1192 # underlying db library. May BSD-ish Unixes incorporate db 1.85 |
1137 # symbols into libc and place the include file in /usr/include. | 1193 # symbols into libc and place the include file in /usr/include. |
1138 # | 1194 # |
1139 # If the better bsddb library can be built (db_incs is defined) | 1195 # If the better bsddb library can be built (db_incs is defined) |
1140 # we do not build this one. Otherwise this build will pick up | 1196 # we do not build this one. Otherwise this build will pick up |
1141 # the more recent berkeleydb's db.h file first in the include path | 1197 # the more recent berkeleydb's db.h file first in the include path |
1142 # when attempting to compile and it will fail. | 1198 # when attempting to compile and it will fail. |
1143 f = "/usr/include/db.h" | 1199 f = "/usr/include/db.h" |
1144 | 1200 |
1145 if sys.platform == 'darwin': | 1201 if host_platform == 'darwin': |
1146 if is_macosx_sdk_path(f): | 1202 if is_macosx_sdk_path(f): |
1147 sysroot = macosx_sdk_root() | 1203 sysroot = macosx_sdk_root() |
1148 f = os.path.join(sysroot, f[1:]) | 1204 f = os.path.join(sysroot, f[1:]) |
1149 | 1205 |
1150 if os.path.exists(f) and not db_incs: | 1206 if os.path.exists(f) and not db_incs: |
1151 data = open(f).read() | 1207 data = open(f).read() |
1152 m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data) | 1208 m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data) |
1153 if m is not None: | 1209 if m is not None: |
1154 # bingo - old version used hash file format version 2 | 1210 # bingo - old version used hash file format version 2 |
1155 ### XXX this should be fixed to not be platform-dependent | 1211 ### XXX this should be fixed to not be platform-dependent |
1156 ### but I don't have direct access to an osf1 platform and | 1212 ### but I don't have direct access to an osf1 platform and |
1157 ### seemed to be muffing the search somehow | 1213 ### seemed to be muffing the search somehow |
1158 libraries = platform == "osf1" and ['db'] or None | 1214 libraries = host_platform == "osf1" and ['db'] or None |
1159 if libraries is not None: | 1215 if libraries is not None: |
1160 exts.append(Extension('bsddb185', ['bsddbmodule.c'], | 1216 exts.append(Extension('bsddb185', ['bsddbmodule.c'], |
1161 libraries=libraries)) | 1217 libraries=libraries)) |
1162 else: | 1218 else: |
1163 exts.append(Extension('bsddb185', ['bsddbmodule.c'])) | 1219 exts.append(Extension('bsddb185', ['bsddbmodule.c'])) |
1164 else: | 1220 else: |
1165 missing.append('bsddb185') | 1221 missing.append('bsddb185') |
1166 else: | 1222 else: |
1167 missing.append('bsddb185') | 1223 missing.append('bsddb185') |
1168 | 1224 |
1169 dbm_order = ['gdbm'] | 1225 dbm_order = ['gdbm'] |
1170 # The standard Unix dbm module: | 1226 # The standard Unix dbm module: |
1171 if platform not in ['cygwin']: | 1227 if host_platform not in ['cygwin']: |
1172 config_args = [arg.strip("'") | 1228 config_args = [arg.strip("'") |
1173 for arg in sysconfig.get_config_var("CONFIG_ARGS").sp
lit()] | 1229 for arg in sysconfig.get_config_var("CONFIG_ARGS").sp
lit()] |
1174 dbm_args = [arg for arg in config_args | 1230 dbm_args = [arg for arg in config_args |
1175 if arg.startswith('--with-dbmliborder=')] | 1231 if arg.startswith('--with-dbmliborder=')] |
1176 if dbm_args: | 1232 if dbm_args: |
1177 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split("
:") | 1233 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split("
:") |
1178 else: | 1234 else: |
1179 dbm_order = "ndbm:gdbm:bdb".split(":") | 1235 dbm_order = "ndbm:gdbm:bdb".split(":") |
1180 dbmext = None | 1236 dbmext = None |
1181 for cand in dbm_order: | 1237 for cand in dbm_order: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 | 1299 |
1244 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: | 1300 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: |
1245 if ('gdbm' in dbm_order and | 1301 if ('gdbm' in dbm_order and |
1246 self.compiler.find_library_file(lib_dirs, 'gdbm')): | 1302 self.compiler.find_library_file(lib_dirs, 'gdbm')): |
1247 exts.append( Extension('gdbm', ['gdbmmodule.c'], | 1303 exts.append( Extension('gdbm', ['gdbmmodule.c'], |
1248 libraries = ['gdbm'] ) ) | 1304 libraries = ['gdbm'] ) ) |
1249 else: | 1305 else: |
1250 missing.append('gdbm') | 1306 missing.append('gdbm') |
1251 | 1307 |
1252 # Unix-only modules | 1308 # Unix-only modules |
1253 if platform not in ['win32']: | 1309 if host_platform not in ['win32']: |
1254 # Steen Lumholt's termios module | 1310 # Steen Lumholt's termios module |
1255 exts.append( Extension('termios', ['termios.c']) ) | 1311 exts.append( Extension('termios', ['termios.c']) ) |
1256 # Jeremy Hylton's rlimit interface | 1312 # Jeremy Hylton's rlimit interface |
1257 if platform not in ['atheos']: | 1313 if host_platform not in ['atheos']: |
1258 exts.append( Extension('resource', ['resource.c']) ) | 1314 exts.append( Extension('resource', ['resource.c']) ) |
1259 else: | 1315 else: |
1260 missing.append('resource') | 1316 missing.append('resource') |
1261 | 1317 |
1262 # Sun yellow pages. Some systems have the functions in libc. | 1318 # Sun yellow pages. Some systems have the functions in libc. |
1263 if (platform not in ['cygwin', 'atheos', 'qnx6'] and | 1319 if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and |
1264 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): | 1320 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): |
1265 if (self.compiler.find_library_file(lib_dirs, 'nsl')): | 1321 if (self.compiler.find_library_file(lib_dirs, 'nsl')): |
1266 libs = ['nsl'] | 1322 libs = ['nsl'] |
1267 else: | 1323 else: |
1268 libs = [] | 1324 libs = [] |
1269 exts.append( Extension('nis', ['nismodule.c'], | 1325 exts.append( Extension('nis', ['nismodule.c'], |
1270 libraries = libs) ) | 1326 libraries = libs) ) |
1271 else: | 1327 else: |
1272 missing.append('nis') | 1328 missing.append('nis') |
1273 else: | 1329 else: |
1274 missing.extend(['nis', 'resource', 'termios']) | 1330 missing.extend(['nis', 'resource', 'termios']) |
1275 | 1331 |
1276 # Curses support, requiring the System V version of curses, often | 1332 # Curses support, requiring the System V version of curses, often |
1277 # provided by the ncurses library. | 1333 # provided by the ncurses library. |
1278 panel_library = 'panel' | 1334 panel_library = 'panel' |
1279 if curses_library.startswith('ncurses'): | 1335 if curses_library.startswith('ncurses'): |
1280 if curses_library == 'ncursesw': | 1336 if curses_library == 'ncursesw': |
1281 # Bug 1464056: If _curses.so links with ncursesw, | 1337 # Bug 1464056: If _curses.so links with ncursesw, |
1282 # _curses_panel.so must link with panelw. | 1338 # _curses_panel.so must link with panelw. |
1283 panel_library = 'panelw' | 1339 panel_library = 'panelw' |
1284 curses_libs = [curses_library] | 1340 curses_libs = [curses_library] |
1285 exts.append( Extension('_curses', ['_cursesmodule.c'], | 1341 exts.append( Extension('_curses', ['_cursesmodule.c'], |
1286 libraries = curses_libs) ) | 1342 libraries = curses_libs) ) |
1287 elif curses_library == 'curses' and platform != 'darwin': | 1343 elif curses_library == 'curses' and host_platform != 'darwin': |
1288 # OSX has an old Berkeley curses, not good enough for | 1344 # OSX has an old Berkeley curses, not good enough for |
1289 # the _curses module. | 1345 # the _curses module. |
1290 if (self.compiler.find_library_file(lib_dirs, 'terminfo')): | 1346 if (self.compiler.find_library_file(lib_dirs, 'terminfo')): |
1291 curses_libs = ['curses', 'terminfo'] | 1347 curses_libs = ['curses', 'terminfo'] |
1292 elif (self.compiler.find_library_file(lib_dirs, 'termcap')): | 1348 elif (self.compiler.find_library_file(lib_dirs, 'termcap')): |
1293 curses_libs = ['curses', 'termcap'] | 1349 curses_libs = ['curses', 'termcap'] |
1294 else: | 1350 else: |
1295 curses_libs = ['curses'] | 1351 curses_libs = ['curses'] |
1296 | 1352 |
1297 exts.append( Extension('_curses', ['_cursesmodule.c'], | 1353 exts.append( Extension('_curses', ['_cursesmodule.c'], |
(...skipping 30 matching lines...) Expand all Loading... |
1328 fp = open(zlib_h) | 1384 fp = open(zlib_h) |
1329 while 1: | 1385 while 1: |
1330 line = fp.readline() | 1386 line = fp.readline() |
1331 if not line: | 1387 if not line: |
1332 break | 1388 break |
1333 if line.startswith('#define ZLIB_VERSION'): | 1389 if line.startswith('#define ZLIB_VERSION'): |
1334 version = line.split()[2] | 1390 version = line.split()[2] |
1335 break | 1391 break |
1336 if version >= version_req: | 1392 if version >= version_req: |
1337 if (self.compiler.find_library_file(lib_dirs, 'z')): | 1393 if (self.compiler.find_library_file(lib_dirs, 'z')): |
1338 if sys.platform == "darwin": | 1394 if host_platform == "darwin": |
1339 zlib_extra_link_args = ('-Wl,-search_paths_first',) | 1395 zlib_extra_link_args = ('-Wl,-search_paths_first',) |
1340 else: | 1396 else: |
1341 zlib_extra_link_args = () | 1397 zlib_extra_link_args = () |
1342 exts.append( Extension('zlib', ['zlibmodule.c'], | 1398 exts.append( Extension('zlib', ['zlibmodule.c'], |
1343 libraries = ['z'], | 1399 libraries = ['z'], |
1344 extra_link_args = zlib_extra_link_arg
s)) | 1400 extra_link_args = zlib_extra_link_arg
s)) |
1345 have_zlib = True | 1401 have_zlib = True |
1346 else: | 1402 else: |
1347 missing.append('zlib') | 1403 missing.append('zlib') |
1348 else: | 1404 else: |
(...skipping 11 matching lines...) Expand all Loading... |
1360 extra_compile_args = [] | 1416 extra_compile_args = [] |
1361 libraries = [] | 1417 libraries = [] |
1362 extra_link_args = [] | 1418 extra_link_args = [] |
1363 exts.append( Extension('binascii', ['binascii.c'], | 1419 exts.append( Extension('binascii', ['binascii.c'], |
1364 extra_compile_args = extra_compile_args, | 1420 extra_compile_args = extra_compile_args, |
1365 libraries = libraries, | 1421 libraries = libraries, |
1366 extra_link_args = extra_link_args) ) | 1422 extra_link_args = extra_link_args) ) |
1367 | 1423 |
1368 # Gustavo Niemeyer's bz2 module. | 1424 # Gustavo Niemeyer's bz2 module. |
1369 if (self.compiler.find_library_file(lib_dirs, 'bz2')): | 1425 if (self.compiler.find_library_file(lib_dirs, 'bz2')): |
1370 if sys.platform == "darwin": | 1426 if host_platform == "darwin": |
1371 bz2_extra_link_args = ('-Wl,-search_paths_first',) | 1427 bz2_extra_link_args = ('-Wl,-search_paths_first',) |
1372 else: | 1428 else: |
1373 bz2_extra_link_args = () | 1429 bz2_extra_link_args = () |
1374 exts.append( Extension('bz2', ['bz2module.c'], | 1430 exts.append( Extension('bz2', ['bz2module.c'], |
1375 libraries = ['bz2'], | 1431 libraries = ['bz2'], |
1376 extra_link_args = bz2_extra_link_args) ) | 1432 extra_link_args = bz2_extra_link_args) ) |
1377 else: | 1433 else: |
1378 missing.append('bz2') | 1434 missing.append('bz2') |
1379 | 1435 |
1380 # Interface to the Expat XML parser | 1436 # Interface to the Expat XML parser |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 ['cjkcodecs/_codecs_%s.c' % loc])) | 1489 ['cjkcodecs/_codecs_%s.c' % loc])) |
1434 else: | 1490 else: |
1435 missing.append('_multibytecodec') | 1491 missing.append('_multibytecodec') |
1436 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): | 1492 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): |
1437 missing.append('_codecs_%s' % loc) | 1493 missing.append('_codecs_%s' % loc) |
1438 | 1494 |
1439 # Dynamic loading module | 1495 # Dynamic loading module |
1440 if sys.maxint == 0x7fffffff: | 1496 if sys.maxint == 0x7fffffff: |
1441 # This requires sizeof(int) == sizeof(long) == sizeof(char*) | 1497 # This requires sizeof(int) == sizeof(long) == sizeof(char*) |
1442 dl_inc = find_file('dlfcn.h', [], inc_dirs) | 1498 dl_inc = find_file('dlfcn.h', [], inc_dirs) |
1443 if (dl_inc is not None) and (platform not in ['atheos']): | 1499 if (dl_inc is not None) and (host_platform not in ['atheos']): |
1444 exts.append( Extension('dl', ['dlmodule.c']) ) | 1500 exts.append( Extension('dl', ['dlmodule.c']) ) |
1445 else: | 1501 else: |
1446 missing.append('dl') | 1502 missing.append('dl') |
1447 else: | 1503 else: |
1448 missing.append('dl') | 1504 missing.append('dl') |
1449 | 1505 |
1450 # Thomas Heller's _ctypes module | 1506 # Thomas Heller's _ctypes module |
1451 self.detect_ctypes(inc_dirs, lib_dirs) | 1507 self.detect_ctypes(inc_dirs, lib_dirs) |
1452 | 1508 |
1453 # Richard Oudkerk's multiprocessing module | 1509 # Richard Oudkerk's multiprocessing module |
1454 if platform == 'win32': # Windows | 1510 if host_platform == 'win32': # Windows |
1455 macros = dict() | 1511 macros = dict() |
1456 libraries = ['ws2_32'] | 1512 libraries = ['ws2_32'] |
1457 | 1513 |
1458 elif platform == 'darwin': # Mac OSX | 1514 elif host_platform == 'darwin': # Mac OSX |
1459 macros = dict() | 1515 macros = dict() |
1460 libraries = [] | 1516 libraries = [] |
1461 | 1517 |
1462 elif platform == 'cygwin': # Cygwin | 1518 elif host_platform == 'cygwin': # Cygwin |
1463 macros = dict() | 1519 macros = dict() |
1464 libraries = [] | 1520 libraries = [] |
1465 | 1521 |
1466 elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freeb
sd8'): | 1522 elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', '
freebsd8'): |
1467 # FreeBSD's P1003.1b semaphore support is very experimental | 1523 # FreeBSD's P1003.1b semaphore support is very experimental |
1468 # and has many known problems. (as of June 2008) | 1524 # and has many known problems. (as of June 2008) |
1469 macros = dict() | 1525 macros = dict() |
1470 libraries = [] | 1526 libraries = [] |
1471 | 1527 |
1472 elif platform.startswith('openbsd'): | 1528 elif host_platform.startswith('openbsd'): |
1473 macros = dict() | 1529 macros = dict() |
1474 libraries = [] | 1530 libraries = [] |
1475 | 1531 |
1476 elif platform.startswith('netbsd'): | 1532 elif host_platform.startswith('netbsd'): |
1477 macros = dict() | 1533 macros = dict() |
1478 libraries = [] | 1534 libraries = [] |
1479 | 1535 |
1480 else: # Linux and other unices | 1536 else: # Linux and other unices |
1481 macros = dict() | 1537 macros = dict() |
1482 libraries = ['rt'] | 1538 libraries = ['rt'] |
1483 | 1539 |
1484 if platform == 'win32': | 1540 if host_platform == 'win32': |
1485 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', | 1541 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', |
1486 '_multiprocessing/semaphore.c', | 1542 '_multiprocessing/semaphore.c', |
1487 '_multiprocessing/pipe_connection.c', | 1543 '_multiprocessing/pipe_connection.c', |
1488 '_multiprocessing/socket_connection.c', | 1544 '_multiprocessing/socket_connection.c', |
1489 '_multiprocessing/win32_functions.c' | 1545 '_multiprocessing/win32_functions.c' |
1490 ] | 1546 ] |
1491 | 1547 |
1492 else: | 1548 else: |
1493 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', | 1549 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', |
1494 '_multiprocessing/socket_connection.c' | 1550 '_multiprocessing/socket_connection.c' |
1495 ] | 1551 ] |
1496 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not | 1552 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not |
1497 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): | 1553 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): |
1498 multiprocessing_srcs.append('_multiprocessing/semaphore.c') | 1554 multiprocessing_srcs.append('_multiprocessing/semaphore.c') |
1499 | 1555 |
1500 if sysconfig.get_config_var('WITH_THREAD'): | 1556 if sysconfig.get_config_var('WITH_THREAD'): |
1501 exts.append ( Extension('_multiprocessing', multiprocessing_srcs, | 1557 exts.append ( Extension('_multiprocessing', multiprocessing_srcs, |
1502 define_macros=macros.items(), | 1558 define_macros=macros.items(), |
1503 include_dirs=["Modules/_multiprocessing"])) | 1559 include_dirs=["Modules/_multiprocessing"])) |
1504 else: | 1560 else: |
1505 missing.append('_multiprocessing') | 1561 missing.append('_multiprocessing') |
1506 | 1562 |
1507 # End multiprocessing | 1563 # End multiprocessing |
1508 | 1564 |
1509 | 1565 |
1510 # Platform-specific libraries | 1566 # Platform-specific libraries |
1511 if platform == 'linux2': | 1567 if host_platform == 'linux2': |
1512 # Linux-specific modules | 1568 # Linux-specific modules |
1513 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) | 1569 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) |
1514 else: | 1570 else: |
1515 missing.append('linuxaudiodev') | 1571 missing.append('linuxaudiodev') |
1516 | 1572 |
1517 if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', | 1573 if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', |
1518 'freebsd7', 'freebsd8') | 1574 'freebsd7', 'freebsd8') |
1519 or platform.startswith("gnukfreebsd")): | 1575 or host_platform.startswith("gnukfreebsd")): |
1520 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) | 1576 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) |
1521 else: | 1577 else: |
1522 missing.append('ossaudiodev') | 1578 missing.append('ossaudiodev') |
1523 | 1579 |
1524 if platform == 'sunos5': | 1580 if host_platform == 'sunos5': |
1525 # SunOS specific modules | 1581 # SunOS specific modules |
1526 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) | 1582 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) |
1527 else: | 1583 else: |
1528 missing.append('sunaudiodev') | 1584 missing.append('sunaudiodev') |
1529 | 1585 |
1530 if platform == 'darwin': | 1586 if host_platform == 'darwin': |
1531 # _scproxy | 1587 # _scproxy |
1532 exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules
/_scproxy.c")], | 1588 exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules
/_scproxy.c")], |
1533 extra_link_args= [ | 1589 extra_link_args= [ |
1534 '-framework', 'SystemConfiguration', | 1590 '-framework', 'SystemConfiguration', |
1535 '-framework', 'CoreFoundation' | 1591 '-framework', 'CoreFoundation' |
1536 ])) | 1592 ])) |
1537 | 1593 |
1538 | 1594 |
1539 if platform == 'darwin' and ("--disable-toolbox-glue" not in | 1595 if host_platform == 'darwin' and ("--disable-toolbox-glue" not in |
1540 sysconfig.get_config_var("CONFIG_ARGS")): | 1596 sysconfig.get_config_var("CONFIG_ARGS")): |
1541 | 1597 |
1542 if int(os.uname()[2].split('.')[0]) >= 8: | 1598 if int(os.uname()[2].split('.')[0]) >= 8: |
1543 # We're on Mac OS X 10.4 or later, the compiler should | 1599 # We're on Mac OS X 10.4 or later, the compiler should |
1544 # support '-Wno-deprecated-declarations'. This will | 1600 # support '-Wno-deprecated-declarations'. This will |
1545 # surpress deprecation warnings for the Carbon extensions, | 1601 # surpress deprecation warnings for the Carbon extensions, |
1546 # these extensions wrap the Carbon APIs and even those | 1602 # these extensions wrap the Carbon APIs and even those |
1547 # parts that are deprecated. | 1603 # parts that are deprecated. |
1548 carbon_extra_compile_args = ['-Wno-deprecated-declarations'] | 1604 carbon_extra_compile_args = ['-Wno-deprecated-declarations'] |
1549 else: | 1605 else: |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 self.extensions.append(ext) | 1781 self.extensions.append(ext) |
1726 return 1 | 1782 return 1 |
1727 | 1783 |
1728 | 1784 |
1729 def detect_tkinter(self, inc_dirs, lib_dirs): | 1785 def detect_tkinter(self, inc_dirs, lib_dirs): |
1730 # The _tkinter module. | 1786 # The _tkinter module. |
1731 | 1787 |
1732 # Rather than complicate the code below, detecting and building | 1788 # Rather than complicate the code below, detecting and building |
1733 # AquaTk is a separate method. Only one Tkinter will be built on | 1789 # AquaTk is a separate method. Only one Tkinter will be built on |
1734 # Darwin - either AquaTk, if it is found, or X11 based Tk. | 1790 # Darwin - either AquaTk, if it is found, or X11 based Tk. |
1735 platform = self.get_platform() | 1791 if (host_platform == 'darwin' and |
1736 if (platform == 'darwin' and | |
1737 self.detect_tkinter_darwin(inc_dirs, lib_dirs)): | 1792 self.detect_tkinter_darwin(inc_dirs, lib_dirs)): |
1738 return | 1793 return |
1739 | 1794 |
1740 # Assume we haven't found any of the libraries or include files | 1795 # Assume we haven't found any of the libraries or include files |
1741 # The versions with dots are used on Unix, and the versions without | 1796 # The versions with dots are used on Unix, and the versions without |
1742 # dots on Windows, for detection by cygwin. | 1797 # dots on Windows, for detection by cygwin. |
1743 tcllib = tklib = tcl_includes = tk_includes = None | 1798 tcllib = tklib = tcl_includes = tk_includes = None |
1744 for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', | 1799 for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', |
1745 '8.2', '82', '8.1', '81', '8.0', '80']: | 1800 '8.2', '82', '8.1', '81', '8.0', '80']: |
1746 tklib = self.compiler.find_library_file(lib_dirs, | 1801 tklib = self.compiler.find_library_file(lib_dirs, |
1747 'tk' + version) | 1802 'tk' + version) |
1748 tcllib = self.compiler.find_library_file(lib_dirs, | 1803 tcllib = self.compiler.find_library_file(lib_dirs, |
1749 'tcl' + version) | 1804 'tcl' + version) |
1750 if tklib and tcllib: | 1805 if tklib and tcllib: |
1751 # Exit the loop when we've found the Tcl/Tk libraries | 1806 # Exit the loop when we've found the Tcl/Tk libraries |
1752 break | 1807 break |
1753 | 1808 |
1754 # Now check for the header files | 1809 # Now check for the header files |
1755 if tklib and tcllib: | 1810 if tklib and tcllib: |
1756 # Check for the include files on Debian and {Free,Open}BSD, where | 1811 # Check for the include files on Debian and {Free,Open}BSD, where |
1757 # they're put in /usr/include/{tcl,tk}X.Y | 1812 # they're put in /usr/include/{tcl,tk}X.Y |
1758 dotversion = version | 1813 dotversion = version |
1759 if '.' not in dotversion and "bsd" in sys.platform.lower(): | 1814 if '.' not in dotversion and "bsd" in host_platform.lower(): |
1760 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, | 1815 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, |
1761 # but the include subdirs are named like .../include/tcl8.3. | 1816 # but the include subdirs are named like .../include/tcl8.3. |
1762 dotversion = dotversion[:-1] + '.' + dotversion[-1] | 1817 dotversion = dotversion[:-1] + '.' + dotversion[-1] |
1763 tcl_include_sub = [] | 1818 tcl_include_sub = [] |
1764 tk_include_sub = [] | 1819 tk_include_sub = [] |
1765 for dir in inc_dirs: | 1820 for dir in inc_dirs: |
1766 tcl_include_sub += [dir + os.sep + "tcl" + dotversion] | 1821 tcl_include_sub += [dir + os.sep + "tcl" + dotversion] |
1767 tk_include_sub += [dir + os.sep + "tk" + dotversion] | 1822 tk_include_sub += [dir + os.sep + "tk" + dotversion] |
1768 tk_include_sub += tcl_include_sub | 1823 tk_include_sub += tcl_include_sub |
1769 tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub) | 1824 tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub) |
1770 tk_includes = find_file('tk.h', inc_dirs, tk_include_sub) | 1825 tk_includes = find_file('tk.h', inc_dirs, tk_include_sub) |
1771 | 1826 |
1772 if (tcllib is None or tklib is None or | 1827 if (tcllib is None or tklib is None or |
1773 tcl_includes is None or tk_includes is None): | 1828 tcl_includes is None or tk_includes is None): |
1774 self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) | 1829 self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) |
1775 return | 1830 return |
1776 | 1831 |
1777 # OK... everything seems to be present for Tcl/Tk. | 1832 # OK... everything seems to be present for Tcl/Tk. |
1778 | 1833 |
1779 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] | 1834 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] |
1780 for dir in tcl_includes + tk_includes: | 1835 for dir in tcl_includes + tk_includes: |
1781 if dir not in include_dirs: | 1836 if dir not in include_dirs: |
1782 include_dirs.append(dir) | 1837 include_dirs.append(dir) |
1783 | 1838 |
1784 # Check for various platform-specific directories | 1839 # Check for various platform-specific directories |
1785 if platform == 'sunos5': | 1840 if host_platform == 'sunos5': |
1786 include_dirs.append('/usr/openwin/include') | 1841 include_dirs.append('/usr/openwin/include') |
1787 added_lib_dirs.append('/usr/openwin/lib') | 1842 added_lib_dirs.append('/usr/openwin/lib') |
1788 elif os.path.exists('/usr/X11R6/include'): | 1843 elif os.path.exists('/usr/X11R6/include'): |
1789 include_dirs.append('/usr/X11R6/include') | 1844 include_dirs.append('/usr/X11R6/include') |
1790 added_lib_dirs.append('/usr/X11R6/lib64') | 1845 added_lib_dirs.append('/usr/X11R6/lib64') |
1791 added_lib_dirs.append('/usr/X11R6/lib') | 1846 added_lib_dirs.append('/usr/X11R6/lib') |
1792 elif os.path.exists('/usr/X11R5/include'): | 1847 elif os.path.exists('/usr/X11R5/include'): |
1793 include_dirs.append('/usr/X11R5/include') | 1848 include_dirs.append('/usr/X11R5/include') |
1794 added_lib_dirs.append('/usr/X11R5/lib') | 1849 added_lib_dirs.append('/usr/X11R5/lib') |
1795 else: | 1850 else: |
1796 # Assume default location for X11 | 1851 # Assume default location for X11 |
1797 include_dirs.append('/usr/X11/include') | 1852 include_dirs.append('/usr/X11/include') |
1798 added_lib_dirs.append('/usr/X11/lib') | 1853 added_lib_dirs.append('/usr/X11/lib') |
1799 | 1854 |
1800 # If Cygwin, then verify that X is installed before proceeding | 1855 # If Cygwin, then verify that X is installed before proceeding |
1801 if platform == 'cygwin': | 1856 if host_platform == 'cygwin': |
1802 x11_inc = find_file('X11/Xlib.h', [], include_dirs) | 1857 x11_inc = find_file('X11/Xlib.h', [], include_dirs) |
1803 if x11_inc is None: | 1858 if x11_inc is None: |
1804 return | 1859 return |
1805 | 1860 |
1806 # Check for BLT extension | 1861 # Check for BLT extension |
1807 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, | 1862 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, |
1808 'BLT8.0'): | 1863 'BLT8.0'): |
1809 defs.append( ('WITH_BLT', 1) ) | 1864 defs.append( ('WITH_BLT', 1) ) |
1810 libs.append('BLT8.0') | 1865 libs.append('BLT8.0') |
1811 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs, | 1866 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs, |
1812 'BLT'): | 1867 'BLT'): |
1813 defs.append( ('WITH_BLT', 1) ) | 1868 defs.append( ('WITH_BLT', 1) ) |
1814 libs.append('BLT') | 1869 libs.append('BLT') |
1815 | 1870 |
1816 # Add the Tcl/Tk libraries | 1871 # Add the Tcl/Tk libraries |
1817 libs.append('tk'+ version) | 1872 libs.append('tk'+ version) |
1818 libs.append('tcl'+ version) | 1873 libs.append('tcl'+ version) |
1819 | 1874 |
1820 if platform in ['aix3', 'aix4']: | 1875 if host_platform in ['aix3', 'aix4']: |
1821 libs.append('ld') | 1876 libs.append('ld') |
1822 | 1877 |
1823 # Finally, link with the X11 libraries (not appropriate on cygwin) | 1878 # Finally, link with the X11 libraries (not appropriate on cygwin) |
1824 if platform != "cygwin": | 1879 if host_platform != "cygwin": |
1825 libs.append('X11') | 1880 libs.append('X11') |
1826 | 1881 |
1827 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], | 1882 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
1828 define_macros=[('WITH_APPINIT', 1)] + defs, | 1883 define_macros=[('WITH_APPINIT', 1)] + defs, |
1829 include_dirs = include_dirs, | 1884 include_dirs = include_dirs, |
1830 libraries = libs, | 1885 libraries = libs, |
1831 library_dirs = added_lib_dirs, | 1886 library_dirs = added_lib_dirs, |
1832 ) | 1887 ) |
1833 self.extensions.append(ext) | 1888 self.extensions.append(ext) |
1834 | 1889 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 self.compiler.src_extensions.append('.S') | 1921 self.compiler.src_extensions.append('.S') |
1867 | 1922 |
1868 include_dirs = [os.path.join(ffi_srcdir, 'include'), | 1923 include_dirs = [os.path.join(ffi_srcdir, 'include'), |
1869 os.path.join(ffi_srcdir, 'powerpc')] | 1924 os.path.join(ffi_srcdir, 'powerpc')] |
1870 ext.include_dirs.extend(include_dirs) | 1925 ext.include_dirs.extend(include_dirs) |
1871 ext.sources.extend(sources) | 1926 ext.sources.extend(sources) |
1872 return True | 1927 return True |
1873 | 1928 |
1874 def configure_ctypes(self, ext): | 1929 def configure_ctypes(self, ext): |
1875 if not self.use_system_libffi: | 1930 if not self.use_system_libffi: |
1876 if sys.platform == 'darwin': | 1931 if host_platform == 'darwin': |
1877 return self.configure_ctypes_darwin(ext) | 1932 return self.configure_ctypes_darwin(ext) |
1878 | 1933 |
1879 srcdir = sysconfig.get_config_var('srcdir') | 1934 srcdir = sysconfig.get_config_var('srcdir') |
1880 ffi_builddir = os.path.join(self.build_temp, 'libffi') | 1935 ffi_builddir = os.path.join(self.build_temp, 'libffi') |
1881 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', | 1936 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', |
1882 '_ctypes', 'libffi')) | 1937 '_ctypes', 'libffi')) |
1883 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') | 1938 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') |
1884 | 1939 |
1885 from distutils.dep_util import newer_group | 1940 from distutils.dep_util import newer_group |
1886 | 1941 |
1887 config_sources = [os.path.join(ffi_srcdir, fname) | 1942 config_sources = [os.path.join(ffi_srcdir, fname) |
1888 for fname in os.listdir(ffi_srcdir) | 1943 for fname in os.listdir(ffi_srcdir) |
1889 if os.path.isfile(os.path.join(ffi_srcdir, fname))
] | 1944 if os.path.isfile(os.path.join(ffi_srcdir, fname))
] |
1890 if self.force or newer_group(config_sources, | 1945 if self.force or newer_group(config_sources, |
1891 ffi_configfile): | 1946 ffi_configfile): |
1892 from distutils.dir_util import mkpath | 1947 from distutils.dir_util import mkpath |
1893 mkpath(ffi_builddir) | 1948 mkpath(ffi_builddir) |
1894 config_args = [] | 1949 config_args = [arg for arg in sysconfig.get_config_var("CONFIG_A
RGS").split() |
| 1950 if (('--host=' in arg) or ('--build=' in arg))] |
1895 if not self.verbose: | 1951 if not self.verbose: |
1896 config_args.append("-q") | 1952 config_args.append("-q") |
1897 | 1953 |
1898 # Pass empty CFLAGS because we'll just append the resulting | 1954 # Pass empty CFLAGS because we'll just append the resulting |
1899 # CFLAGS to Python's; -g or -O2 is to be avoided. | 1955 # CFLAGS to Python's; -g or -O2 is to be avoided. |
1900 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ | 1956 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ |
1901 % (ffi_builddir, ffi_srcdir, " ".join(config_args)) | 1957 % (ffi_builddir, ffi_srcdir, " ".join(config_args)) |
1902 | 1958 |
1903 res = os.system(cmd) | 1959 res = os.system(cmd) |
1904 if res or not os.path.exists(ffi_configfile): | 1960 if res or not os.path.exists(ffi_configfile): |
(...skipping 23 matching lines...) Expand all Loading... |
1928 include_dirs = [] | 1984 include_dirs = [] |
1929 extra_compile_args = [] | 1985 extra_compile_args = [] |
1930 extra_link_args = [] | 1986 extra_link_args = [] |
1931 sources = ['_ctypes/_ctypes.c', | 1987 sources = ['_ctypes/_ctypes.c', |
1932 '_ctypes/callbacks.c', | 1988 '_ctypes/callbacks.c', |
1933 '_ctypes/callproc.c', | 1989 '_ctypes/callproc.c', |
1934 '_ctypes/stgdict.c', | 1990 '_ctypes/stgdict.c', |
1935 '_ctypes/cfield.c'] | 1991 '_ctypes/cfield.c'] |
1936 depends = ['_ctypes/ctypes.h'] | 1992 depends = ['_ctypes/ctypes.h'] |
1937 | 1993 |
1938 if sys.platform == 'darwin': | 1994 if host_platform == 'darwin': |
1939 sources.append('_ctypes/malloc_closure.c') | 1995 sources.append('_ctypes/malloc_closure.c') |
1940 sources.append('_ctypes/darwin/dlfcn_simple.c') | 1996 sources.append('_ctypes/darwin/dlfcn_simple.c') |
1941 extra_compile_args.append('-DMACOSX') | 1997 extra_compile_args.append('-DMACOSX') |
1942 include_dirs.append('_ctypes/darwin') | 1998 include_dirs.append('_ctypes/darwin') |
1943 # XXX Is this still needed? | 1999 # XXX Is this still needed? |
1944 ## extra_link_args.extend(['-read_only_relocs', 'warning']) | 2000 ## extra_link_args.extend(['-read_only_relocs', 'warning']) |
1945 | 2001 |
1946 elif sys.platform == 'sunos5': | 2002 elif host_platform == 'sunos5': |
1947 # XXX This shouldn't be necessary; it appears that some | 2003 # XXX This shouldn't be necessary; it appears that some |
1948 # of the assembler code is non-PIC (i.e. it has relocations | 2004 # of the assembler code is non-PIC (i.e. it has relocations |
1949 # when it shouldn't. The proper fix would be to rewrite | 2005 # when it shouldn't. The proper fix would be to rewrite |
1950 # the assembler code to be PIC. | 2006 # the assembler code to be PIC. |
1951 # This only works with GCC; the Sun compiler likely refuses | 2007 # This only works with GCC; the Sun compiler likely refuses |
1952 # this option. If you want to compile ctypes with the Sun | 2008 # this option. If you want to compile ctypes with the Sun |
1953 # compiler, please research a proper solution, instead of | 2009 # compiler, please research a proper solution, instead of |
1954 # finding some -z option for the Sun compiler. | 2010 # finding some -z option for the Sun compiler. |
1955 extra_link_args.append('-mimpure-text') | 2011 extra_link_args.append('-mimpure-text') |
1956 | 2012 |
1957 elif sys.platform.startswith('hp-ux'): | 2013 elif host_platform.startswith('hp-ux'): |
1958 extra_link_args.append('-fPIC') | 2014 extra_link_args.append('-fPIC') |
1959 | 2015 |
1960 ext = Extension('_ctypes', | 2016 ext = Extension('_ctypes', |
1961 include_dirs=include_dirs, | 2017 include_dirs=include_dirs, |
1962 extra_compile_args=extra_compile_args, | 2018 extra_compile_args=extra_compile_args, |
1963 extra_link_args=extra_link_args, | 2019 extra_link_args=extra_link_args, |
1964 libraries=[], | 2020 libraries=[], |
1965 sources=sources, | 2021 sources=sources, |
1966 depends=depends) | 2022 depends=depends) |
1967 ext_test = Extension('_ctypes_test', | 2023 ext_test = Extension('_ctypes_test', |
1968 sources=['_ctypes/_ctypes_test.c']) | 2024 sources=['_ctypes/_ctypes_test.c']) |
1969 self.extensions.extend([ext, ext_test]) | 2025 self.extensions.extend([ext, ext_test]) |
1970 | 2026 |
1971 if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): | 2027 if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): |
1972 return | 2028 return |
1973 | 2029 |
1974 if sys.platform == 'darwin': | 2030 if host_platform == 'darwin': |
1975 # OS X 10.5 comes with libffi.dylib; the include files are | 2031 # OS X 10.5 comes with libffi.dylib; the include files are |
1976 # in /usr/include/ffi | 2032 # in /usr/include/ffi |
1977 inc_dirs.append('/usr/include/ffi') | 2033 inc_dirs.append('/usr/include/ffi') |
1978 | 2034 |
1979 ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] | 2035 ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] |
1980 if not ffi_inc or ffi_inc[0] == '': | 2036 if not ffi_inc or ffi_inc[0] == '': |
1981 ffi_inc = find_file('ffi.h', [], inc_dirs) | 2037 ffi_inc = find_file('ffi.h', [], inc_dirs) |
1982 if ffi_inc is not None: | 2038 if ffi_inc is not None: |
1983 ffi_h = ffi_inc[0] + '/ffi.h' | 2039 ffi_h = ffi_inc[0] + '/ffi.h' |
1984 fp = open(ffi_h) | 2040 fp = open(ffi_h) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 | 2156 |
2101 # Scripts to install | 2157 # Scripts to install |
2102 scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', | 2158 scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', |
2103 'Tools/scripts/2to3', | 2159 'Tools/scripts/2to3', |
2104 'Lib/smtpd.py'] | 2160 'Lib/smtpd.py'] |
2105 ) | 2161 ) |
2106 | 2162 |
2107 # --install-platlib | 2163 # --install-platlib |
2108 if __name__ == '__main__': | 2164 if __name__ == '__main__': |
2109 main() | 2165 main() |
OLD | NEW |