| 
									
										
										
										
											2001-01-26 21:56:58 +00:00
										 |  |  | # Autodetecting setup.py script for building the Python extensions | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-26 21:56:58 +00:00
										 |  |  | __version__ = "$Revision$" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-07 03:25:18 +00:00
										 |  |  | import sys, os, imp, re, optparse | 
					
						
							| 
									
										
										
										
											2008-01-25 15:52:11 +00:00
										 |  |  | from glob import glob | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  | from platform import machine as platform_machine | 
					
						
							| 
									
										
										
										
											2010-01-23 09:23:15 +00:00
										 |  |  | import sysconfig | 
					
						
							| 
									
										
										
										
											2002-12-17 16:47:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | from distutils import log | 
					
						
							| 
									
										
										
										
											2001-02-23 16:32:32 +00:00
										 |  |  | from distutils import text_file | 
					
						
							| 
									
										
										
										
											2001-01-26 18:03:24 +00:00
										 |  |  | from distutils.errors import * | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | from distutils.core import Extension, setup | 
					
						
							|  |  |  | from distutils.command.build_ext import build_ext | 
					
						
							| 
									
										
										
										
											2001-05-21 20:29:27 +00:00
										 |  |  | from distutils.command.install import install | 
					
						
							| 
									
										
										
										
											2002-12-17 16:47:17 +00:00
										 |  |  | from distutils.command.install_lib import install_lib | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-02 22:25:29 +00:00
										 |  |  | # Were we compiled --with-pydebug or with #define Py_DEBUG? | 
					
						
							|  |  |  | COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | # This global variable is used to hold the list of modules to be disabled. | 
					
						
							|  |  |  | disabled_module_list = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-16 15:26:48 +00:00
										 |  |  | def add_dir_to_list(dirlist, dir): | 
					
						
							|  |  |  |     """Add the directory 'dir' to the list 'dirlist' (at the front) if
 | 
					
						
							|  |  |  |     1) 'dir' is not already in 'dirlist' | 
					
						
							|  |  |  |     2) 'dir' actually exists, and is a directory."""
 | 
					
						
							| 
									
										
										
										
											2002-06-26 15:44:30 +00:00
										 |  |  |     if dir is not None and os.path.isdir(dir) and dir not in dirlist: | 
					
						
							| 
									
										
										
										
											2002-01-16 15:26:48 +00:00
										 |  |  |         dirlist.insert(0, dir) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | def find_file(filename, std_dirs, paths): | 
					
						
							|  |  |  |     """Searches for the directory where a given file is located,
 | 
					
						
							|  |  |  |     and returns a possibly-empty list of additional directories, or None | 
					
						
							|  |  |  |     if the file couldn't be found at all. | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |     'filename' is the name of a file, such as readline.h or libcrypto.a. | 
					
						
							|  |  |  |     'std_dirs' is the list of standard system directories; if the | 
					
						
							|  |  |  |         file is found in one of them, no additional directives are needed. | 
					
						
							|  |  |  |     'paths' is a list of additional locations to check; if the file is | 
					
						
							|  |  |  |         found in one of them, the resulting list will contain the directory. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Check the standard locations | 
					
						
							|  |  |  |     for dir in std_dirs: | 
					
						
							|  |  |  |         f = os.path.join(dir, filename) | 
					
						
							|  |  |  |         if os.path.exists(f): return [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Check the additional directories | 
					
						
							|  |  |  |     for dir in paths: | 
					
						
							|  |  |  |         f = os.path.join(dir, filename) | 
					
						
							|  |  |  |         if os.path.exists(f): | 
					
						
							|  |  |  |             return [dir] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Not found anywhere | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |     return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | def find_library_file(compiler, libname, std_dirs, paths): | 
					
						
							| 
									
										
										
										
											2002-11-27 13:43:46 +00:00
										 |  |  |     result = compiler.find_library_file(std_dirs + paths, libname) | 
					
						
							|  |  |  |     if result is None: | 
					
						
							|  |  |  |         return None | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-27 13:43:46 +00:00
										 |  |  |     # Check whether the found file is in one of the standard directories | 
					
						
							|  |  |  |     dirname = os.path.dirname(result) | 
					
						
							|  |  |  |     for p in std_dirs: | 
					
						
							|  |  |  |         # Ensure path doesn't end with path separator | 
					
						
							| 
									
										
										
										
											2003-05-06 20:59:57 +00:00
										 |  |  |         p = p.rstrip(os.sep) | 
					
						
							| 
									
										
										
										
											2002-11-27 13:43:46 +00:00
										 |  |  |         if p == dirname: | 
					
						
							|  |  |  |             return [ ] | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-27 13:43:46 +00:00
										 |  |  |     # Otherwise, it must have been in one of the additional directories, | 
					
						
							|  |  |  |     # so we have to figure out which one. | 
					
						
							|  |  |  |     for p in paths: | 
					
						
							|  |  |  |         # Ensure path doesn't end with path separator | 
					
						
							| 
									
										
										
										
											2003-05-06 20:59:57 +00:00
										 |  |  |         p = p.rstrip(os.sep) | 
					
						
							| 
									
										
										
										
											2002-11-27 13:43:46 +00:00
										 |  |  |         if p == dirname: | 
					
						
							|  |  |  |             return [p] | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         assert False, "Internal error: Path not found in std_dirs or paths" | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | def module_enabled(extlist, modname): | 
					
						
							|  |  |  |     """Returns whether the module 'modname' is present in the list
 | 
					
						
							|  |  |  |     of extensions 'extlist'."""
 | 
					
						
							|  |  |  |     extlist = [ext for ext in extlist if ext.name == modname] | 
					
						
							|  |  |  |     return len(extlist) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  | def find_module_file(module, dirlist): | 
					
						
							|  |  |  |     """Find a module in a set of possible folders. If it is not found
 | 
					
						
							|  |  |  |     return the unadorned filename"""
 | 
					
						
							|  |  |  |     list = find_file(module, [], dirlist) | 
					
						
							|  |  |  |     if not list: | 
					
						
							|  |  |  |         return module | 
					
						
							|  |  |  |     if len(list) > 1: | 
					
						
							| 
									
										
										
										
											2003-02-20 02:11:43 +00:00
										 |  |  |         log.info("WARNING: multiple copies of %s found"%module) | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |     return os.path.join(list[0], module) | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | class PyBuildExt(build_ext): | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |     def __init__(self, dist): | 
					
						
							|  |  |  |         build_ext.__init__(self, dist) | 
					
						
							|  |  |  |         self.failed = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |     def build_extensions(self): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Detect which modules should be compiled | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         missing = self.detect_modules() | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Remove modules that are present on the disabled list | 
					
						
							| 
									
										
										
										
											2008-01-18 09:51:43 +00:00
										 |  |  |         extensions = [ext for ext in self.extensions | 
					
						
							|  |  |  |                       if ext.name not in disabled_module_list] | 
					
						
							|  |  |  |         # move ctypes to the end, it depends on other modules | 
					
						
							|  |  |  |         ext_map = dict((ext.name, i) for i, ext in enumerate(extensions)) | 
					
						
							|  |  |  |         if "_ctypes" in ext_map: | 
					
						
							|  |  |  |             ctypes = extensions.pop(ext_map["_ctypes"]) | 
					
						
							|  |  |  |             extensions.append(ctypes) | 
					
						
							|  |  |  |         self.extensions = extensions | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Fix up the autodetected modules, prefixing all the source files | 
					
						
							|  |  |  |         # with Modules/ and adding Python's include directory to the path. | 
					
						
							|  |  |  |         (srcdir,) = sysconfig.get_config_vars('srcdir') | 
					
						
							| 
									
										
										
										
											2002-10-14 20:48:09 +00:00
										 |  |  |         if not srcdir: | 
					
						
							|  |  |  |             # Maybe running on Windows but not using CYGWIN? | 
					
						
							|  |  |  |             raise ValueError("No source directory; cannot proceed.") | 
					
						
							| 
									
										
										
										
											2009-02-06 00:21:55 +00:00
										 |  |  |         srcdir = os.path.abspath(srcdir) | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |         moddirlist = [os.path.join(srcdir, 'Modules')] | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |         # Platform-dependent module source and include directories | 
					
						
							| 
									
										
										
										
											2009-02-05 22:14:04 +00:00
										 |  |  |         incdirlist = [] | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |         platform = self.get_platform() | 
					
						
							| 
									
										
										
										
											2004-08-26 05:23:19 +00:00
										 |  |  |         if platform in ('darwin', 'mac') and ("--disable-toolbox-glue" not in | 
					
						
							| 
									
										
										
										
											2004-08-26 01:44:07 +00:00
										 |  |  |             sysconfig.get_config_var("CONFIG_ARGS")): | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |             # Mac OS X also includes some mac-specific modules | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |             macmoddir = os.path.join(srcdir, 'Mac/Modules') | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |             moddirlist.append(macmoddir) | 
					
						
							| 
									
										
										
										
											2009-02-05 22:14:04 +00:00
										 |  |  |             incdirlist.append(os.path.join(srcdir, 'Mac/Include')) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-28 22:49:26 +00:00
										 |  |  |         # Fix up the paths for scripts, too | 
					
						
							|  |  |  |         self.distribution.scripts = [os.path.join(srcdir, filename) | 
					
						
							|  |  |  |                                      for filename in self.distribution.scripts] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-25 15:52:11 +00:00
										 |  |  |         # Python header files | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |         headers = [sysconfig.get_config_h_filename()] | 
					
						
							| 
									
										
										
										
											2010-01-23 09:23:15 +00:00
										 |  |  |         headers += glob(os.path.join(sysconfig.get_path('platinclude'), "*.h")) | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         for ext in self.extensions[:]: | 
					
						
							| 
									
										
										
										
											2001-08-05 22:31:19 +00:00
										 |  |  |             ext.sources = [ find_module_file(filename, moddirlist) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |                             for filename in ext.sources ] | 
					
						
							| 
									
										
										
										
											2002-06-13 17:38:11 +00:00
										 |  |  |             if ext.depends is not None: | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |                 ext.depends = [find_module_file(filename, moddirlist) | 
					
						
							| 
									
										
										
										
											2002-06-13 17:38:11 +00:00
										 |  |  |                                for filename in ext.depends] | 
					
						
							| 
									
										
										
										
											2008-01-25 15:52:11 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 ext.depends = [] | 
					
						
							|  |  |  |             # re-compile extensions if a header file has been changed | 
					
						
							|  |  |  |             ext.depends.extend(headers) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-05 22:14:04 +00:00
										 |  |  |             # platform specific include directories | 
					
						
							|  |  |  |             ext.include_dirs.extend(incdirlist) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-19 16:58:21 +00:00
										 |  |  |             # If a module has already been built statically, | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             # don't build it here | 
					
						
							| 
									
										
										
										
											2001-01-19 16:58:21 +00:00
										 |  |  |             if ext.name in sys.builtin_module_names: | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |                 self.extensions.remove(ext) | 
					
						
							| 
									
										
										
										
											2001-01-18 20:39:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-26 15:44:30 +00:00
										 |  |  |         if platform != 'mac': | 
					
						
							| 
									
										
										
										
											2005-12-27 18:24:27 +00:00
										 |  |  |             # Parse Modules/Setup and Modules/Setup.local to figure out which | 
					
						
							|  |  |  |             # modules are turned on in the file. | 
					
						
							| 
									
										
										
										
											2002-06-26 15:44:30 +00:00
										 |  |  |             remove_modules = [] | 
					
						
							| 
									
										
										
										
											2005-12-27 18:24:27 +00:00
										 |  |  |             for filename in ('Modules/Setup', 'Modules/Setup.local'): | 
					
						
							|  |  |  |                 input = text_file.TextFile(filename, join_lines=1) | 
					
						
							|  |  |  |                 while 1: | 
					
						
							|  |  |  |                     line = input.readline() | 
					
						
							|  |  |  |                     if not line: break | 
					
						
							|  |  |  |                     line = line.split() | 
					
						
							|  |  |  |                     remove_modules.append(line[0]) | 
					
						
							|  |  |  |                 input.close() | 
					
						
							| 
									
										
										
										
											2005-12-30 18:42:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-26 15:44:30 +00:00
										 |  |  |             for ext in self.extensions[:]: | 
					
						
							|  |  |  |                 if ext.name in remove_modules: | 
					
						
							|  |  |  |                     self.extensions.remove(ext) | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 20:39:34 +00:00
										 |  |  |         # When you run "make CC=altcc" or something similar, you really want | 
					
						
							|  |  |  |         # those environment variables passed into the setup.py phase.  Here's | 
					
						
							|  |  |  |         # a small set of useful ones. | 
					
						
							|  |  |  |         compiler = os.environ.get('CC') | 
					
						
							|  |  |  |         args = {} | 
					
						
							|  |  |  |         # unfortunately, distutils doesn't let us provide separate C and C++ | 
					
						
							|  |  |  |         # compilers | 
					
						
							|  |  |  |         if compiler is not None: | 
					
						
							| 
									
										
										
										
											2005-04-25 07:14:03 +00:00
										 |  |  |             (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') | 
					
						
							|  |  |  |             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         self.compiler.set_executables(**args) | 
					
						
							| 
									
										
										
										
											2001-01-18 20:39:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         build_ext.build_extensions(self) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         longest = max([len(e.name) for e in self.extensions]) | 
					
						
							|  |  |  |         if self.failed: | 
					
						
							|  |  |  |             longest = max(longest, max([len(name) for name in self.failed])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def print_three_column(lst): | 
					
						
							| 
									
										
										
										
											2007-03-06 17:49:14 +00:00
										 |  |  |             lst.sort(key=str.lower) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             # guarantee zip() doesn't drop anything | 
					
						
							|  |  |  |             while len(lst) % 3: | 
					
						
							|  |  |  |                 lst.append("") | 
					
						
							|  |  |  |             for e, f, g in zip(lst[::3], lst[1::3], lst[2::3]): | 
					
						
							|  |  |  |                 print "%-*s   %-*s   %-*s" % (longest, e, longest, f, | 
					
						
							|  |  |  |                                               longest, g) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if missing: | 
					
						
							|  |  |  |             print | 
					
						
							| 
									
										
										
										
											2008-12-28 11:58:49 +00:00
										 |  |  |             print ("Python build finished, but the necessary bits to build " | 
					
						
							|  |  |  |                    "these modules were not found:") | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             print_three_column(missing) | 
					
						
							| 
									
										
										
										
											2007-08-22 23:14:27 +00:00
										 |  |  |             print ("To find the necessary bits, look in setup.py in" | 
					
						
							|  |  |  |                    " detect_modules() for the module's name.") | 
					
						
							|  |  |  |             print | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if self.failed: | 
					
						
							|  |  |  |             failed = self.failed[:] | 
					
						
							|  |  |  |             print | 
					
						
							|  |  |  |             print "Failed to build these modules:" | 
					
						
							|  |  |  |             print_three_column(failed) | 
					
						
							| 
									
										
										
										
											2007-08-22 23:14:27 +00:00
										 |  |  |             print | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-26 18:03:24 +00:00
										 |  |  |     def build_extension(self, ext): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  |         if ext.name == '_ctypes': | 
					
						
							| 
									
										
										
										
											2006-04-07 19:27:56 +00:00
										 |  |  |             if not self.configure_ctypes(ext): | 
					
						
							|  |  |  |                 return | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-26 18:03:24 +00:00
										 |  |  |         try: | 
					
						
							|  |  |  |             build_ext.build_extension(self, ext) | 
					
						
							|  |  |  |         except (CCompilerError, DistutilsError), why: | 
					
						
							|  |  |  |             self.announce('WARNING: building of extension "%s" failed: %s' % | 
					
						
							|  |  |  |                           (ext.name, sys.exc_info()[1])) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             self.failed.append(ext.name) | 
					
						
							| 
									
										
										
										
											2001-05-21 20:48:09 +00:00
										 |  |  |             return | 
					
						
							| 
									
										
										
										
											2001-11-01 14:44:15 +00:00
										 |  |  |         # Workaround for Mac OS X: The Carbon-based modules cannot be | 
					
						
							|  |  |  |         # reliably imported into a command-line Python | 
					
						
							|  |  |  |         if 'Carbon' in ext.extra_link_args: | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  |             self.announce( | 
					
						
							|  |  |  |                 'WARNING: skipping import check for Carbon-based "%s"' % | 
					
						
							|  |  |  |                 ext.name) | 
					
						
							|  |  |  |             return | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if self.get_platform() == 'darwin' and ( | 
					
						
							|  |  |  |                 sys.maxint > 2**32 and '-arch' in ext.extra_link_args): | 
					
						
							|  |  |  |             # Don't bother doing an import check when an extension was | 
					
						
							|  |  |  |             # build with an explicit '-arch' flag on OSX. That's currently | 
					
						
							|  |  |  |             # only used to build 32-bit only extensions in a 4-way | 
					
						
							|  |  |  |             # universal build and loading 32-bit code into a 64-bit | 
					
						
							|  |  |  |             # process will fail. | 
					
						
							|  |  |  |             self.announce( | 
					
						
							|  |  |  |                 'WARNING: skipping import check for "%s"' % | 
					
						
							|  |  |  |                 ext.name) | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-05-22 16:46:15 +00:00
										 |  |  |         # Workaround for Cygwin: Cygwin currently has fork issues when many | 
					
						
							|  |  |  |         # modules have been imported | 
					
						
							|  |  |  |         if self.get_platform() == 'cygwin': | 
					
						
							|  |  |  |             self.announce('WARNING: skipping import check for Cygwin-based "%s"' | 
					
						
							|  |  |  |                 % ext.name) | 
					
						
							|  |  |  |             return | 
					
						
							| 
									
										
										
										
											2002-01-23 15:07:46 +00:00
										 |  |  |         ext_filename = os.path.join( | 
					
						
							|  |  |  |             self.build_lib, | 
					
						
							|  |  |  |             self.get_ext_filename(self.get_ext_fullname(ext.name))) | 
					
						
							| 
									
										
										
										
											2001-05-21 20:48:09 +00:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2002-01-23 15:07:46 +00:00
										 |  |  |             imp.load_dynamic(ext.name, ext_filename) | 
					
						
							| 
									
										
										
										
											2003-02-28 17:39:42 +00:00
										 |  |  |         except ImportError, why: | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             self.failed.append(ext.name) | 
					
						
							| 
									
										
										
										
											2003-02-28 17:39:42 +00:00
										 |  |  |             self.announce('*** WARNING: renaming "%s" since importing it' | 
					
						
							|  |  |  |                           ' failed: %s' % (ext.name, why), level=3) | 
					
						
							|  |  |  |             assert not self.inplace | 
					
						
							|  |  |  |             basename, tail = os.path.splitext(ext_filename) | 
					
						
							|  |  |  |             newname = basename + "_failed" + tail | 
					
						
							|  |  |  |             if os.path.exists(newname): | 
					
						
							|  |  |  |                 os.remove(newname) | 
					
						
							|  |  |  |             os.rename(ext_filename, newname) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             # XXX -- This relies on a Vile HACK in | 
					
						
							|  |  |  |             # distutils.command.build_ext.build_extension().  The | 
					
						
							|  |  |  |             # _built_objects attribute is stored there strictly for | 
					
						
							|  |  |  |             # use here. | 
					
						
							|  |  |  |             # If there is a failure, _built_objects may not be there, | 
					
						
							|  |  |  |             # so catch the AttributeError and move on. | 
					
						
							|  |  |  |             try: | 
					
						
							|  |  |  |                 for filename in self._built_objects: | 
					
						
							|  |  |  |                     os.remove(filename) | 
					
						
							|  |  |  |             except AttributeError: | 
					
						
							|  |  |  |                 self.announce('unable to remove files (ignored)') | 
					
						
							| 
									
										
										
										
											2003-02-28 17:21:39 +00:00
										 |  |  |         except: | 
					
						
							|  |  |  |             exc_type, why, tb = sys.exc_info() | 
					
						
							| 
									
										
										
										
											2003-02-28 17:39:42 +00:00
										 |  |  |             self.announce('*** WARNING: importing extension "%s" ' | 
					
						
							|  |  |  |                           'failed with %s: %s' % (ext.name, exc_type, why), | 
					
						
							|  |  |  |                           level=3) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             self.failed.append(ext.name) | 
					
						
							| 
									
										
										
										
											2001-12-06 22:59:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-17 02:51:28 +00:00
										 |  |  |     def get_platform(self): | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # Get value of sys.platform | 
					
						
							| 
									
										
										
										
											2003-06-17 02:51:28 +00:00
										 |  |  |         for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']: | 
					
						
							|  |  |  |             if sys.platform.startswith(platform): | 
					
						
							|  |  |  |                 return platform | 
					
						
							|  |  |  |         return sys.platform | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |     def detect_modules(self): | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # Ensure that /usr/local is always used | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') | 
					
						
							|  |  |  |         add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 
					
						
							| 
									
										
										
										
											2002-01-16 15:26:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-07 00:42:59 +00:00
										 |  |  |         # Add paths specified in the environment variables LDFLAGS and | 
					
						
							| 
									
										
										
										
											2004-12-31 08:11:21 +00:00
										 |  |  |         # CPPFLAGS for header and library files. | 
					
						
							| 
									
										
										
										
											2004-12-18 20:48:09 +00:00
										 |  |  |         # We must get the values from the Makefile and not the environment | 
					
						
							|  |  |  |         # directly since an inconsistently reproducible issue comes up where | 
					
						
							|  |  |  |         # the environment variable is not set even though the value were passed | 
					
						
							| 
									
										
										
										
											2004-12-31 08:11:21 +00:00
										 |  |  |         # into configure and stored in the Makefile (issue found on OS X 10.3). | 
					
						
							| 
									
										
										
										
											2004-12-07 00:42:59 +00:00
										 |  |  |         for env_var, arg_name, dir_list in ( | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs), | 
					
						
							|  |  |  |                 ('LDFLAGS', '-L', self.compiler.library_dirs), | 
					
						
							|  |  |  |                 ('CPPFLAGS', '-I', self.compiler.include_dirs)): | 
					
						
							| 
									
										
										
										
											2004-12-18 20:48:09 +00:00
										 |  |  |             env_val = sysconfig.get_config_var(env_var) | 
					
						
							| 
									
										
										
										
											2004-12-07 00:42:59 +00:00
										 |  |  |             if env_val: | 
					
						
							| 
									
										
										
										
											2004-12-31 08:11:21 +00:00
										 |  |  |                 # To prevent optparse from raising an exception about any | 
					
						
							| 
									
										
										
										
											2008-10-07 02:02:00 +00:00
										 |  |  |                 # options in env_val that it doesn't know about we strip out | 
					
						
							| 
									
										
										
										
											2004-12-31 08:11:21 +00:00
										 |  |  |                 # all double dashes and any dashes followed by a character | 
					
						
							|  |  |  |                 # that is not for the option we are dealing with. | 
					
						
							|  |  |  |                 # | 
					
						
							|  |  |  |                 # Please note that order of the regex is important!  We must | 
					
						
							|  |  |  |                 # strip out double-dashes first so that we don't end up with | 
					
						
							|  |  |  |                 # substituting "--Long" to "-Long" and thus lead to "ong" being | 
					
						
							|  |  |  |                 # used for a library directory. | 
					
						
							| 
									
										
										
										
											2007-08-24 11:47:37 +00:00
										 |  |  |                 env_val = re.sub(r'(^|\s+)-(-|(?!%s))' % arg_name[1], | 
					
						
							|  |  |  |                                  ' ', env_val) | 
					
						
							| 
									
										
										
										
											2004-12-07 03:25:18 +00:00
										 |  |  |                 parser = optparse.OptionParser() | 
					
						
							| 
									
										
										
										
											2004-12-31 08:11:21 +00:00
										 |  |  |                 # Make sure that allowing args interspersed with options is | 
					
						
							|  |  |  |                 # allowed | 
					
						
							|  |  |  |                 parser.allow_interspersed_args = True | 
					
						
							|  |  |  |                 parser.error = lambda msg: None | 
					
						
							| 
									
										
										
										
											2004-12-07 03:25:18 +00:00
										 |  |  |                 parser.add_option(arg_name, dest="dirs", action="append") | 
					
						
							|  |  |  |                 options = parser.parse_args(env_val.split())[0] | 
					
						
							| 
									
										
										
										
											2005-01-02 21:54:07 +00:00
										 |  |  |                 if options.dirs: | 
					
						
							| 
									
										
										
										
											2008-02-03 02:08:45 +00:00
										 |  |  |                     for directory in reversed(options.dirs): | 
					
						
							| 
									
										
										
										
											2005-01-02 21:54:07 +00:00
										 |  |  |                         add_dir_to_list(dir_list, directory) | 
					
						
							| 
									
										
										
										
											2003-01-01 20:07:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-08-02 13:55:50 +00:00
										 |  |  |         if os.path.normpath(sys.prefix) != '/usr': | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             add_dir_to_list(self.compiler.library_dirs, | 
					
						
							| 
									
										
										
										
											2002-08-02 13:55:50 +00:00
										 |  |  |                             sysconfig.get_config_var("LIBDIR")) | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             add_dir_to_list(self.compiler.include_dirs, | 
					
						
							| 
									
										
										
										
											2002-08-02 13:55:50 +00:00
										 |  |  |                             sysconfig.get_config_var("INCLUDEDIR")) | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-17 18:39:25 +00:00
										 |  |  |         try: | 
					
						
							|  |  |  |             have_unicode = unicode | 
					
						
							|  |  |  |         except NameError: | 
					
						
							|  |  |  |             have_unicode = 0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # lib_dirs and inc_dirs are used to search for files; | 
					
						
							|  |  |  |         # if a file is found in one of those directories, it can | 
					
						
							|  |  |  |         # be assumed that no additional -I,-L directives are needed. | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         lib_dirs = self.compiler.library_dirs + [ | 
					
						
							| 
									
										
										
										
											2004-11-13 11:13:35 +00:00
										 |  |  |             '/lib64', '/usr/lib64', | 
					
						
							|  |  |  |             '/lib', '/usr/lib', | 
					
						
							|  |  |  |             ] | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         inc_dirs = self.compiler.include_dirs + ['/usr/include'] | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         exts = [] | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         missing = [] | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-15 20:32:39 +00:00
										 |  |  |         config_h = sysconfig.get_config_h_filename() | 
					
						
							|  |  |  |         config_h_vars = sysconfig.parse_config_h(open(config_h)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         platform = self.get_platform() | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |         srcdir = sysconfig.get_config_var('srcdir') | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-11 06:22:31 +00:00
										 |  |  |         # Check for AtheOS which has libraries in non-standard locations | 
					
						
							|  |  |  |         if platform == 'atheos': | 
					
						
							|  |  |  |             lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] | 
					
						
							|  |  |  |             lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) | 
					
						
							|  |  |  |             inc_dirs += ['/system/include', '/atheos/autolnk/include'] | 
					
						
							|  |  |  |             inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-24 18:26:26 +00:00
										 |  |  |         # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) | 
					
						
							|  |  |  |         if platform in ['osf1', 'unixware7', 'openunix8']: | 
					
						
							| 
									
										
										
										
											2003-05-06 20:43:34 +00:00
										 |  |  |             lib_dirs += ['/usr/ccs/lib'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  |         if platform == 'darwin': | 
					
						
							|  |  |  |             # This should work on any unixy platform ;-) | 
					
						
							|  |  |  |             # If the user has bothered specifying additional -I and -L flags | 
					
						
							|  |  |  |             # in OPT and LDFLAGS we might as well use them here. | 
					
						
							|  |  |  |             #   NOTE: using shlex.split would technically be more correct, but | 
					
						
							|  |  |  |             # also gives a bootstrap problem. Let's hope nobody uses directories | 
					
						
							|  |  |  |             # with whitespace in the name to store libraries. | 
					
						
							|  |  |  |             cflags, ldflags = sysconfig.get_config_vars( | 
					
						
							|  |  |  |                     'CFLAGS', 'LDFLAGS') | 
					
						
							|  |  |  |             for item in cflags.split(): | 
					
						
							|  |  |  |                 if item.startswith('-I'): | 
					
						
							|  |  |  |                     inc_dirs.append(item[2:]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             for item in ldflags.split(): | 
					
						
							|  |  |  |                 if item.startswith('-L'): | 
					
						
							|  |  |  |                     lib_dirs.append(item[2:]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # Check for MacOS X, which doesn't need libm.a at all | 
					
						
							|  |  |  |         math_libs = ['m'] | 
					
						
							| 
									
										
										
										
											2002-06-26 15:44:30 +00:00
										 |  |  |         if platform in ['darwin', 'beos', 'mac']: | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |             math_libs = [] | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # XXX Omitted modules: gl, pure, dl, SGI-specific modules | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # | 
					
						
							|  |  |  |         # The following modules are all pretty straightforward, and compile | 
					
						
							|  |  |  |         # on pretty much any POSIXish platform. | 
					
						
							|  |  |  |         # | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Some modules that are normally always on: | 
					
						
							| 
									
										
										
										
											2001-02-01 05:26:54 +00:00
										 |  |  |         exts.append( Extension('_weakref', ['_weakref.c']) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # array objects | 
					
						
							|  |  |  |         exts.append( Extension('array', ['arraymodule.c']) ) | 
					
						
							|  |  |  |         # complex math library functions | 
					
						
							| 
									
										
										
										
											2009-12-21 15:22:00 +00:00
										 |  |  |         exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], | 
					
						
							|  |  |  |                                depends=['_math.h'], | 
					
						
							| 
									
										
										
										
											2001-01-23 22:21:11 +00:00
										 |  |  |                                libraries=math_libs) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # math library functions, e.g. sin() | 
					
						
							| 
									
										
										
										
											2009-12-16 20:13:40 +00:00
										 |  |  |         exts.append( Extension('math',  ['mathmodule.c', '_math.c'], | 
					
						
							| 
									
										
										
										
											2009-12-17 08:33:56 +00:00
										 |  |  |                                depends=['_math.h'], | 
					
						
							| 
									
										
										
										
											2001-01-23 22:21:11 +00:00
										 |  |  |                                libraries=math_libs) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # fast string operations implemented in C | 
					
						
							|  |  |  |         exts.append( Extension('strop', ['stropmodule.c']) ) | 
					
						
							|  |  |  |         # time operations and variables | 
					
						
							| 
									
										
										
										
											2001-01-23 22:21:11 +00:00
										 |  |  |         exts.append( Extension('time', ['timemodule.c'], | 
					
						
							|  |  |  |                                libraries=math_libs) ) | 
					
						
							| 
									
										
										
										
											2004-06-24 01:38:47 +00:00
										 |  |  |         exts.append( Extension('datetime', ['datetimemodule.c', 'timemodule.c'], | 
					
						
							| 
									
										
										
										
											2002-12-16 20:31:57 +00:00
										 |  |  |                                libraries=math_libs) ) | 
					
						
							| 
									
										
										
										
											2008-03-23 06:13:25 +00:00
										 |  |  |         # fast iterator tools implemented in C | 
					
						
							|  |  |  |         exts.append( Extension("itertools", ["itertoolsmodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2008-02-23 03:09:44 +00:00
										 |  |  |         # code that will be builtins in the future, but conflict with the | 
					
						
							|  |  |  |         #  current builtins | 
					
						
							|  |  |  |         exts.append( Extension('future_builtins', ['future_builtins.c']) ) | 
					
						
							| 
									
										
										
										
											2002-12-29 23:03:38 +00:00
										 |  |  |         # random number generator implemented in C | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |         exts.append( Extension("_random", ["_randommodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2004-01-29 06:37:52 +00:00
										 |  |  |         # high-performance collections | 
					
						
							| 
									
										
										
										
											2007-02-28 18:37:52 +00:00
										 |  |  |         exts.append( Extension("_collections", ["_collectionsmodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2004-01-05 10:13:35 +00:00
										 |  |  |         # bisect | 
					
						
							|  |  |  |         exts.append( Extension("_bisect", ["_bisectmodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2003-11-08 10:24:38 +00:00
										 |  |  |         # heapq | 
					
						
							| 
									
										
										
										
											2004-04-19 19:06:21 +00:00
										 |  |  |         exts.append( Extension("_heapq", ["_heapqmodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # operator.add() and similar goodies | 
					
						
							|  |  |  |         exts.append( Extension('operator', ['operator.c']) ) | 
					
						
							| 
									
										
										
										
											2009-06-12 20:14:08 +00:00
										 |  |  |         # Python 3.1 _io library | 
					
						
							|  |  |  |         exts.append( Extension("_io", | 
					
						
							|  |  |  |             ["_io/bufferedio.c", "_io/bytesio.c", "_io/fileio.c", | 
					
						
							|  |  |  |              "_io/iobase.c", "_io/_iomodule.c", "_io/stringio.c", "_io/textio.c"], | 
					
						
							|  |  |  |              depends=["_io/_iomodule.h"], include_dirs=["Modules/_io"])) | 
					
						
							| 
									
										
										
										
											2006-05-29 12:43:05 +00:00
										 |  |  |         # _functools | 
					
						
							|  |  |  |         exts.append( Extension("_functools", ["_functoolsmodule.c"]) ) | 
					
						
							| 
									
										
										
										
											2008-05-05 20:21:38 +00:00
										 |  |  |         # _json speedups | 
					
						
							|  |  |  |         exts.append( Extension("_json", ["_json.c"]) ) | 
					
						
							| 
									
										
										
										
											2001-02-02 12:12:44 +00:00
										 |  |  |         # Python C API test module | 
					
						
							| 
									
										
										
										
											2009-02-10 16:17:16 +00:00
										 |  |  |         exts.append( Extension('_testcapi', ['_testcapimodule.c'], | 
					
						
							|  |  |  |                                depends=['testcapi_long.h']) ) | 
					
						
							| 
									
										
										
										
											2006-02-08 12:53:56 +00:00
										 |  |  |         # profilers (_lsprof is for cProfile.py) | 
					
						
							|  |  |  |         exts.append( Extension('_hotshot', ['_hotshot.c']) ) | 
					
						
							|  |  |  |         exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # static Unicode character database | 
					
						
							| 
									
										
										
										
											2001-08-17 18:39:25 +00:00
										 |  |  |         if have_unicode: | 
					
						
							|  |  |  |             exts.append( Extension('unicodedata', ['unicodedata.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('unicodedata') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # access to ISO C locale support | 
					
						
							| 
									
										
										
										
											2003-06-14 21:03:05 +00:00
										 |  |  |         data = open('pyconfig.h').read() | 
					
						
							|  |  |  |         m = re.search(r"#s*define\s+WITH_LIBINTL\s+1\s*", data) | 
					
						
							|  |  |  |         if m is not None: | 
					
						
							| 
									
										
										
										
											2002-08-14 11:13:52 +00:00
										 |  |  |             locale_libs = ['intl'] | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             locale_libs = [] | 
					
						
							| 
									
										
										
										
											2004-07-15 19:56:25 +00:00
										 |  |  |         if platform == 'darwin': | 
					
						
							|  |  |  |             locale_extra_link_args = ['-framework', 'CoreFoundation'] | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             locale_extra_link_args = [] | 
					
						
							| 
									
										
										
										
											2004-07-18 05:56:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 19:56:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-08-14 11:13:52 +00:00
										 |  |  |         exts.append( Extension('_locale', ['_localemodule.c'], | 
					
						
							| 
									
										
										
										
											2004-07-15 19:56:25 +00:00
										 |  |  |                                libraries=locale_libs, | 
					
						
							|  |  |  |                                extra_link_args=locale_extra_link_args) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Modules with some UNIX dependencies -- on by default: | 
					
						
							|  |  |  |         # (If you have a really backward UNIX, select and socket may not be | 
					
						
							|  |  |  |         # supported...) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # fcntl(2) and ioctl(2) | 
					
						
							|  |  |  |         exts.append( Extension('fcntl', ['fcntlmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2002-06-27 22:06:49 +00:00
										 |  |  |         if platform not in ['mac']: | 
					
						
							| 
									
										
										
										
											2005-02-16 00:07:19 +00:00
										 |  |  |             # pwd(3) | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             exts.append( Extension('pwd', ['pwdmodule.c']) ) | 
					
						
							|  |  |  |             # grp(3) | 
					
						
							|  |  |  |             exts.append( Extension('grp', ['grpmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2005-01-23 09:27:24 +00:00
										 |  |  |             # spwd, shadow passwords | 
					
						
							| 
									
										
										
										
											2005-04-15 20:32:39 +00:00
										 |  |  |             if (config_h_vars.get('HAVE_GETSPNAM', False) or | 
					
						
							|  |  |  |                     config_h_vars.get('HAVE_GETSPENT', False)): | 
					
						
							| 
									
										
										
										
											2005-02-16 00:07:19 +00:00
										 |  |  |                 exts.append( Extension('spwd', ['spwdmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('spwd') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.extend(['pwd', 'grp', 'spwd']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # select(2); not on ancient System V | 
					
						
							|  |  |  |         exts.append( Extension('select', ['selectmodule.c']) ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Fred Drake's interface to the Python parser | 
					
						
							|  |  |  |         exts.append( Extension('parser', ['parsermodule.c']) ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-04 17:52:50 +00:00
										 |  |  |         # cStringIO and cPickle | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         exts.append( Extension('cStringIO', ['cStringIO.c']) ) | 
					
						
							|  |  |  |         exts.append( Extension('cPickle', ['cPickle.c']) ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Memory-mapped files (also works on Win32). | 
					
						
							| 
									
										
										
										
											2002-06-27 22:06:49 +00:00
										 |  |  |         if platform not in ['atheos', 'mac']: | 
					
						
							| 
									
										
										
										
											2002-06-11 06:22:31 +00:00
										 |  |  |             exts.append( Extension('mmap', ['mmapmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('mmap') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-08-31 13:37:25 +00:00
										 |  |  |         # Lance Ellinghaus's syslog module | 
					
						
							| 
									
										
										
										
											2002-06-27 22:06:49 +00:00
										 |  |  |         if platform not in ['mac']: | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             # syslog daemon interface | 
					
						
							|  |  |  |             exts.append( Extension('syslog', ['syslogmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('syslog') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # George Neville-Neil's timing module: | 
					
						
							| 
									
										
										
										
											2006-03-03 00:48:46 +00:00
										 |  |  |         # Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html | 
					
						
							|  |  |  |         # http://mail.python.org/pipermail/python-dev/2006-January/060023.html | 
					
						
							|  |  |  |         #exts.append( Extension('timing', ['timingmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # | 
					
						
							| 
									
										
										
										
											2001-01-18 20:39:34 +00:00
										 |  |  |         # Here ends the simple stuff.  From here on, modules need certain | 
					
						
							|  |  |  |         # libraries, are platform-specific, or present other surprises. | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Multimedia modules | 
					
						
							|  |  |  |         # These don't work for 64-bit platforms!!! | 
					
						
							|  |  |  |         # These represent audio samples or images as strings: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-19 16:55:07 +00:00
										 |  |  |         # Operations on audio samples | 
					
						
							| 
									
										
										
										
											2004-07-23 02:50:10 +00:00
										 |  |  |         # According to #993173, this one should actually work fine on | 
					
						
							| 
									
										
										
										
											2004-07-19 16:42:20 +00:00
										 |  |  |         # 64-bit platforms. | 
					
						
							|  |  |  |         exts.append( Extension('audioop', ['audioop.c']) ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # Disabled on 64-bit platforms | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         if sys.maxint != 9223372036854775807L: | 
					
						
							|  |  |  |             # Operations on images | 
					
						
							|  |  |  |             exts.append( Extension('imageop', ['imageop.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2007-05-20 07:09:50 +00:00
										 |  |  |             missing.extend(['imageop']) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # readline | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         do_readline = self.compiler.find_library_file(lib_dirs, 'readline') | 
					
						
							| 
									
										
										
										
											2009-09-20 14:18:15 +00:00
										 |  |  |         if platform == 'darwin': | 
					
						
							|  |  |  |             os_release = int(os.uname()[2].split('.')[0]) | 
					
						
							| 
									
										
										
										
											2010-03-08 07:06:47 +00:00
										 |  |  |             dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') | 
					
						
							|  |  |  |             if dep_target and dep_target.split('.') < ['10', '5']: | 
					
						
							|  |  |  |                 os_release = 8 | 
					
						
							| 
									
										
										
										
											2009-09-20 14:18:15 +00:00
										 |  |  |             if os_release < 9: | 
					
						
							|  |  |  |                 # MacOSX 10.4 has a broken readline. Don't try to build | 
					
						
							|  |  |  |                 # the readline module unless the user has installed a fixed | 
					
						
							|  |  |  |                 # readline package | 
					
						
							|  |  |  |                 if find_file('readline/rlconf.h', inc_dirs, []) is None: | 
					
						
							|  |  |  |                     do_readline = False | 
					
						
							| 
									
										
										
										
											2006-02-23 15:02:23 +00:00
										 |  |  |         if do_readline: | 
					
						
							| 
									
										
										
										
											2009-09-20 14:18:15 +00:00
										 |  |  |             if platform == 'darwin' and os_release < 9: | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  |                 # In every directory on the search path search for a dynamic | 
					
						
							|  |  |  |                 # library and then a static library, instead of first looking | 
					
						
							|  |  |  |                 # for dynamic libraries on the entiry path. | 
					
						
							|  |  |  |                 # This way a staticly linked custom readline gets picked up | 
					
						
							|  |  |  |                 # before the (broken) dynamic library in /usr/lib. | 
					
						
							|  |  |  |                 readline_extra_link_args = ('-Wl,-search_paths_first',) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 readline_extra_link_args = () | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-26 18:23:02 +00:00
										 |  |  |             readline_libs = ['readline'] | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             if self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                    'ncursesw'): | 
					
						
							| 
									
										
										
										
											2006-02-11 15:55:14 +00:00
										 |  |  |                 readline_libs.append('ncursesw') | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             elif self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                      'ncurses'): | 
					
						
							| 
									
										
										
										
											2001-08-16 20:30:18 +00:00
										 |  |  |                 readline_libs.append('ncurses') | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             elif self.compiler.find_library_file(lib_dirs, 'curses'): | 
					
						
							| 
									
										
										
										
											2003-03-31 15:53:49 +00:00
										 |  |  |                 readline_libs.append('curses') | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             elif self.compiler.find_library_file(lib_dirs + | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                      ['/usr/lib/termcap'], | 
					
						
							|  |  |  |                                                      'termcap'): | 
					
						
							| 
									
										
										
										
											2001-01-26 18:23:02 +00:00
										 |  |  |                 readline_libs.append('termcap') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             exts.append( Extension('readline', ['readline.c'], | 
					
						
							| 
									
										
										
										
											2001-01-26 18:03:24 +00:00
										 |  |  |                                    library_dirs=['/usr/lib/termcap'], | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  |                                    extra_link_args=readline_extra_link_args, | 
					
						
							| 
									
										
										
										
											2001-01-26 18:23:02 +00:00
										 |  |  |                                    libraries=readline_libs) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('readline') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-27 22:06:49 +00:00
										 |  |  |         if platform not in ['mac']: | 
					
						
							| 
									
										
										
										
											2003-10-24 18:26:26 +00:00
										 |  |  |             # crypt module. | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             if self.compiler.find_library_file(lib_dirs, 'crypt'): | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |                 libs = ['crypt'] | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 libs = [] | 
					
						
							|  |  |  |             exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('crypt') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-20 23:34:22 +00:00
										 |  |  |         # CSV files | 
					
						
							|  |  |  |         exts.append( Extension('_csv', ['_csv.c']) ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # socket(2) | 
					
						
							| 
									
										
										
										
											2002-06-13 14:41:32 +00:00
										 |  |  |         exts.append( Extension('_socket', ['socketmodule.c'], | 
					
						
							| 
									
										
										
										
											2002-06-13 17:38:11 +00:00
										 |  |  |                                depends = ['socketmodule.h']) ) | 
					
						
							| 
									
										
										
										
											2002-02-16 18:23:30 +00:00
										 |  |  |         # Detect SSL support for the socket module (via _ssl) | 
					
						
							| 
									
										
										
										
											2005-08-23 21:19:40 +00:00
										 |  |  |         search_for_ssl_incs_in = [ | 
					
						
							|  |  |  |                               '/usr/local/ssl/include', | 
					
						
							| 
									
										
										
										
											2001-01-19 16:58:21 +00:00
										 |  |  |                               '/usr/contrib/ssl/include/' | 
					
						
							|  |  |  |                              ] | 
					
						
							| 
									
										
										
										
											2005-08-23 21:19:40 +00:00
										 |  |  |         ssl_incs = find_file('openssl/ssl.h', inc_dirs, | 
					
						
							|  |  |  |                              search_for_ssl_incs_in | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |                              ) | 
					
						
							| 
									
										
										
										
											2003-05-09 09:05:19 +00:00
										 |  |  |         if ssl_incs is not None: | 
					
						
							|  |  |  |             krb5_h = find_file('krb5.h', inc_dirs, | 
					
						
							|  |  |  |                                ['/usr/kerberos/include']) | 
					
						
							|  |  |  |             if krb5_h: | 
					
						
							|  |  |  |                 ssl_incs += krb5_h | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, | 
					
						
							| 
									
										
										
										
											2001-01-19 16:58:21 +00:00
										 |  |  |                                      ['/usr/local/ssl/lib', | 
					
						
							|  |  |  |                                       '/usr/contrib/ssl/lib/' | 
					
						
							|  |  |  |                                      ] ) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         if (ssl_incs is not None and | 
					
						
							|  |  |  |             ssl_libs is not None): | 
					
						
							| 
									
										
										
										
											2002-02-16 18:23:30 +00:00
										 |  |  |             exts.append( Extension('_ssl', ['_ssl.c'], | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |                                    include_dirs = ssl_incs, | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |                                    library_dirs = ssl_libs, | 
					
						
							| 
									
										
										
										
											2002-06-13 14:41:32 +00:00
										 |  |  |                                    libraries = ['ssl', 'crypto'], | 
					
						
							| 
									
										
										
										
											2002-06-13 17:38:11 +00:00
										 |  |  |                                    depends = ['socketmodule.h']), ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_ssl') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-08-23 21:19:40 +00:00
										 |  |  |         # find out which version of OpenSSL we have | 
					
						
							|  |  |  |         openssl_ver = 0 | 
					
						
							|  |  |  |         openssl_ver_re = re.compile( | 
					
						
							|  |  |  |             '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) | 
					
						
							|  |  |  |         for ssl_inc_dir in inc_dirs + search_for_ssl_incs_in: | 
					
						
							|  |  |  |             name = os.path.join(ssl_inc_dir, 'openssl', 'opensslv.h') | 
					
						
							|  |  |  |             if os.path.isfile(name): | 
					
						
							|  |  |  |                 try: | 
					
						
							|  |  |  |                     incfile = open(name, 'r') | 
					
						
							|  |  |  |                     for line in incfile: | 
					
						
							|  |  |  |                         m = openssl_ver_re.match(line) | 
					
						
							|  |  |  |                         if m: | 
					
						
							|  |  |  |                             openssl_ver = eval(m.group(1)) | 
					
						
							|  |  |  |                             break | 
					
						
							|  |  |  |                 except IOError: | 
					
						
							|  |  |  |                     pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             # first version found is what we'll use (as the compiler should) | 
					
						
							|  |  |  |             if openssl_ver: | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #print 'openssl_ver = 0x%08x' % openssl_ver | 
					
						
							| 
									
										
										
										
											2010-01-02 22:25:29 +00:00
										 |  |  |         min_openssl_ver = 0x00907000 | 
					
						
							| 
									
										
										
										
											2010-01-03 00:43:02 +00:00
										 |  |  |         have_any_openssl = ssl_incs is not None and ssl_libs is not None | 
					
						
							|  |  |  |         have_usable_openssl = (have_any_openssl and | 
					
						
							| 
									
										
										
										
											2010-01-02 22:25:29 +00:00
										 |  |  |                                openssl_ver >= min_openssl_ver) | 
					
						
							| 
									
										
										
										
											2005-08-23 21:19:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-03 00:43:02 +00:00
										 |  |  |         if have_any_openssl: | 
					
						
							|  |  |  |             if have_usable_openssl: | 
					
						
							|  |  |  |                 # The _hashlib module wraps optimized implementations | 
					
						
							|  |  |  |                 # of hash functions from the OpenSSL library. | 
					
						
							|  |  |  |                 exts.append( Extension('_hashlib', ['_hashopenssl.c'], | 
					
						
							|  |  |  |                                        include_dirs = ssl_incs, | 
					
						
							|  |  |  |                                        library_dirs = ssl_libs, | 
					
						
							|  |  |  |                                        libraries = ['ssl', 'crypto']) ) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 print ("warning: openssl 0x%08x is too old for _hashlib" % | 
					
						
							|  |  |  |                        openssl_ver) | 
					
						
							|  |  |  |                 missing.append('_hashlib') | 
					
						
							| 
									
										
										
										
											2010-01-02 22:25:29 +00:00
										 |  |  |         if COMPILED_WITH_PYDEBUG or not have_usable_openssl: | 
					
						
							| 
									
										
										
										
											2005-08-21 18:45:59 +00:00
										 |  |  |             # The _sha module implements the SHA1 hash algorithm. | 
					
						
							|  |  |  |             exts.append( Extension('_sha', ['shamodule.c']) ) | 
					
						
							|  |  |  |             # The _md5 module implements the RSA Data Security, Inc. MD5 | 
					
						
							|  |  |  |             # Message-Digest Algorithm, described in RFC 1321.  The | 
					
						
							| 
									
										
										
										
											2006-04-03 16:27:50 +00:00
										 |  |  |             # necessary files md5.c and md5.h are included here. | 
					
						
							| 
									
										
										
										
											2006-06-05 23:38:06 +00:00
										 |  |  |             exts.append( Extension('_md5', | 
					
						
							|  |  |  |                             sources = ['md5module.c', 'md5.c'], | 
					
						
							|  |  |  |                             depends = ['md5.h']) ) | 
					
						
							| 
									
										
										
										
											2005-08-21 18:45:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-02 22:25:29 +00:00
										 |  |  |         min_sha2_openssl_ver = 0x00908000 | 
					
						
							|  |  |  |         if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver: | 
					
						
							| 
									
										
										
										
											2005-08-23 21:19:40 +00:00
										 |  |  |             # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash | 
					
						
							|  |  |  |             exts.append( Extension('_sha256', ['sha256module.c']) ) | 
					
						
							|  |  |  |             exts.append( Extension('_sha512', ['sha512module.c']) ) | 
					
						
							| 
									
										
										
										
											2005-08-21 18:45:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Modules that provide persistent dictionary-like semantics.  You will | 
					
						
							|  |  |  |         # probably want to arrange for at least one of them to be available on | 
					
						
							|  |  |  |         # your machine, though none are defined by default because of library | 
					
						
							|  |  |  |         # dependencies.  The Python module anydbm.py provides an | 
					
						
							|  |  |  |         # implementation independent wrapper for these; dumbdbm.py provides | 
					
						
							|  |  |  |         # similar functionality (but slower of course) implemented in Python. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-06 07:51:59 +00:00
										 |  |  |         # Sleepycat^WOracle Berkeley DB interface. | 
					
						
							|  |  |  |         #  http://www.oracle.com/database/berkeley-db/db/index.html | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  |         # | 
					
						
							| 
									
										
										
										
											2007-08-26 00:26:00 +00:00
										 |  |  |         # This requires the Sleepycat^WOracle DB code. The supported versions | 
					
						
							| 
									
										
										
										
											2007-10-09 18:26:02 +00:00
										 |  |  |         # are set below.  Visit the URL above to download | 
					
						
							| 
									
										
										
										
											2006-04-13 19:19:01 +00:00
										 |  |  |         # a release.  Most open source OSes come with one or more | 
					
						
							|  |  |  |         # versions of BerkeleyDB already installed. | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-15 12:46:18 +00:00
										 |  |  |         max_db_ver = (4, 8) | 
					
						
							| 
									
										
										
										
											2010-03-22 14:22:26 +00:00
										 |  |  |         min_db_ver = (4, 1) | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |         db_setup_debug = False   # verbose debug prints from this script? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |         def allow_db_ver(db_ver): | 
					
						
							|  |  |  |             """Returns a boolean if the given BerkeleyDB version is acceptable.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Args: | 
					
						
							|  |  |  |               db_ver: A tuple of the version to verify. | 
					
						
							|  |  |  |             """
 | 
					
						
							|  |  |  |             if not (min_db_ver <= db_ver <= max_db_ver): | 
					
						
							|  |  |  |                 return False | 
					
						
							|  |  |  |             # Use this function to filter out known bad configurations. | 
					
						
							|  |  |  |             if (4, 6) == db_ver[:2]: | 
					
						
							|  |  |  |                 # BerkeleyDB 4.6.x is not stable on many architectures. | 
					
						
							|  |  |  |                 arch = platform_machine() | 
					
						
							|  |  |  |                 if arch not in ('i386', 'i486', 'i586', 'i686', | 
					
						
							|  |  |  |                                 'x86_64', 'ia64'): | 
					
						
							|  |  |  |                     return False | 
					
						
							|  |  |  |             return True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def gen_db_minor_ver_nums(major): | 
					
						
							|  |  |  |             if major == 4: | 
					
						
							|  |  |  |                 for x in range(max_db_ver[1]+1): | 
					
						
							|  |  |  |                     if allow_db_ver((4, x)): | 
					
						
							|  |  |  |                         yield x | 
					
						
							|  |  |  |             elif major == 3: | 
					
						
							|  |  |  |                 for x in (3,): | 
					
						
							|  |  |  |                     if allow_db_ver((3, x)): | 
					
						
							|  |  |  |                         yield x | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 raise ValueError("unknown major BerkeleyDB version", major) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |         # construct a list of paths to look for the header file in on | 
					
						
							|  |  |  |         # top of the normal inc_dirs. | 
					
						
							|  |  |  |         db_inc_paths = [ | 
					
						
							|  |  |  |             '/usr/include/db4', | 
					
						
							|  |  |  |             '/usr/local/include/db4', | 
					
						
							|  |  |  |             '/opt/sfw/include/db4', | 
					
						
							|  |  |  |             '/usr/include/db3', | 
					
						
							|  |  |  |             '/usr/local/include/db3', | 
					
						
							|  |  |  |             '/opt/sfw/include/db3', | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |             # Fink defaults (http://fink.sourceforge.net/) | 
					
						
							|  |  |  |             '/sw/include/db4', | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             '/sw/include/db3', | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |         # 4.x minor number specific paths | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |         for x in gen_db_minor_ver_nums(4): | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             db_inc_paths.append('/usr/include/db4%d' % x) | 
					
						
							| 
									
										
										
										
											2005-10-20 05:28:29 +00:00
										 |  |  |             db_inc_paths.append('/usr/include/db4.%d' % x) | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x) | 
					
						
							|  |  |  |             db_inc_paths.append('/usr/local/include/db4%d' % x) | 
					
						
							|  |  |  |             db_inc_paths.append('/pkg/db-4.%d/include' % x) | 
					
						
							| 
									
										
										
										
											2006-01-24 09:46:48 +00:00
										 |  |  |             db_inc_paths.append('/opt/db-4.%d/include' % x) | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |             # MacPorts default (http://www.macports.org/) | 
					
						
							|  |  |  |             db_inc_paths.append('/opt/local/include/db4%d' % x) | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |         # 3.x minor number specific paths | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |         for x in gen_db_minor_ver_nums(3): | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             db_inc_paths.append('/usr/include/db3%d' % x) | 
					
						
							|  |  |  |             db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) | 
					
						
							|  |  |  |             db_inc_paths.append('/usr/local/include/db3%d' % x) | 
					
						
							|  |  |  |             db_inc_paths.append('/pkg/db-3.%d/include' % x) | 
					
						
							| 
									
										
										
										
											2006-01-24 09:46:48 +00:00
										 |  |  |             db_inc_paths.append('/opt/db-3.%d/include' % x) | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |         # Add some common subdirectories for Sleepycat DB to the list, | 
					
						
							|  |  |  |         # based on the standard include directories. This way DB3/4 gets | 
					
						
							|  |  |  |         # picked up when it is installed in a non-standard prefix and | 
					
						
							|  |  |  |         # the user has added that prefix into inc_dirs. | 
					
						
							|  |  |  |         std_variants = [] | 
					
						
							|  |  |  |         for dn in inc_dirs: | 
					
						
							|  |  |  |             std_variants.append(os.path.join(dn, 'db3')) | 
					
						
							|  |  |  |             std_variants.append(os.path.join(dn, 'db4')) | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |             for x in gen_db_minor_ver_nums(4): | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |                 std_variants.append(os.path.join(dn, "db4%d"%x)) | 
					
						
							|  |  |  |                 std_variants.append(os.path.join(dn, "db4.%d"%x)) | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |             for x in gen_db_minor_ver_nums(3): | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |                 std_variants.append(os.path.join(dn, "db3%d"%x)) | 
					
						
							|  |  |  |                 std_variants.append(os.path.join(dn, "db3.%d"%x)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-30 06:18:39 +00:00
										 |  |  |         db_inc_paths = std_variants + db_inc_paths | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |         db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |         db_ver_inc_map = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         class db_found(Exception): pass | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2002-12-06 10:25:02 +00:00
										 |  |  |             # See whether there is a Sleepycat header in the standard | 
					
						
							|  |  |  |             # search path. | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             for d in inc_dirs + db_inc_paths: | 
					
						
							| 
									
										
										
										
											2002-12-06 10:25:02 +00:00
										 |  |  |                 f = os.path.join(d, "db.h") | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                 if db_setup_debug: print "db: looking for db.h in", f | 
					
						
							| 
									
										
										
										
											2002-12-06 10:25:02 +00:00
										 |  |  |                 if os.path.exists(f): | 
					
						
							|  |  |  |                     f = open(f).read() | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                     m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f) | 
					
						
							| 
									
										
										
										
											2002-12-06 10:25:02 +00:00
										 |  |  |                     if m: | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                         db_major = int(m.group(1)) | 
					
						
							|  |  |  |                         m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f) | 
					
						
							|  |  |  |                         db_minor = int(m.group(1)) | 
					
						
							|  |  |  |                         db_ver = (db_major, db_minor) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-06 07:51:59 +00:00
										 |  |  |                         # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug | 
					
						
							|  |  |  |                         if db_ver == (4, 6): | 
					
						
							|  |  |  |                             m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f) | 
					
						
							|  |  |  |                             db_patch = int(m.group(1)) | 
					
						
							|  |  |  |                             if db_patch < 21: | 
					
						
							|  |  |  |                                 print "db.h:", db_ver, "patch", db_patch, | 
					
						
							|  |  |  |                                 print "being ignored (4.6.x must be >= 4.6.21)" | 
					
						
							|  |  |  |                                 continue | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-13 11:47:49 +00:00
										 |  |  |                         if ( (db_ver not in db_ver_inc_map) and | 
					
						
							| 
									
										
										
										
											2008-05-27 08:40:09 +00:00
										 |  |  |                             allow_db_ver(db_ver) ): | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                             # save the include directory with the db.h version | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |                             # (first occurrence only) | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                             db_ver_inc_map[db_ver] = d | 
					
						
							| 
									
										
										
										
											2006-10-27 18:13:46 +00:00
										 |  |  |                             if db_setup_debug: | 
					
						
							|  |  |  |                                 print "db.h: found", db_ver, "in", d | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                         else: | 
					
						
							|  |  |  |                             # we already found a header for this library version | 
					
						
							|  |  |  |                             if db_setup_debug: print "db.h: ignoring", d | 
					
						
							|  |  |  |                     else: | 
					
						
							|  |  |  |                         # ignore this header, it didn't contain a version number | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |                         if db_setup_debug: | 
					
						
							|  |  |  |                             print "db.h: no version number version in", d | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             db_found_vers = db_ver_inc_map.keys() | 
					
						
							|  |  |  |             db_found_vers.sort() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             while db_found_vers: | 
					
						
							|  |  |  |                 db_ver = db_found_vers.pop() | 
					
						
							|  |  |  |                 db_incdir = db_ver_inc_map[db_ver] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 # check lib directories parallel to the location of the header | 
					
						
							|  |  |  |                 db_dirs_to_check = [ | 
					
						
							| 
									
										
										
										
											2007-03-04 20:52:28 +00:00
										 |  |  |                     db_incdir.replace("include", 'lib64'), | 
					
						
							|  |  |  |                     db_incdir.replace("include", 'lib'), | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                 ] | 
					
						
							|  |  |  |                 db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 # Look for a version specific db-X.Y before an ambiguoius dbX | 
					
						
							|  |  |  |                 # XXX should we -ever- look for a dbX name?  Do any | 
					
						
							|  |  |  |                 # systems really not name their library by version and | 
					
						
							|  |  |  |                 # symlink to more general names? | 
					
						
							| 
									
										
										
										
											2005-03-09 22:21:08 +00:00
										 |  |  |                 for dblib in (('db-%d.%d' % db_ver), | 
					
						
							|  |  |  |                               ('db%d%d' % db_ver), | 
					
						
							|  |  |  |                               ('db%d' % db_ver[0])): | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                     dblib_file = self.compiler.find_library_file( | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |                                     db_dirs_to_check + lib_dirs, dblib ) | 
					
						
							|  |  |  |                     if dblib_file: | 
					
						
							|  |  |  |                         dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ] | 
					
						
							|  |  |  |                         raise db_found | 
					
						
							|  |  |  |                     else: | 
					
						
							|  |  |  |                         if db_setup_debug: print "db lib: ", dblib, "not found" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         except db_found: | 
					
						
							| 
									
										
										
										
											2008-05-29 21:23:33 +00:00
										 |  |  |             if db_setup_debug: | 
					
						
							|  |  |  |                 print "bsddb using BerkeleyDB lib:", db_ver, dblib | 
					
						
							|  |  |  |                 print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             db_incs = [db_incdir] | 
					
						
							| 
									
										
										
										
											2002-07-08 21:39:36 +00:00
										 |  |  |             dblibs = [dblib] | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             # We add the runtime_library_dirs argument because the | 
					
						
							|  |  |  |             # BerkeleyDB lib we're linking against often isn't in the | 
					
						
							|  |  |  |             # system dynamic library search path.  This is usually | 
					
						
							|  |  |  |             # correct and most trouble free, but may cause problems in | 
					
						
							|  |  |  |             # some unusual system configurations (e.g. the directory | 
					
						
							|  |  |  |             # is on an NFS server that goes away). | 
					
						
							| 
									
										
										
										
											2002-11-19 08:09:52 +00:00
										 |  |  |             exts.append(Extension('_bsddb', ['_bsddb.c'], | 
					
						
							| 
									
										
										
										
											2007-10-09 06:02:21 +00:00
										 |  |  |                                   depends = ['bsddb.h'], | 
					
						
							| 
									
										
										
										
											2002-12-06 10:25:02 +00:00
										 |  |  |                                   library_dirs=dblib_dir, | 
					
						
							|  |  |  |                                   runtime_library_dirs=dblib_dir, | 
					
						
							| 
									
										
										
										
											2002-11-19 08:09:52 +00:00
										 |  |  |                                   include_dirs=db_incs, | 
					
						
							|  |  |  |                                   libraries=dblibs)) | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2004-12-13 12:01:24 +00:00
										 |  |  |             if db_setup_debug: print "db: no appropriate library found" | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  |             db_incs = None | 
					
						
							|  |  |  |             dblibs = [] | 
					
						
							|  |  |  |             dblib_dir = None | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             missing.append('_bsddb') | 
					
						
							| 
									
										
										
										
											2002-06-14 20:30:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |         # The sqlite interface | 
					
						
							| 
									
										
										
										
											2006-10-27 18:13:46 +00:00
										 |  |  |         sqlite_setup_debug = False   # verbose debug prints from this script? | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |         # We hunt for #define SQLITE_VERSION "n.n.n" | 
					
						
							|  |  |  |         # We need to find >= sqlite version 3.0.8 | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |         sqlite_incdir = sqlite_libdir = None | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |         sqlite_inc_paths = [ '/usr/include', | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                              '/usr/include/sqlite', | 
					
						
							|  |  |  |                              '/usr/include/sqlite3', | 
					
						
							|  |  |  |                              '/usr/local/include', | 
					
						
							|  |  |  |                              '/usr/local/include/sqlite', | 
					
						
							|  |  |  |                              '/usr/local/include/sqlite3', | 
					
						
							|  |  |  |                            ] | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |         MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) | 
					
						
							|  |  |  |         MIN_SQLITE_VERSION = ".".join([str(x) | 
					
						
							|  |  |  |                                     for x in MIN_SQLITE_VERSION_NUMBER]) | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Scan the default include directories before the SQLite specific | 
					
						
							|  |  |  |         # ones. This allows one to override the copy of sqlite on OSX, | 
					
						
							|  |  |  |         # where /usr/include contains an old version of sqlite. | 
					
						
							|  |  |  |         for d in inc_dirs + sqlite_inc_paths: | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |             f = os.path.join(d, "sqlite3.h") | 
					
						
							|  |  |  |             if os.path.exists(f): | 
					
						
							| 
									
										
										
										
											2006-04-01 08:36:27 +00:00
										 |  |  |                 if sqlite_setup_debug: print "sqlite: found %s"%f | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |                 incf = open(f).read() | 
					
						
							|  |  |  |                 m = re.search( | 
					
						
							|  |  |  |                     r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf) | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                 if m: | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |                     sqlite_version = m.group(1) | 
					
						
							|  |  |  |                     sqlite_version_tuple = tuple([int(x) | 
					
						
							|  |  |  |                                         for x in sqlite_version.split(".")]) | 
					
						
							|  |  |  |                     if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                         # we win! | 
					
						
							| 
									
										
										
										
											2006-10-27 18:13:46 +00:00
										 |  |  |                         if sqlite_setup_debug: | 
					
						
							|  |  |  |                             print "%s/sqlite3.h: version %s"%(d, sqlite_version) | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                         sqlite_incdir = d | 
					
						
							|  |  |  |                         break | 
					
						
							|  |  |  |                     else: | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |                         if sqlite_setup_debug: | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                             print "%s: version %d is too old, need >= %s"%(d, | 
					
						
							|  |  |  |                                         sqlite_version, MIN_SQLITE_VERSION) | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |                 elif sqlite_setup_debug: | 
					
						
							|  |  |  |                     print "sqlite: %s had no SQLITE_VERSION"%(f,) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |         if sqlite_incdir: | 
					
						
							|  |  |  |             sqlite_dirs_to_check = [ | 
					
						
							|  |  |  |                 os.path.join(sqlite_incdir, '..', 'lib64'), | 
					
						
							|  |  |  |                 os.path.join(sqlite_incdir, '..', 'lib'), | 
					
						
							|  |  |  |                 os.path.join(sqlite_incdir, '..', '..', 'lib64'), | 
					
						
							|  |  |  |                 os.path.join(sqlite_incdir, '..', '..', 'lib'), | 
					
						
							|  |  |  |             ] | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             sqlite_libfile = self.compiler.find_library_file( | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                                 sqlite_dirs_to_check + lib_dirs, 'sqlite3') | 
					
						
							| 
									
										
										
										
											2008-10-03 17:34:49 +00:00
										 |  |  |             if sqlite_libfile: | 
					
						
							|  |  |  |                 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if sqlite_incdir and sqlite_libdir: | 
					
						
							| 
									
										
										
										
											2006-04-23 15:24:26 +00:00
										 |  |  |             sqlite_srcs = ['_sqlite/cache.c', | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                 '_sqlite/connection.c', | 
					
						
							|  |  |  |                 '_sqlite/cursor.c', | 
					
						
							|  |  |  |                 '_sqlite/microprotocols.c', | 
					
						
							|  |  |  |                 '_sqlite/module.c', | 
					
						
							|  |  |  |                 '_sqlite/prepare_protocol.c', | 
					
						
							|  |  |  |                 '_sqlite/row.c', | 
					
						
							|  |  |  |                 '_sqlite/statement.c', | 
					
						
							|  |  |  |                 '_sqlite/util.c', ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             sqlite_defines = [] | 
					
						
							|  |  |  |             if sys.platform != "win32": | 
					
						
							| 
									
										
										
										
											2006-04-05 18:25:33 +00:00
										 |  |  |                 sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |             else: | 
					
						
							| 
									
										
										
										
											2006-04-05 18:25:33 +00:00
										 |  |  |                 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-05 09:12:37 +00:00
										 |  |  |             # Comment this out if you want the sqlite3 module to be able to load extensions. | 
					
						
							|  |  |  |             sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if sys.platform == 'darwin': | 
					
						
							|  |  |  |                 # In every directory on the search path search for a dynamic | 
					
						
							|  |  |  |                 # library and then a static library, instead of first looking | 
					
						
							|  |  |  |                 # for dynamic libraries on the entiry path. | 
					
						
							|  |  |  |                 # This way a staticly linked custom sqlite gets picked up | 
					
						
							|  |  |  |                 # before the dynamic library in /usr/lib. | 
					
						
							|  |  |  |                 sqlite_extra_link_args = ('-Wl,-search_paths_first',) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 sqlite_extra_link_args = () | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |             exts.append(Extension('_sqlite3', sqlite_srcs, | 
					
						
							|  |  |  |                                   define_macros=sqlite_defines, | 
					
						
							| 
									
										
										
										
											2006-04-03 02:20:49 +00:00
										 |  |  |                                   include_dirs=["Modules/_sqlite", | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                                                 sqlite_incdir], | 
					
						
							|  |  |  |                                   library_dirs=sqlite_libdir, | 
					
						
							|  |  |  |                                   runtime_library_dirs=sqlite_libdir, | 
					
						
							| 
									
										
										
										
											2006-05-26 11:38:39 +00:00
										 |  |  |                                   extra_link_args=sqlite_extra_link_args, | 
					
						
							| 
									
										
										
										
											2006-04-01 00:57:31 +00:00
										 |  |  |                                   libraries=["sqlite3",])) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_sqlite3') | 
					
						
							| 
									
										
										
										
											2003-05-06 20:43:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Look for Berkeley db 1.85.   Note that it is built as a different | 
					
						
							|  |  |  |         # module name so it can be included even when later versions are | 
					
						
							|  |  |  |         # available.  A very restrictive search is performed to avoid | 
					
						
							|  |  |  |         # accidentally building this module with a later version of the | 
					
						
							|  |  |  |         # underlying db library.  May BSD-ish Unixes incorporate db 1.85 | 
					
						
							|  |  |  |         # symbols into libc and place the include file in /usr/include. | 
					
						
							| 
									
										
										
										
											2007-08-26 00:26:00 +00:00
										 |  |  |         # | 
					
						
							|  |  |  |         # If the better bsddb library can be built (db_incs is defined) | 
					
						
							|  |  |  |         # we do not build this one.  Otherwise this build will pick up | 
					
						
							|  |  |  |         # the more recent berkeleydb's db.h file first in the include path | 
					
						
							|  |  |  |         # when attempting to compile and it will fail. | 
					
						
							| 
									
										
										
										
											2003-05-06 20:43:34 +00:00
										 |  |  |         f = "/usr/include/db.h" | 
					
						
							| 
									
										
										
										
											2007-08-26 00:26:00 +00:00
										 |  |  |         if os.path.exists(f) and not db_incs: | 
					
						
							| 
									
										
										
										
											2003-05-06 20:43:34 +00:00
										 |  |  |             data = open(f).read() | 
					
						
							|  |  |  |             m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data) | 
					
						
							|  |  |  |             if m is not None: | 
					
						
							|  |  |  |                 # bingo - old version used hash file format version 2 | 
					
						
							|  |  |  |                 ### XXX this should be fixed to not be platform-dependent | 
					
						
							|  |  |  |                 ### but I don't have direct access to an osf1 platform and | 
					
						
							|  |  |  |                 ### seemed to be muffing the search somehow | 
					
						
							|  |  |  |                 libraries = platform == "osf1" and ['db'] or None | 
					
						
							|  |  |  |                 if libraries is not None: | 
					
						
							|  |  |  |                     exts.append(Extension('bsddb185', ['bsddbmodule.c'], | 
					
						
							|  |  |  |                                           libraries=libraries)) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     exts.append(Extension('bsddb185', ['bsddbmodule.c'])) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('bsddb185') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.append('bsddb185') | 
					
						
							| 
									
										
										
										
											2003-05-06 20:43:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-01 15:21:13 +00:00
										 |  |  |         dbm_order = ['gdbm'] | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # The standard Unix dbm module: | 
					
						
							| 
									
										
										
										
											2002-07-08 21:39:36 +00:00
										 |  |  |         if platform not in ['cygwin']: | 
					
						
							| 
									
										
										
										
											2009-04-29 19:52:49 +00:00
										 |  |  |             config_args = [arg.strip("'") | 
					
						
							|  |  |  |                            for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] | 
					
						
							| 
									
										
										
										
											2010-01-01 15:21:13 +00:00
										 |  |  |             dbm_args = [arg for arg in config_args | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |                         if arg.startswith('--with-dbmliborder=')] | 
					
						
							|  |  |  |             if dbm_args: | 
					
						
							| 
									
										
										
										
											2010-01-01 15:21:13 +00:00
										 |  |  |                 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |             else: | 
					
						
							| 
									
										
										
										
											2009-04-29 19:52:49 +00:00
										 |  |  |                 dbm_order = "ndbm:gdbm:bdb".split(":") | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |             dbmext = None | 
					
						
							|  |  |  |             for cand in dbm_order: | 
					
						
							|  |  |  |                 if cand == "ndbm": | 
					
						
							|  |  |  |                     if find_file("ndbm.h", inc_dirs, []) is not None: | 
					
						
							|  |  |  |                         # Some systems have -lndbm, others don't | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                         if self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                                'ndbm'): | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |                             ndbm_libs = ['ndbm'] | 
					
						
							|  |  |  |                         else: | 
					
						
							|  |  |  |                             ndbm_libs = [] | 
					
						
							|  |  |  |                         print "building dbm using ndbm" | 
					
						
							|  |  |  |                         dbmext = Extension('dbm', ['dbmmodule.c'], | 
					
						
							|  |  |  |                                            define_macros=[ | 
					
						
							|  |  |  |                                                ('HAVE_NDBM_H',None), | 
					
						
							|  |  |  |                                                ], | 
					
						
							|  |  |  |                                            libraries=ndbm_libs) | 
					
						
							|  |  |  |                         break | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 elif cand == "gdbm": | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                     if self.compiler.find_library_file(lib_dirs, 'gdbm'): | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |                         gdbm_libs = ['gdbm'] | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                         if self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                                'gdbm_compat'): | 
					
						
							| 
									
										
										
										
											2009-04-29 17:18:19 +00:00
										 |  |  |                             gdbm_libs.append('gdbm_compat') | 
					
						
							|  |  |  |                         if find_file("gdbm/ndbm.h", inc_dirs, []) is not None: | 
					
						
							|  |  |  |                             print "building dbm using gdbm" | 
					
						
							|  |  |  |                             dbmext = Extension( | 
					
						
							|  |  |  |                                 'dbm', ['dbmmodule.c'], | 
					
						
							|  |  |  |                                 define_macros=[ | 
					
						
							|  |  |  |                                     ('HAVE_GDBM_NDBM_H', None), | 
					
						
							|  |  |  |                                     ], | 
					
						
							|  |  |  |                                 libraries = gdbm_libs) | 
					
						
							|  |  |  |                             break | 
					
						
							|  |  |  |                         if find_file("gdbm-ndbm.h", inc_dirs, []) is not None: | 
					
						
							|  |  |  |                             print "building dbm using gdbm" | 
					
						
							|  |  |  |                             dbmext = Extension( | 
					
						
							|  |  |  |                                 'dbm', ['dbmmodule.c'], | 
					
						
							|  |  |  |                                 define_macros=[ | 
					
						
							|  |  |  |                                     ('HAVE_GDBM_DASH_NDBM_H', None), | 
					
						
							|  |  |  |                                     ], | 
					
						
							|  |  |  |                                 libraries = gdbm_libs) | 
					
						
							|  |  |  |                             break | 
					
						
							|  |  |  |                 elif cand == "bdb": | 
					
						
							|  |  |  |                     if db_incs is not None: | 
					
						
							|  |  |  |                         print "building dbm using bdb" | 
					
						
							|  |  |  |                         dbmext = Extension('dbm', ['dbmmodule.c'], | 
					
						
							|  |  |  |                                            library_dirs=dblib_dir, | 
					
						
							|  |  |  |                                            runtime_library_dirs=dblib_dir, | 
					
						
							|  |  |  |                                            include_dirs=db_incs, | 
					
						
							|  |  |  |                                            define_macros=[ | 
					
						
							|  |  |  |                                                ('HAVE_BERKDB_H', None), | 
					
						
							|  |  |  |                                                ('DB_DBM_HSEARCH', None), | 
					
						
							|  |  |  |                                                ], | 
					
						
							|  |  |  |                                            libraries=dblibs) | 
					
						
							|  |  |  |                         break | 
					
						
							|  |  |  |             if dbmext is not None: | 
					
						
							|  |  |  |                 exts.append(dbmext) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('dbm') | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm: | 
					
						
							| 
									
										
										
										
											2010-01-01 15:21:13 +00:00
										 |  |  |         if ('gdbm' in dbm_order and | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             self.compiler.find_library_file(lib_dirs, 'gdbm')): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             exts.append( Extension('gdbm', ['gdbmmodule.c'], | 
					
						
							|  |  |  |                                    libraries = ['gdbm'] ) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('gdbm') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Unix-only modules | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  |         if platform not in ['mac', 'win32']: | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             # Steen Lumholt's termios module | 
					
						
							|  |  |  |             exts.append( Extension('termios', ['termios.c']) ) | 
					
						
							|  |  |  |             # Jeremy Hylton's rlimit interface | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             if platform not in ['atheos']: | 
					
						
							| 
									
										
										
										
											2002-06-11 06:22:31 +00:00
										 |  |  |                 exts.append( Extension('resource', ['resource.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('resource') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-21 02:38:24 +00:00
										 |  |  |             # Sun yellow pages. Some systems have the functions in libc. | 
					
						
							| 
									
										
										
										
											2009-12-30 03:02:34 +00:00
										 |  |  |             if (platform not in ['cygwin', 'atheos', 'qnx6'] and | 
					
						
							|  |  |  |                 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                 if (self.compiler.find_library_file(lib_dirs, 'nsl')): | 
					
						
							| 
									
										
										
										
											2001-02-27 20:54:23 +00:00
										 |  |  |                     libs = ['nsl'] | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     libs = [] | 
					
						
							|  |  |  |                 exts.append( Extension('nis', ['nismodule.c'], | 
					
						
							|  |  |  |                                        libraries = libs) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('nis') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.extend(['nis', 'resource', 'termios']) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-02-07 12:50:19 +00:00
										 |  |  |         # Curses support, requiring the System V version of curses, often | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # provided by the ncurses library. | 
					
						
							| 
									
										
										
										
											2006-08-06 22:07:04 +00:00
										 |  |  |         panel_library = 'panel' | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         if (self.compiler.find_library_file(lib_dirs, 'ncursesw')): | 
					
						
							| 
									
										
										
										
											2006-02-11 15:55:14 +00:00
										 |  |  |             curses_libs = ['ncursesw'] | 
					
						
							| 
									
										
										
										
											2006-08-06 22:07:04 +00:00
										 |  |  |             # Bug 1464056: If _curses.so links with ncursesw, | 
					
						
							|  |  |  |             # _curses_panel.so must link with panelw. | 
					
						
							|  |  |  |             panel_library = 'panelw' | 
					
						
							| 
									
										
										
										
											2006-02-11 15:55:14 +00:00
										 |  |  |             exts.append( Extension('_curses', ['_cursesmodule.c'], | 
					
						
							|  |  |  |                                    libraries = curses_libs) ) | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         elif (self.compiler.find_library_file(lib_dirs, 'ncurses')): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             curses_libs = ['ncurses'] | 
					
						
							|  |  |  |             exts.append( Extension('_curses', ['_cursesmodule.c'], | 
					
						
							|  |  |  |                                    libraries = curses_libs) ) | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         elif (self.compiler.find_library_file(lib_dirs, 'curses') | 
					
						
							| 
									
										
										
										
											2001-12-06 22:24:47 +00:00
										 |  |  |               and platform != 'darwin'): | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  |                 # OSX has an old Berkeley curses, not good enough for | 
					
						
							|  |  |  |                 # the _curses module. | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             if (self.compiler.find_library_file(lib_dirs, 'terminfo')): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |                 curses_libs = ['curses', 'terminfo'] | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             elif (self.compiler.find_library_file(lib_dirs, 'termcap')): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |                 curses_libs = ['curses', 'termcap'] | 
					
						
							| 
									
										
										
										
											2003-03-31 15:53:49 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 curses_libs = ['curses'] | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             exts.append( Extension('_curses', ['_cursesmodule.c'], | 
					
						
							|  |  |  |                                    libraries = curses_libs) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_curses') | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # If the curses module is enabled, check for the panel module | 
					
						
							| 
									
										
										
										
											2001-12-06 15:57:16 +00:00
										 |  |  |         if (module_enabled(exts, '_curses') and | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             self.compiler.find_library_file(lib_dirs, panel_library)): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             exts.append( Extension('_curses_panel', ['_curses_panel.c'], | 
					
						
							| 
									
										
										
										
											2006-08-06 22:07:04 +00:00
										 |  |  |                                    libraries = [panel_library] + curses_libs) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_curses_panel') | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-08-13 20:09:26 +00:00
										 |  |  |         # Andrew Kuchling's zlib module.  Note that some versions of zlib | 
					
						
							|  |  |  |         # 1.1.3 have security problems.  See CERT Advisory CA-2002-07: | 
					
						
							|  |  |  |         # http://www.cert.org/advisories/CA-2002-07.html | 
					
						
							|  |  |  |         # | 
					
						
							|  |  |  |         # zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to | 
					
						
							|  |  |  |         # patch its zlib 1.1.3 package instead of upgrading to 1.1.4.  For | 
					
						
							|  |  |  |         # now, we still accept 1.1.3, because we think it's difficult to | 
					
						
							|  |  |  |         # exploit this in Python, and we'd rather make it RedHat's problem | 
					
						
							|  |  |  |         # than our problem <wink>. | 
					
						
							|  |  |  |         # | 
					
						
							|  |  |  |         # You can upgrade zlib to version 1.1.4 yourself by going to | 
					
						
							|  |  |  |         # http://www.gzip.org/zlib/ | 
					
						
							| 
									
										
										
										
											2001-04-15 15:16:12 +00:00
										 |  |  |         zlib_inc = find_file('zlib.h', [], inc_dirs) | 
					
						
							| 
									
										
										
										
											2008-03-24 00:08:01 +00:00
										 |  |  |         have_zlib = False | 
					
						
							| 
									
										
										
										
											2001-04-15 15:16:12 +00:00
										 |  |  |         if zlib_inc is not None: | 
					
						
							|  |  |  |             zlib_h = zlib_inc[0] + '/zlib.h' | 
					
						
							|  |  |  |             version = '"0.0.0"' | 
					
						
							| 
									
										
										
										
											2002-08-13 20:09:26 +00:00
										 |  |  |             version_req = '"1.1.3"' | 
					
						
							| 
									
										
										
										
											2001-04-15 15:16:12 +00:00
										 |  |  |             fp = open(zlib_h) | 
					
						
							|  |  |  |             while 1: | 
					
						
							|  |  |  |                 line = fp.readline() | 
					
						
							|  |  |  |                 if not line: | 
					
						
							|  |  |  |                     break | 
					
						
							| 
									
										
										
										
											2002-08-06 17:28:30 +00:00
										 |  |  |                 if line.startswith('#define ZLIB_VERSION'): | 
					
						
							| 
									
										
										
										
											2001-04-15 15:16:12 +00:00
										 |  |  |                     version = line.split()[2] | 
					
						
							|  |  |  |                     break | 
					
						
							|  |  |  |             if version >= version_req: | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                 if (self.compiler.find_library_file(lib_dirs, 'z')): | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |                     if sys.platform == "darwin": | 
					
						
							|  |  |  |                         zlib_extra_link_args = ('-Wl,-search_paths_first',) | 
					
						
							|  |  |  |                     else: | 
					
						
							|  |  |  |                         zlib_extra_link_args = () | 
					
						
							| 
									
										
										
										
											2001-04-15 15:16:12 +00:00
										 |  |  |                     exts.append( Extension('zlib', ['zlibmodule.c'], | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |                                            libraries = ['z'], | 
					
						
							|  |  |  |                                            extra_link_args = zlib_extra_link_args)) | 
					
						
							| 
									
										
										
										
											2008-03-24 00:08:01 +00:00
										 |  |  |                     have_zlib = True | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |                 else: | 
					
						
							|  |  |  |                     missing.append('zlib') | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('zlib') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.append('zlib') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-24 00:08:01 +00:00
										 |  |  |         # Helper module for various ascii-encoders.  Uses zlib for an optimized | 
					
						
							|  |  |  |         # crc32 if we have it.  Otherwise binascii uses its own. | 
					
						
							|  |  |  |         if have_zlib: | 
					
						
							|  |  |  |             extra_compile_args = ['-DUSE_ZLIB_CRC32'] | 
					
						
							|  |  |  |             libraries = ['z'] | 
					
						
							|  |  |  |             extra_link_args = zlib_extra_link_args | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             extra_compile_args = [] | 
					
						
							|  |  |  |             libraries = [] | 
					
						
							|  |  |  |             extra_link_args = [] | 
					
						
							|  |  |  |         exts.append( Extension('binascii', ['binascii.c'], | 
					
						
							|  |  |  |                                extra_compile_args = extra_compile_args, | 
					
						
							|  |  |  |                                libraries = libraries, | 
					
						
							|  |  |  |                                extra_link_args = extra_link_args) ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-05 16:50:05 +00:00
										 |  |  |         # Gustavo Niemeyer's bz2 module. | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         if (self.compiler.find_library_file(lib_dirs, 'bz2')): | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |             if sys.platform == "darwin": | 
					
						
							|  |  |  |                 bz2_extra_link_args = ('-Wl,-search_paths_first',) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 bz2_extra_link_args = () | 
					
						
							| 
									
										
										
										
											2002-11-05 16:50:05 +00:00
										 |  |  |             exts.append( Extension('bz2', ['bz2module.c'], | 
					
						
							| 
									
										
										
										
											2006-06-27 12:53:52 +00:00
										 |  |  |                                    libraries = ['bz2'], | 
					
						
							|  |  |  |                                    extra_link_args = bz2_extra_link_args) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('bz2') | 
					
						
							| 
									
										
										
										
											2002-11-05 16:50:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Interface to the Expat XML parser | 
					
						
							|  |  |  |         # | 
					
						
							| 
									
										
										
										
											2009-12-31 16:28:24 +00:00
										 |  |  |         # Expat was written by James Clark and is now maintained by a group of | 
					
						
							|  |  |  |         # developers on SourceForge; see www.libexpat.org for more information. | 
					
						
							|  |  |  |         # The pyexpat module was written by Paul Prescod after a prototype by | 
					
						
							|  |  |  |         # Jack Jansen.  The Expat source is included in Modules/expat/.  Usage | 
					
						
							|  |  |  |         # of a system shared libexpat.so is possible with --with-system-expat | 
					
						
							|  |  |  |         # cofigure option. | 
					
						
							| 
									
										
										
										
											2002-06-17 17:55:30 +00:00
										 |  |  |         # | 
					
						
							|  |  |  |         # More information on Expat can be found at www.libexpat.org. | 
					
						
							|  |  |  |         # | 
					
						
							| 
									
										
										
										
											2009-12-31 03:17:18 +00:00
										 |  |  |         if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): | 
					
						
							|  |  |  |             expat_inc = [] | 
					
						
							|  |  |  |             define_macros = [] | 
					
						
							|  |  |  |             expat_lib = ['expat'] | 
					
						
							|  |  |  |             expat_sources = [] | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')] | 
					
						
							|  |  |  |             define_macros = [ | 
					
						
							|  |  |  |                 ('HAVE_EXPAT_CONFIG_H', '1'), | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |             expat_lib = [] | 
					
						
							|  |  |  |             expat_sources = ['expat/xmlparse.c', | 
					
						
							|  |  |  |                              'expat/xmlrole.c', | 
					
						
							|  |  |  |                              'expat/xmltok.c'] | 
					
						
							| 
									
										
										
										
											2006-04-29 11:31:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-21 15:41:15 +00:00
										 |  |  |         exts.append(Extension('pyexpat', | 
					
						
							|  |  |  |                               define_macros = define_macros, | 
					
						
							| 
									
										
										
										
											2009-12-31 03:17:18 +00:00
										 |  |  |                               include_dirs = expat_inc, | 
					
						
							|  |  |  |                               libraries = expat_lib, | 
					
						
							|  |  |  |                               sources = ['pyexpat.c'] + expat_sources | 
					
						
							| 
									
										
										
										
											2003-10-21 15:41:15 +00:00
										 |  |  |                               )) | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-14 18:46:16 +00:00
										 |  |  |         # Fredrik Lundh's cElementTree module.  Note that this also | 
					
						
							|  |  |  |         # uses expat (via the CAPI hook in pyexpat). | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-27 08:43:11 +00:00
										 |  |  |         if os.path.isfile(os.path.join(srcdir, 'Modules', '_elementtree.c')): | 
					
						
							| 
									
										
										
										
											2005-12-14 18:46:16 +00:00
										 |  |  |             define_macros.append(('USE_PYEXPAT_CAPI', None)) | 
					
						
							|  |  |  |             exts.append(Extension('_elementtree', | 
					
						
							|  |  |  |                                   define_macros = define_macros, | 
					
						
							| 
									
										
										
										
											2009-12-31 03:17:18 +00:00
										 |  |  |                                   include_dirs = expat_inc, | 
					
						
							|  |  |  |                                   libraries = expat_lib, | 
					
						
							| 
									
										
										
										
											2005-12-14 18:46:16 +00:00
										 |  |  |                                   sources = ['_elementtree.c'], | 
					
						
							|  |  |  |                                   )) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_elementtree') | 
					
						
							| 
									
										
										
										
											2005-12-14 18:46:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-17 14:29:29 +00:00
										 |  |  |         # Hye-Shik Chang's CJKCodecs modules. | 
					
						
							| 
									
										
										
										
											2005-03-08 15:03:08 +00:00
										 |  |  |         if have_unicode: | 
					
						
							|  |  |  |             exts.append(Extension('_multibytecodec', | 
					
						
							|  |  |  |                                   ['cjkcodecs/multibytecodec.c'])) | 
					
						
							|  |  |  |             for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |                 exts.append(Extension('_codecs_%s' % loc, | 
					
						
							| 
									
										
										
										
											2005-03-08 15:03:08 +00:00
										 |  |  |                                       ['cjkcodecs/_codecs_%s.c' % loc])) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_multibytecodec') | 
					
						
							|  |  |  |             for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): | 
					
						
							|  |  |  |                 missing.append('_codecs_%s' % loc) | 
					
						
							| 
									
										
										
										
											2004-01-17 14:29:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  |         # Dynamic loading module | 
					
						
							| 
									
										
										
										
											2002-09-12 14:41:20 +00:00
										 |  |  |         if sys.maxint == 0x7fffffff: | 
					
						
							|  |  |  |             # This requires sizeof(int) == sizeof(long) == sizeof(char*) | 
					
						
							|  |  |  |             dl_inc = find_file('dlfcn.h', [], inc_dirs) | 
					
						
							| 
									
										
										
										
											2006-04-09 15:07:40 +00:00
										 |  |  |             if (dl_inc is not None) and (platform not in ['atheos']): | 
					
						
							| 
									
										
										
										
											2002-09-12 14:41:20 +00:00
										 |  |  |                 exts.append( Extension('dl', ['dlmodule.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |             else: | 
					
						
							|  |  |  |                 missing.append('dl') | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.append('dl') | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |         # Thomas Heller's _ctypes module | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |         self.detect_ctypes(inc_dirs, lib_dirs) | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |         # Richard Oudkerk's multiprocessing module | 
					
						
							|  |  |  |         if platform == 'win32':             # Windows | 
					
						
							|  |  |  |             macros = dict() | 
					
						
							|  |  |  |             libraries = ['ws2_32'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         elif platform == 'darwin':          # Mac OSX | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |             libraries = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         elif platform == 'cygwin':          # Cygwin | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |             libraries = [] | 
					
						
							| 
									
										
										
										
											2008-06-28 01:04:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-04 20:40:09 +00:00
										 |  |  |         elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): | 
					
						
							| 
									
										
										
										
											2008-06-28 01:04:31 +00:00
										 |  |  |             # FreeBSD's P1003.1b semaphore support is very experimental | 
					
						
							|  |  |  |             # and has many known problems. (as of June 2008) | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2008-06-28 01:04:31 +00:00
										 |  |  |             libraries = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-30 00:15:45 +00:00
										 |  |  |         elif platform.startswith('openbsd'): | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2008-09-30 00:15:45 +00:00
										 |  |  |             libraries = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-31 18:12:35 +00:00
										 |  |  |         elif platform.startswith('netbsd'): | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2009-03-31 18:12:35 +00:00
										 |  |  |             libraries = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |         else:                                   # Linux and other unices | 
					
						
							| 
									
										
										
										
											2009-04-02 00:03:28 +00:00
										 |  |  |             macros = dict() | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |             libraries = ['rt'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if platform == 'win32': | 
					
						
							|  |  |  |             multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', | 
					
						
							|  |  |  |                                      '_multiprocessing/semaphore.c', | 
					
						
							|  |  |  |                                      '_multiprocessing/pipe_connection.c', | 
					
						
							|  |  |  |                                      '_multiprocessing/socket_connection.c', | 
					
						
							|  |  |  |                                      '_multiprocessing/win32_functions.c' | 
					
						
							|  |  |  |                                    ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', | 
					
						
							|  |  |  |                                      '_multiprocessing/socket_connection.c' | 
					
						
							|  |  |  |                                    ] | 
					
						
							| 
									
										
										
										
											2009-11-20 19:30:22 +00:00
										 |  |  |             if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not | 
					
						
							| 
									
										
										
										
											2009-11-28 10:44:20 +00:00
										 |  |  |                 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |                 multiprocessing_srcs.append('_multiprocessing/semaphore.c') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 14:04:41 +00:00
										 |  |  |         if sysconfig.get_config_var('WITH_THREAD'): | 
					
						
							|  |  |  |             exts.append ( Extension('_multiprocessing', multiprocessing_srcs, | 
					
						
							|  |  |  |                                     define_macros=macros.items(), | 
					
						
							|  |  |  |                                     include_dirs=["Modules/_multiprocessing"])) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             missing.append('_multiprocessing') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-11 02:40:25 +00:00
										 |  |  |         # End multiprocessing | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # Platform-specific libraries | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  |         if platform == 'linux2': | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             # Linux-specific modules | 
					
						
							|  |  |  |             exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('linuxaudiodev') | 
					
						
							| 
									
										
										
										
											2003-01-08 01:37:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-21 22:18:52 +00:00
										 |  |  |         if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', | 
					
						
							|  |  |  |                         'freebsd7', 'freebsd8') | 
					
						
							|  |  |  |             or platform.startswith("gnukfreebsd")): | 
					
						
							| 
									
										
										
										
											2003-02-13 16:12:21 +00:00
										 |  |  |             exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('ossaudiodev') | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  |         if platform == 'sunos5': | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |             # SunOS specific modules | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |             exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             missing.append('sunaudiodev') | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-08 08:04:15 +00:00
										 |  |  |         if platform == 'darwin': | 
					
						
							|  |  |  |             # _scproxy | 
					
						
							|  |  |  |             exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")], | 
					
						
							|  |  |  |                 extra_link_args= [ | 
					
						
							|  |  |  |                     '-framework', 'SystemConfiguration', | 
					
						
							|  |  |  |                     '-framework', 'CoreFoundation' | 
					
						
							|  |  |  |                 ])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-08-26 05:23:19 +00:00
										 |  |  |         if platform == 'darwin' and ("--disable-toolbox-glue" not in | 
					
						
							| 
									
										
										
										
											2006-03-30 20:18:33 +00:00
										 |  |  |                 sysconfig.get_config_var("CONFIG_ARGS")): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 07:06:47 +00:00
										 |  |  |             if int(os.uname()[2].split('.')[0]) >= 8: | 
					
						
							| 
									
										
										
										
											2006-03-30 20:18:33 +00:00
										 |  |  |                 # We're on Mac OS X 10.4 or later, the compiler should | 
					
						
							|  |  |  |                 # support '-Wno-deprecated-declarations'. This will | 
					
						
							|  |  |  |                 # surpress deprecation warnings for the Carbon extensions, | 
					
						
							|  |  |  |                 # these extensions wrap the Carbon APIs and even those | 
					
						
							|  |  |  |                 # parts that are deprecated. | 
					
						
							|  |  |  |                 carbon_extra_compile_args = ['-Wno-deprecated-declarations'] | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 carbon_extra_compile_args = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-24 23:15:57 +00:00
										 |  |  |             # Mac OS X specific modules. | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |             def macSrcExists(name1, name2=''): | 
					
						
							|  |  |  |                 if not name1: | 
					
						
							|  |  |  |                     return None | 
					
						
							|  |  |  |                 names = (name1,) | 
					
						
							|  |  |  |                 if name2: | 
					
						
							|  |  |  |                     names = (name1, name2) | 
					
						
							|  |  |  |                 path = os.path.join(srcdir, 'Mac', 'Modules', *names) | 
					
						
							|  |  |  |                 return os.path.exists(path) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             def addMacExtension(name, kwds, extra_srcs=[]): | 
					
						
							|  |  |  |                 dirname = '' | 
					
						
							|  |  |  |                 if name[0] == '_': | 
					
						
							|  |  |  |                     dirname = name[1:].lower() | 
					
						
							|  |  |  |                 cname = name + '.c' | 
					
						
							|  |  |  |                 cmodulename = name + 'module.c' | 
					
						
							|  |  |  |                 # Check for NNN.c, NNNmodule.c, _nnn/NNN.c, _nnn/NNNmodule.c | 
					
						
							|  |  |  |                 if macSrcExists(cname): | 
					
						
							|  |  |  |                     srcs = [cname] | 
					
						
							|  |  |  |                 elif macSrcExists(cmodulename): | 
					
						
							|  |  |  |                     srcs = [cmodulename] | 
					
						
							|  |  |  |                 elif macSrcExists(dirname, cname): | 
					
						
							|  |  |  |                     # XXX(nnorwitz): If all the names ended with module, we | 
					
						
							|  |  |  |                     # wouldn't need this condition.  ibcarbon is the only one. | 
					
						
							|  |  |  |                     srcs = [os.path.join(dirname, cname)] | 
					
						
							|  |  |  |                 elif macSrcExists(dirname, cmodulename): | 
					
						
							|  |  |  |                     srcs = [os.path.join(dirname, cmodulename)] | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     raise RuntimeError("%s not found" % name) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 # Here's the whole point:  add the extension with sources | 
					
						
							|  |  |  |                 exts.append(Extension(name, srcs + extra_srcs, **kwds)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             # Core Foundation | 
					
						
							|  |  |  |             core_kwds = {'extra_compile_args': carbon_extra_compile_args, | 
					
						
							|  |  |  |                          'extra_link_args': ['-framework', 'CoreFoundation'], | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |             addMacExtension('_CF', core_kwds, ['cf/pycfbridge.c']) | 
					
						
							|  |  |  |             addMacExtension('autoGIL', core_kwds) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-20 10:31:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |             # Carbon | 
					
						
							|  |  |  |             carbon_kwds = {'extra_compile_args': carbon_extra_compile_args, | 
					
						
							|  |  |  |                            'extra_link_args': ['-framework', 'Carbon'], | 
					
						
							|  |  |  |                           } | 
					
						
							| 
									
										
										
										
											2006-04-05 17:30:38 +00:00
										 |  |  |             CARBON_EXTS = ['ColorPicker', 'gestalt', 'MacOS', 'Nav', | 
					
						
							|  |  |  |                            'OSATerminology', 'icglue', | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |                            # All these are in subdirs | 
					
						
							| 
									
										
										
										
											2006-04-05 17:30:38 +00:00
										 |  |  |                            '_AE', '_AH', '_App', '_CarbonEvt', '_Cm', '_Ctl', | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |                            '_Dlg', '_Drag', '_Evt', '_File', '_Folder', '_Fm', | 
					
						
							| 
									
										
										
										
											2006-04-05 17:30:38 +00:00
										 |  |  |                            '_Help', '_Icn', '_IBCarbon', '_List', | 
					
						
							|  |  |  |                            '_Menu', '_Mlte', '_OSA', '_Res', '_Qd', '_Qdoffs', | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  |                            '_Scrap', '_Snd', '_TE', | 
					
						
							| 
									
										
										
										
											2006-04-05 17:30:38 +00:00
										 |  |  |                           ] | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |             for name in CARBON_EXTS: | 
					
						
							|  |  |  |                 addMacExtension(name, carbon_kwds) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  |             # Workaround for a bug in the version of gcc shipped with Xcode 3. | 
					
						
							|  |  |  |             # The _Win extension should build just like the other Carbon extensions, but | 
					
						
							|  |  |  |             # this actually results in a hard crash of the linker. | 
					
						
							|  |  |  |             # | 
					
						
							|  |  |  |             if '-arch ppc64' in cflags and '-arch ppc' in cflags: | 
					
						
							|  |  |  |                 win_kwds = {'extra_compile_args': carbon_extra_compile_args + ['-arch', 'i386', '-arch', 'ppc'], | 
					
						
							|  |  |  |                                'extra_link_args': ['-framework', 'Carbon', '-arch', 'i386', '-arch', 'ppc'], | 
					
						
							|  |  |  |                            } | 
					
						
							|  |  |  |                 addMacExtension('_Win', win_kwds) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 addMacExtension('_Win', carbon_kwds) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  |             # Application Services & QuickTime | 
					
						
							|  |  |  |             app_kwds = {'extra_compile_args': carbon_extra_compile_args, | 
					
						
							|  |  |  |                         'extra_link_args': ['-framework','ApplicationServices'], | 
					
						
							|  |  |  |                        } | 
					
						
							|  |  |  |             addMacExtension('_Launch', app_kwds) | 
					
						
							|  |  |  |             addMacExtension('_CG', app_kwds) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-24 23:15:57 +00:00
										 |  |  |             exts.append( Extension('_Qt', ['qt/_Qtmodule.c'], | 
					
						
							| 
									
										
										
										
											2006-03-30 20:18:33 +00:00
										 |  |  |                         extra_compile_args=carbon_extra_compile_args, | 
					
						
							|  |  |  |                         extra_link_args=['-framework', 'QuickTime', | 
					
						
							| 
									
										
										
										
											2002-11-24 23:15:57 +00:00
										 |  |  |                                      '-framework', 'Carbon']) ) | 
					
						
							| 
									
										
										
										
											2006-04-03 04:52:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         self.extensions.extend(exts) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Call the method for detecting whether _tkinter can be compiled | 
					
						
							|  |  |  |         self.detect_tkinter(inc_dirs, lib_dirs) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-06 15:41:38 +00:00
										 |  |  |         if '_tkinter' not in [e.name for e in self.extensions]: | 
					
						
							|  |  |  |             missing.append('_tkinter') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return missing | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |     def detect_tkinter_darwin(self, inc_dirs, lib_dirs): | 
					
						
							|  |  |  |         # The _tkinter module, using frameworks. Since frameworks are quite | 
					
						
							|  |  |  |         # different the UNIX search logic is not sharable. | 
					
						
							|  |  |  |         from os.path import join, exists | 
					
						
							|  |  |  |         framework_dirs = [ | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             '/Library/Frameworks', | 
					
						
							| 
									
										
										
										
											2009-03-04 21:30:12 +00:00
										 |  |  |             '/System/Library/Frameworks/', | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |             join(os.getenv('HOME'), '/Library/Frameworks') | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-30 05:01:26 +00:00
										 |  |  |         # Find the directory that contains the Tcl.framework and Tk.framework | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         # bundles. | 
					
						
							|  |  |  |         # XXX distutils should support -F! | 
					
						
							|  |  |  |         for F in framework_dirs: | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             # both Tcl.framework and Tk.framework should be present | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |             for fw in 'Tcl', 'Tk': | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |                 if not exists(join(F, fw + '.framework')): | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |                     break | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 # ok, F is now directory with both frameworks. Continure | 
					
						
							|  |  |  |                 # building | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             # Tk and Tcl frameworks not found. Normal "unix" tkinter search | 
					
						
							|  |  |  |             # will now resume. | 
					
						
							|  |  |  |             return 0 | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         # For 8.4a2, we must add -I options that point inside the Tcl and Tk | 
					
						
							|  |  |  |         # frameworks. In later release we should hopefully be able to pass | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |         # the -F option to gcc, which specifies a framework lookup path. | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         # | 
					
						
							|  |  |  |         include_dirs = [ | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             join(F, fw + '.framework', H) | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |             for fw in 'Tcl', 'Tk' | 
					
						
							|  |  |  |             for H in 'Headers', 'Versions/Current/PrivateHeaders' | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |         # For 8.4a2, the X11 headers are not included. Rather than include a | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         # complicated search, this is a hard-coded path. It could bail out | 
					
						
							|  |  |  |         # if X11 libs are not found... | 
					
						
							|  |  |  |         include_dirs.append('/usr/X11R6/include') | 
					
						
							|  |  |  |         frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  |         # All existing framework builds of Tcl/Tk don't support 64-bit | 
					
						
							|  |  |  |         # architectures. | 
					
						
							|  |  |  |         cflags = sysconfig.get_config_vars('CFLAGS')[0] | 
					
						
							|  |  |  |         archs = re.findall('-arch\s+(\w+)', cflags) | 
					
						
							| 
									
										
										
										
											2009-09-15 18:33:33 +00:00
										 |  |  |         fp = os.popen("file %s/Tk.framework/Tk | grep 'for architecture'"%(F,)) | 
					
						
							|  |  |  |         detected_archs = [] | 
					
						
							|  |  |  |         for ln in fp: | 
					
						
							|  |  |  |             a = ln.split()[-1] | 
					
						
							|  |  |  |             if a in archs: | 
					
						
							|  |  |  |                 detected_archs.append(ln.split()[-1]) | 
					
						
							|  |  |  |         fp.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for a in detected_archs: | 
					
						
							|  |  |  |             frameworks.append('-arch') | 
					
						
							|  |  |  |             frameworks.append(a) | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], | 
					
						
							|  |  |  |                         define_macros=[('WITH_APPINIT', 1)], | 
					
						
							|  |  |  |                         include_dirs = include_dirs, | 
					
						
							|  |  |  |                         libraries = [], | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  |                         extra_compile_args = frameworks[2:], | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |                         extra_link_args = frameworks, | 
					
						
							|  |  |  |                         ) | 
					
						
							|  |  |  |         self.extensions.append(ext) | 
					
						
							|  |  |  |         return 1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |     def detect_tkinter(self, inc_dirs, lib_dirs): | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # The _tkinter module. | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  |         # Rather than complicate the code below, detecting and building | 
					
						
							|  |  |  |         # AquaTk is a separate method. Only one Tkinter will be built on | 
					
						
							|  |  |  |         # Darwin - either AquaTk, if it is found, or X11 based Tk. | 
					
						
							|  |  |  |         platform = self.get_platform() | 
					
						
							| 
									
										
										
										
											2005-12-30 05:01:26 +00:00
										 |  |  |         if (platform == 'darwin' and | 
					
						
							|  |  |  |             self.detect_tkinter_darwin(inc_dirs, lib_dirs)): | 
					
						
							| 
									
										
										
										
											2003-01-29 03:49:43 +00:00
										 |  |  |             return | 
					
						
							| 
									
										
										
										
											2002-06-21 14:48:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # Assume we haven't found any of the libraries or include files | 
					
						
							| 
									
										
										
										
											2001-07-24 06:54:01 +00:00
										 |  |  |         # The versions with dots are used on Unix, and the versions without | 
					
						
							|  |  |  |         # dots on Windows, for detection by cygwin. | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         tcllib = tklib = tcl_includes = tk_includes = None | 
					
						
							| 
									
										
										
										
											2009-08-16 14:34:26 +00:00
										 |  |  |         for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', | 
					
						
							|  |  |  |                         '8.2', '82', '8.1', '81', '8.0', '80']: | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             tklib = self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                         'tk' + version) | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             tcllib = self.compiler.find_library_file(lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                          'tcl' + version) | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  |             if tklib and tcllib: | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |                 # Exit the loop when we've found the Tcl/Tk libraries | 
					
						
							|  |  |  |                 break | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         # Now check for the header files | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         if tklib and tcllib: | 
					
						
							| 
									
										
										
										
											2004-03-21 18:57:35 +00:00
										 |  |  |             # Check for the include files on Debian and {Free,Open}BSD, where | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             # they're put in /usr/include/{tcl,tk}X.Y | 
					
						
							| 
									
										
										
										
											2004-03-21 18:57:35 +00:00
										 |  |  |             dotversion = version | 
					
						
							|  |  |  |             if '.' not in dotversion and "bsd" in sys.platform.lower(): | 
					
						
							|  |  |  |                 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, | 
					
						
							|  |  |  |                 # but the include subdirs are named like .../include/tcl8.3. | 
					
						
							|  |  |  |                 dotversion = dotversion[:-1] + '.' + dotversion[-1] | 
					
						
							|  |  |  |             tcl_include_sub = [] | 
					
						
							|  |  |  |             tk_include_sub = [] | 
					
						
							|  |  |  |             for dir in inc_dirs: | 
					
						
							|  |  |  |                 tcl_include_sub += [dir + os.sep + "tcl" + dotversion] | 
					
						
							|  |  |  |                 tk_include_sub += [dir + os.sep + "tk" + dotversion] | 
					
						
							|  |  |  |             tk_include_sub += tcl_include_sub | 
					
						
							|  |  |  |             tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub) | 
					
						
							|  |  |  |             tk_includes = find_file('tk.h', inc_dirs, tk_include_sub) | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-03 08:45:51 +00:00
										 |  |  |         if (tcllib is None or tklib is None or | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             tcl_includes is None or tk_includes is None): | 
					
						
							| 
									
										
										
										
											2004-03-21 18:57:35 +00:00
										 |  |  |             self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             return | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # OK... everything seems to be present for Tcl/Tk. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] | 
					
						
							|  |  |  |         for dir in tcl_includes + tk_includes: | 
					
						
							|  |  |  |             if dir not in include_dirs: | 
					
						
							|  |  |  |                 include_dirs.append(dir) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # Check for various platform-specific directories | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  |         if platform == 'sunos5': | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             include_dirs.append('/usr/openwin/include') | 
					
						
							|  |  |  |             added_lib_dirs.append('/usr/openwin/lib') | 
					
						
							|  |  |  |         elif os.path.exists('/usr/X11R6/include'): | 
					
						
							|  |  |  |             include_dirs.append('/usr/X11R6/include') | 
					
						
							| 
									
										
										
										
											2004-11-13 11:13:35 +00:00
										 |  |  |             added_lib_dirs.append('/usr/X11R6/lib64') | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             added_lib_dirs.append('/usr/X11R6/lib') | 
					
						
							|  |  |  |         elif os.path.exists('/usr/X11R5/include'): | 
					
						
							|  |  |  |             include_dirs.append('/usr/X11R5/include') | 
					
						
							|  |  |  |             added_lib_dirs.append('/usr/X11R5/lib') | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |             # Assume default location for X11 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             include_dirs.append('/usr/X11/include') | 
					
						
							|  |  |  |             added_lib_dirs.append('/usr/X11/lib') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-05 15:16:17 +00:00
										 |  |  |         # If Cygwin, then verify that X is installed before proceeding | 
					
						
							|  |  |  |         if platform == 'cygwin': | 
					
						
							|  |  |  |             x11_inc = find_file('X11/Xlib.h', [], include_dirs) | 
					
						
							|  |  |  |             if x11_inc is None: | 
					
						
							|  |  |  |                 return | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # Check for BLT extension | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         if self.compiler.find_library_file(lib_dirs + added_lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                'BLT8.0'): | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             defs.append( ('WITH_BLT', 1) ) | 
					
						
							|  |  |  |             libs.append('BLT8.0') | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         elif self.compiler.find_library_file(lib_dirs + added_lib_dirs, | 
					
						
							| 
									
										
										
										
											2009-07-06 12:50:46 +00:00
										 |  |  |                                                 'BLT'): | 
					
						
							| 
									
										
										
										
											2002-12-12 20:23:38 +00:00
										 |  |  |             defs.append( ('WITH_BLT', 1) ) | 
					
						
							|  |  |  |             libs.append('BLT') | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Add the Tcl/Tk libraries | 
					
						
							| 
									
										
										
										
											2003-02-05 15:06:46 +00:00
										 |  |  |         libs.append('tk'+ version) | 
					
						
							|  |  |  |         libs.append('tcl'+ version) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-24 03:31:07 +00:00
										 |  |  |         if platform in ['aix3', 'aix4']: | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |             libs.append('ld') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-07-24 06:54:01 +00:00
										 |  |  |         # Finally, link with the X11 libraries (not appropriate on cygwin) | 
					
						
							|  |  |  |         if platform != "cygwin": | 
					
						
							|  |  |  |             libs.append('X11') | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], | 
					
						
							|  |  |  |                         define_macros=[('WITH_APPINIT', 1)] + defs, | 
					
						
							|  |  |  |                         include_dirs = include_dirs, | 
					
						
							|  |  |  |                         libraries = libs, | 
					
						
							|  |  |  |                         library_dirs = added_lib_dirs, | 
					
						
							|  |  |  |                         ) | 
					
						
							|  |  |  |         self.extensions.append(ext) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-11 20:05:50 +00:00
										 |  |  | ##         # Uncomment these lines if you want to play with xxmodule.c | 
					
						
							|  |  |  | ##         ext = Extension('xx', ['xxmodule.c']) | 
					
						
							|  |  |  | ##         self.extensions.append(ext) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-18 18:44:20 +00:00
										 |  |  |         # XXX handle these, but how to detect? | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # *** Uncomment and edit for PIL (TkImaging) extension only: | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         #       -DWITH_PIL -I../Extensions/Imaging/libImaging  tkImaging.c \ | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # *** Uncomment and edit for TOGL extension only: | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         #       -DWITH_TOGL togl.c \ | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         # *** Uncomment these for TOGL extension only: | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  |         #       -lGL -lGLU -lXext -lXmu \ | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |     def configure_ctypes_darwin(self, ext): | 
					
						
							|  |  |  |         # Darwin (OS X) uses preconfigured files, in | 
					
						
							|  |  |  |         # the Modules/_ctypes/libffi_osx directory. | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |         srcdir = sysconfig.get_config_var('srcdir') | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |         ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', | 
					
						
							|  |  |  |                                                   '_ctypes', 'libffi_osx')) | 
					
						
							|  |  |  |         sources = [os.path.join(ffi_srcdir, p) | 
					
						
							|  |  |  |                    for p in ['ffi.c', | 
					
						
							| 
									
										
										
										
											2008-06-05 12:58:24 +00:00
										 |  |  |                              'x86/darwin64.S', | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |                              'x86/x86-darwin.S', | 
					
						
							|  |  |  |                              'x86/x86-ffi_darwin.c', | 
					
						
							|  |  |  |                              'x86/x86-ffi64.c', | 
					
						
							|  |  |  |                              'powerpc/ppc-darwin.S', | 
					
						
							|  |  |  |                              'powerpc/ppc-darwin_closure.S', | 
					
						
							|  |  |  |                              'powerpc/ppc-ffi_darwin.c', | 
					
						
							|  |  |  |                              'powerpc/ppc64-darwin_closure.S', | 
					
						
							|  |  |  |                              ]] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Add .S (preprocessed assembly) to C compiler source extensions. | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |         self.compiler.src_extensions.append('.S') | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         include_dirs = [os.path.join(ffi_srcdir, 'include'), | 
					
						
							|  |  |  |                         os.path.join(ffi_srcdir, 'powerpc')] | 
					
						
							|  |  |  |         ext.include_dirs.extend(include_dirs) | 
					
						
							|  |  |  |         ext.sources.extend(sources) | 
					
						
							|  |  |  |         return True | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  |     def configure_ctypes(self, ext): | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |         if not self.use_system_libffi: | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |             if sys.platform == 'darwin': | 
					
						
							|  |  |  |                 return self.configure_ctypes_darwin(ext) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-05 16:32:29 +00:00
										 |  |  |             srcdir = sysconfig.get_config_var('srcdir') | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |             ffi_builddir = os.path.join(self.build_temp, 'libffi') | 
					
						
							|  |  |  |             ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', | 
					
						
							|  |  |  |                                          '_ctypes', 'libffi')) | 
					
						
							|  |  |  |             ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-27 15:50:42 +00:00
										 |  |  |             from distutils.dep_util import newer_group | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             config_sources = [os.path.join(ffi_srcdir, fname) | 
					
						
							| 
									
										
										
										
											2007-02-14 11:30:56 +00:00
										 |  |  |                               for fname in os.listdir(ffi_srcdir) | 
					
						
							|  |  |  |                               if os.path.isfile(os.path.join(ffi_srcdir, fname))] | 
					
						
							| 
									
										
										
										
											2006-04-27 15:50:42 +00:00
										 |  |  |             if self.force or newer_group(config_sources, | 
					
						
							|  |  |  |                                          ffi_configfile): | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |                 from distutils.dir_util import mkpath | 
					
						
							|  |  |  |                 mkpath(ffi_builddir) | 
					
						
							|  |  |  |                 config_args = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 # Pass empty CFLAGS because we'll just append the resulting | 
					
						
							|  |  |  |                 # CFLAGS to Python's; -g or -O2 is to be avoided. | 
					
						
							|  |  |  |                 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ | 
					
						
							|  |  |  |                       % (ffi_builddir, ffi_srcdir, " ".join(config_args)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 res = os.system(cmd) | 
					
						
							|  |  |  |                 if res or not os.path.exists(ffi_configfile): | 
					
						
							|  |  |  |                     print "Failed to configure _ctypes module" | 
					
						
							|  |  |  |                     return False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             fficonfig = {} | 
					
						
							| 
									
										
										
										
											2010-01-13 11:57:42 +00:00
										 |  |  |             with open(ffi_configfile) as f: | 
					
						
							|  |  |  |                 exec f in fficonfig | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             # Add .S (preprocessed assembly) to C compiler source extensions. | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |             self.compiler.src_extensions.append('.S') | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             include_dirs = [os.path.join(ffi_builddir, 'include'), | 
					
						
							| 
									
										
										
										
											2010-01-13 11:47:49 +00:00
										 |  |  |                             ffi_builddir, | 
					
						
							|  |  |  |                             os.path.join(ffi_srcdir, 'src')] | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |             extra_compile_args = fficonfig['ffi_cflags'].split() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-13 11:47:49 +00:00
										 |  |  |             ext.sources.extend(os.path.join(ffi_srcdir, f) for f in | 
					
						
							|  |  |  |                                fficonfig['ffi_sources']) | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |             ext.include_dirs.extend(include_dirs) | 
					
						
							|  |  |  |             ext.extra_compile_args.extend(extra_compile_args) | 
					
						
							| 
									
										
										
										
											2006-04-07 19:27:56 +00:00
										 |  |  |         return True | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |     def detect_ctypes(self, inc_dirs, lib_dirs): | 
					
						
							|  |  |  |         self.use_system_libffi = False | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  |         include_dirs = [] | 
					
						
							|  |  |  |         extra_compile_args = [] | 
					
						
							| 
									
										
										
										
											2006-08-04 18:57:34 +00:00
										 |  |  |         extra_link_args = [] | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |         sources = ['_ctypes/_ctypes.c', | 
					
						
							|  |  |  |                    '_ctypes/callbacks.c', | 
					
						
							|  |  |  |                    '_ctypes/callproc.c', | 
					
						
							|  |  |  |                    '_ctypes/stgdict.c', | 
					
						
							|  |  |  |                    '_ctypes/cfield.c', | 
					
						
							| 
									
										
										
										
											2006-04-07 19:04:09 +00:00
										 |  |  |                    '_ctypes/malloc_closure.c'] | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |         depends = ['_ctypes/ctypes.h'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if sys.platform == 'darwin': | 
					
						
							|  |  |  |             sources.append('_ctypes/darwin/dlfcn_simple.c') | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |             extra_compile_args.append('-DMACOSX') | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |             include_dirs.append('_ctypes/darwin') | 
					
						
							|  |  |  | # XXX Is this still needed? | 
					
						
							|  |  |  | ##            extra_link_args.extend(['-read_only_relocs', 'warning']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-04 18:57:34 +00:00
										 |  |  |         elif sys.platform == 'sunos5': | 
					
						
							| 
									
										
										
										
											2006-08-09 23:42:18 +00:00
										 |  |  |             # XXX This shouldn't be necessary; it appears that some | 
					
						
							|  |  |  |             # of the assembler code is non-PIC (i.e. it has relocations | 
					
						
							|  |  |  |             # when it shouldn't. The proper fix would be to rewrite | 
					
						
							|  |  |  |             # the assembler code to be PIC. | 
					
						
							|  |  |  |             # This only works with GCC; the Sun compiler likely refuses | 
					
						
							|  |  |  |             # this option. If you want to compile ctypes with the Sun | 
					
						
							|  |  |  |             # compiler, please research a proper solution, instead of | 
					
						
							|  |  |  |             # finding some -z option for the Sun compiler. | 
					
						
							| 
									
										
										
										
											2006-08-04 18:57:34 +00:00
										 |  |  |             extra_link_args.append('-mimpure-text') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-02 18:41:30 +00:00
										 |  |  |         elif sys.platform.startswith('hp-ux'): | 
					
						
							| 
									
										
										
										
											2008-05-20 19:53:47 +00:00
										 |  |  |             extra_link_args.append('-fPIC') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |         ext = Extension('_ctypes', | 
					
						
							|  |  |  |                         include_dirs=include_dirs, | 
					
						
							|  |  |  |                         extra_compile_args=extra_compile_args, | 
					
						
							| 
									
										
										
										
											2006-08-04 18:57:34 +00:00
										 |  |  |                         extra_link_args=extra_link_args, | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |                         libraries=[], | 
					
						
							| 
									
										
										
										
											2006-03-08 19:51:58 +00:00
										 |  |  |                         sources=sources, | 
					
						
							|  |  |  |                         depends=depends) | 
					
						
							|  |  |  |         ext_test = Extension('_ctypes_test', | 
					
						
							|  |  |  |                              sources=['_ctypes/_ctypes_test.c']) | 
					
						
							|  |  |  |         self.extensions.extend([ext, ext_test]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |         if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-04 20:09:11 +00:00
										 |  |  |         if sys.platform == 'darwin': | 
					
						
							|  |  |  |             # OS X 10.5 comes with libffi.dylib; the include files are | 
					
						
							|  |  |  |             # in /usr/include/ffi | 
					
						
							|  |  |  |             inc_dirs.append('/usr/include/ffi') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-01 15:16:29 +00:00
										 |  |  |         ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] | 
					
						
							| 
									
										
										
										
											2010-04-21 21:45:30 +00:00
										 |  |  |         if not ffi_inc or ffi_inc[0] == '': | 
					
						
							| 
									
										
										
										
											2010-01-01 15:16:29 +00:00
										 |  |  |             ffi_inc = find_file('ffi.h', [], inc_dirs) | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |         if ffi_inc is not None: | 
					
						
							|  |  |  |             ffi_h = ffi_inc[0] + '/ffi.h' | 
					
						
							|  |  |  |             fp = open(ffi_h) | 
					
						
							|  |  |  |             while 1: | 
					
						
							|  |  |  |                 line = fp.readline() | 
					
						
							|  |  |  |                 if not line: | 
					
						
							|  |  |  |                     ffi_inc = None | 
					
						
							|  |  |  |                     break | 
					
						
							|  |  |  |                 if line.startswith('#define LIBFFI_H'): | 
					
						
							|  |  |  |                     break | 
					
						
							|  |  |  |         ffi_lib = None | 
					
						
							|  |  |  |         if ffi_inc is not None: | 
					
						
							|  |  |  |             for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): | 
					
						
							| 
									
										
										
										
											2010-03-05 00:29:38 +00:00
										 |  |  |                 if (self.compiler.find_library_file(lib_dirs, lib_name)): | 
					
						
							| 
									
										
										
										
											2006-04-11 11:12:43 +00:00
										 |  |  |                     ffi_lib = lib_name | 
					
						
							|  |  |  |                     break | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ffi_inc and ffi_lib: | 
					
						
							|  |  |  |             ext.include_dirs.extend(ffi_inc) | 
					
						
							|  |  |  |             ext.libraries.append(ffi_lib) | 
					
						
							|  |  |  |             self.use_system_libffi = True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-21 20:29:27 +00:00
										 |  |  | class PyBuildInstall(install): | 
					
						
							|  |  |  |     # Suppress the warning about installation into the lib_dynload | 
					
						
							|  |  |  |     # directory, which is not in sys.path when running Python during | 
					
						
							|  |  |  |     # installation: | 
					
						
							|  |  |  |     def initialize_options (self): | 
					
						
							|  |  |  |         install.initialize_options(self) | 
					
						
							|  |  |  |         self.warn_dir=0 | 
					
						
							| 
									
										
										
										
											2002-01-23 15:04:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-12-17 16:47:17 +00:00
										 |  |  | class PyBuildInstallLib(install_lib): | 
					
						
							|  |  |  |     # Do exactly what install_lib does but make sure correct access modes get | 
					
						
							|  |  |  |     # set on installed directories and files. All installed files with get | 
					
						
							|  |  |  |     # mode 644 unless they are a shared library in which case they will get | 
					
						
							|  |  |  |     # mode 755. All installed directories will get mode 755. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     so_ext = sysconfig.get_config_var("SO") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def install(self): | 
					
						
							|  |  |  |         outfiles = install_lib.install(self) | 
					
						
							|  |  |  |         self.set_file_modes(outfiles, 0644, 0755) | 
					
						
							|  |  |  |         self.set_dir_modes(self.install_dir, 0755) | 
					
						
							|  |  |  |         return outfiles | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def set_file_modes(self, files, defaultMode, sharedLibMode): | 
					
						
							|  |  |  |         if not self.is_chmod_supported(): return | 
					
						
							|  |  |  |         if not files: return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for filename in files: | 
					
						
							|  |  |  |             if os.path.islink(filename): continue | 
					
						
							|  |  |  |             mode = defaultMode | 
					
						
							|  |  |  |             if filename.endswith(self.so_ext): mode = sharedLibMode | 
					
						
							|  |  |  |             log.info("changing mode of %s to %o", filename, mode) | 
					
						
							|  |  |  |             if not self.dry_run: os.chmod(filename, mode) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def set_dir_modes(self, dirname, mode): | 
					
						
							|  |  |  |         if not self.is_chmod_supported(): return | 
					
						
							|  |  |  |         os.path.walk(dirname, self.set_dir_modes_visitor, mode) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def set_dir_modes_visitor(self, mode, dirname, names): | 
					
						
							|  |  |  |         if os.path.islink(dirname): return | 
					
						
							|  |  |  |         log.info("changing mode of %s to %o", dirname, mode) | 
					
						
							|  |  |  |         if not self.dry_run: os.chmod(dirname, mode) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def is_chmod_supported(self): | 
					
						
							|  |  |  |         return hasattr(os, 'chmod') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-20 02:52:04 +00:00
										 |  |  | SUMMARY = """
 | 
					
						
							|  |  |  | Python is an interpreted, interactive, object-oriented programming | 
					
						
							|  |  |  | language. It is often compared to Tcl, Perl, Scheme or Java. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Python combines remarkable power with very clear syntax. It has | 
					
						
							|  |  |  | modules, classes, exceptions, very high level dynamic data types, and | 
					
						
							|  |  |  | dynamic typing. There are interfaces to many system calls and | 
					
						
							|  |  |  | libraries, as well as to various windowing systems (X11, Motif, Tk, | 
					
						
							|  |  |  | Mac, MFC). New built-in modules are easily written in C or C++. Python | 
					
						
							|  |  |  | is also usable as an extension language for applications that need a | 
					
						
							|  |  |  | programmable interface. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The Python implementation is portable: it runs on many brands of UNIX, | 
					
						
							|  |  |  | on Windows, DOS, OS/2, Mac, Amiga... If your favorite system isn't | 
					
						
							|  |  |  | listed here, it may still be supported, if there's a C compiler for | 
					
						
							|  |  |  | it. Ask around on comp.lang.python -- or just try compiling Python | 
					
						
							|  |  |  | yourself. | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CLASSIFIERS = """
 | 
					
						
							|  |  |  | Development Status :: 6 - Mature | 
					
						
							|  |  |  | License :: OSI Approved :: Python Software Foundation License | 
					
						
							|  |  |  | Natural Language :: English | 
					
						
							|  |  |  | Programming Language :: C | 
					
						
							|  |  |  | Programming Language :: Python | 
					
						
							|  |  |  | Topic :: Software Development | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2001-05-21 20:48:09 +00:00
										 |  |  |     # turn off warnings when deprecated modules are imported | 
					
						
							|  |  |  |     import warnings | 
					
						
							|  |  |  |     warnings.filterwarnings("ignore",category=DeprecationWarning) | 
					
						
							| 
									
										
										
										
											2003-02-20 02:52:04 +00:00
										 |  |  |     setup(# PyPI Metadata (PEP 301) | 
					
						
							|  |  |  |           name = "Python", | 
					
						
							|  |  |  |           version = sys.version.split()[0], | 
					
						
							|  |  |  |           url = "http://www.python.org/%s" % sys.version[:3], | 
					
						
							|  |  |  |           maintainer = "Guido van Rossum and the Python community", | 
					
						
							|  |  |  |           maintainer_email = "python-dev@python.org", | 
					
						
							|  |  |  |           description = "A high-level object-oriented programming language", | 
					
						
							|  |  |  |           long_description = SUMMARY.strip(), | 
					
						
							|  |  |  |           license = "PSF license", | 
					
						
							|  |  |  |           classifiers = filter(None, CLASSIFIERS.split("\n")), | 
					
						
							|  |  |  |           platforms = ["Many"], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           # Build info | 
					
						
							| 
									
										
										
										
											2002-12-17 16:47:17 +00:00
										 |  |  |           cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, | 
					
						
							|  |  |  |                       'install_lib':PyBuildInstallLib}, | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |           # The struct module is defined here, because build_ext won't be | 
					
						
							|  |  |  |           # called unless there's at least one extension module defined. | 
					
						
							| 
									
										
										
										
											2006-05-23 19:11:34 +00:00
										 |  |  |           ext_modules=[Extension('_struct', ['_struct.c'])], | 
					
						
							| 
									
										
										
										
											2001-02-28 20:56:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |           # Scripts to install | 
					
						
							| 
									
										
										
										
											2004-06-26 22:29:42 +00:00
										 |  |  |           scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', | 
					
						
							| 
									
										
										
										
											2008-03-24 12:57:53 +00:00
										 |  |  |                      'Tools/scripts/2to3', | 
					
						
							| 
									
										
										
										
											2004-06-26 22:29:42 +00:00
										 |  |  |                      'Lib/smtpd.py'] | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  |         ) | 
					
						
							| 
									
										
										
										
											2001-01-24 08:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-17 15:23:23 +00:00
										 |  |  | # --install-platlib | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     main() |