Andrew M. Kuchling | 66012fe | 2001-01-26 21:56:58 +0000 | [diff] [blame] | 1 | # Autodetecting setup.py script for building the Python extensions |
| 2 | # |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 3 | |
Andrew M. Kuchling | 66012fe | 2001-01-26 21:56:58 +0000 | [diff] [blame] | 4 | __version__ = "$Revision$" |
| 5 | |
Michael W. Hudson | af14289 | 2002-01-23 15:07:46 +0000 | [diff] [blame] | 6 | import sys, os, getopt, imp |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 7 | from distutils import sysconfig |
Andrew M. Kuchling | 8d7f086 | 2001-02-23 16:32:32 +0000 | [diff] [blame] | 8 | from distutils import text_file |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 9 | from distutils.errors import * |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 10 | from distutils.core import Extension, setup |
| 11 | from distutils.command.build_ext import build_ext |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 12 | from distutils.command.install import install |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 13 | |
| 14 | # This global variable is used to hold the list of modules to be disabled. |
| 15 | disabled_module_list = [] |
| 16 | |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 17 | def add_dir_to_list(dirlist, dir): |
| 18 | """Add the directory 'dir' to the list 'dirlist' (at the front) if |
| 19 | 1) 'dir' is not already in 'dirlist' |
| 20 | 2) 'dir' actually exists, and is a directory.""" |
Jack Jansen | 4439b7c | 2002-06-26 15:44:30 +0000 | [diff] [blame] | 21 | if dir is not None and os.path.isdir(dir) and dir not in dirlist: |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 22 | dirlist.insert(0, dir) |
| 23 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 24 | def find_file(filename, std_dirs, paths): |
| 25 | """Searches for the directory where a given file is located, |
| 26 | and returns a possibly-empty list of additional directories, or None |
| 27 | if the file couldn't be found at all. |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 28 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 29 | 'filename' is the name of a file, such as readline.h or libcrypto.a. |
| 30 | 'std_dirs' is the list of standard system directories; if the |
| 31 | file is found in one of them, no additional directives are needed. |
| 32 | 'paths' is a list of additional locations to check; if the file is |
| 33 | found in one of them, the resulting list will contain the directory. |
| 34 | """ |
| 35 | |
| 36 | # Check the standard locations |
| 37 | for dir in std_dirs: |
| 38 | f = os.path.join(dir, filename) |
| 39 | if os.path.exists(f): return [] |
| 40 | |
| 41 | # Check the additional directories |
| 42 | for dir in paths: |
| 43 | f = os.path.join(dir, filename) |
| 44 | if os.path.exists(f): |
| 45 | return [dir] |
| 46 | |
| 47 | # Not found anywhere |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 48 | return None |
| 49 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 50 | def find_library_file(compiler, libname, std_dirs, paths): |
| 51 | filename = compiler.library_filename(libname, lib_type='shared') |
| 52 | result = find_file(filename, std_dirs, paths) |
| 53 | if result is not None: return result |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 54 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 55 | filename = compiler.library_filename(libname, lib_type='static') |
| 56 | result = find_file(filename, std_dirs, paths) |
| 57 | return result |
| 58 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 59 | def module_enabled(extlist, modname): |
| 60 | """Returns whether the module 'modname' is present in the list |
| 61 | of extensions 'extlist'.""" |
| 62 | extlist = [ext for ext in extlist if ext.name == modname] |
| 63 | return len(extlist) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 64 | |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 65 | def find_module_file(module, dirlist): |
| 66 | """Find a module in a set of possible folders. If it is not found |
| 67 | return the unadorned filename""" |
| 68 | list = find_file(module, [], dirlist) |
| 69 | if not list: |
| 70 | return module |
| 71 | if len(list) > 1: |
| 72 | self.announce("WARNING: multiple copies of %s found"%module) |
| 73 | return os.path.join(list[0], module) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 74 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 75 | class PyBuildExt(build_ext): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 76 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 77 | def build_extensions(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 78 | |
| 79 | # Detect which modules should be compiled |
| 80 | self.detect_modules() |
| 81 | |
| 82 | # Remove modules that are present on the disabled list |
| 83 | self.extensions = [ext for ext in self.extensions |
| 84 | if ext.name not in disabled_module_list] |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 85 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 86 | # Fix up the autodetected modules, prefixing all the source files |
| 87 | # with Modules/ and adding Python's include directory to the path. |
| 88 | (srcdir,) = sysconfig.get_config_vars('srcdir') |
| 89 | |
Neil Schemenauer | 726b78e | 2001-01-24 17:18:21 +0000 | [diff] [blame] | 90 | # Figure out the location of the source code for extension modules |
| 91 | moddir = os.path.join(os.getcwd(), srcdir, 'Modules') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 92 | moddir = os.path.normpath(moddir) |
| 93 | srcdir, tail = os.path.split(moddir) |
| 94 | srcdir = os.path.normpath(srcdir) |
| 95 | moddir = os.path.normpath(moddir) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 96 | |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 97 | moddirlist = [moddir] |
| 98 | incdirlist = ['./Include'] |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 99 | |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 100 | # Platform-dependent module source and include directories |
| 101 | platform = self.get_platform() |
Jack Jansen | 4439b7c | 2002-06-26 15:44:30 +0000 | [diff] [blame] | 102 | if platform in ('darwin', 'mac'): |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 103 | # Mac OS X also includes some mac-specific modules |
| 104 | macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules') |
| 105 | moddirlist.append(macmoddir) |
| 106 | incdirlist.append('./Mac/Include') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 107 | |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 108 | alldirlist = moddirlist + incdirlist |
| 109 | |
Andrew M. Kuchling | 3da989c | 2001-02-28 22:49:26 +0000 | [diff] [blame] | 110 | # Fix up the paths for scripts, too |
| 111 | self.distribution.scripts = [os.path.join(srcdir, filename) |
| 112 | for filename in self.distribution.scripts] |
| 113 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 114 | for ext in self.extensions[:]: |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 115 | ext.sources = [ find_module_file(filename, moddirlist) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 116 | for filename in ext.sources ] |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 117 | if ext.depends is not None: |
| 118 | ext.depends = [find_module_file(filename, alldirlist) |
| 119 | for filename in ext.depends] |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 120 | ext.include_dirs.append( '.' ) # to get config.h |
| 121 | for incdir in incdirlist: |
| 122 | ext.include_dirs.append( os.path.join(srcdir, incdir) ) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 123 | |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 124 | # If a module has already been built statically, |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 125 | # don't build it here |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 126 | if ext.name in sys.builtin_module_names: |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 127 | self.extensions.remove(ext) |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 128 | |
Jack Jansen | 4439b7c | 2002-06-26 15:44:30 +0000 | [diff] [blame] | 129 | if platform != 'mac': |
| 130 | # Parse Modules/Setup to figure out which modules are turned |
| 131 | # on in the file. |
| 132 | input = text_file.TextFile('Modules/Setup', join_lines=1) |
| 133 | remove_modules = [] |
| 134 | while 1: |
| 135 | line = input.readline() |
| 136 | if not line: break |
| 137 | line = line.split() |
| 138 | remove_modules.append( line[0] ) |
| 139 | input.close() |
| 140 | |
| 141 | for ext in self.extensions[:]: |
| 142 | if ext.name in remove_modules: |
| 143 | self.extensions.remove(ext) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 144 | |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 145 | # When you run "make CC=altcc" or something similar, you really want |
| 146 | # those environment variables passed into the setup.py phase. Here's |
| 147 | # a small set of useful ones. |
| 148 | compiler = os.environ.get('CC') |
| 149 | linker_so = os.environ.get('LDSHARED') |
| 150 | args = {} |
| 151 | # unfortunately, distutils doesn't let us provide separate C and C++ |
| 152 | # compilers |
| 153 | if compiler is not None: |
Martin v. Löwis | 3e4b0e8 | 2001-08-10 08:56:17 +0000 | [diff] [blame] | 154 | (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT') |
| 155 | args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 156 | if linker_so is not None: |
Martin v. Löwis | 2f20dab | 2001-10-08 13:18:37 +0000 | [diff] [blame] | 157 | args['linker_so'] = linker_so |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 158 | self.compiler.set_executables(**args) |
| 159 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 160 | build_ext.build_extensions(self) |
| 161 | |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 162 | def build_extension(self, ext): |
| 163 | |
| 164 | try: |
| 165 | build_ext.build_extension(self, ext) |
| 166 | except (CCompilerError, DistutilsError), why: |
| 167 | self.announce('WARNING: building of extension "%s" failed: %s' % |
| 168 | (ext.name, sys.exc_info()[1])) |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 169 | return |
Jack Jansen | f49c6f9 | 2001-11-01 14:44:15 +0000 | [diff] [blame] | 170 | # Workaround for Mac OS X: The Carbon-based modules cannot be |
| 171 | # reliably imported into a command-line Python |
| 172 | if 'Carbon' in ext.extra_link_args: |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 173 | self.announce( |
| 174 | 'WARNING: skipping import check for Carbon-based "%s"' % |
| 175 | ext.name) |
| 176 | return |
Jason Tishler | 24cf776 | 2002-05-22 16:46:15 +0000 | [diff] [blame] | 177 | # Workaround for Cygwin: Cygwin currently has fork issues when many |
| 178 | # modules have been imported |
| 179 | if self.get_platform() == 'cygwin': |
| 180 | self.announce('WARNING: skipping import check for Cygwin-based "%s"' |
| 181 | % ext.name) |
| 182 | return |
Michael W. Hudson | af14289 | 2002-01-23 15:07:46 +0000 | [diff] [blame] | 183 | ext_filename = os.path.join( |
| 184 | self.build_lib, |
| 185 | self.get_ext_filename(self.get_ext_fullname(ext.name))) |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 186 | try: |
Michael W. Hudson | af14289 | 2002-01-23 15:07:46 +0000 | [diff] [blame] | 187 | imp.load_dynamic(ext.name, ext_filename) |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 188 | except ImportError, why: |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 189 | |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 190 | if 1: |
Michael W. Hudson | 7113d96 | 2002-03-01 14:16:31 +0000 | [diff] [blame] | 191 | self.announce('*** WARNING: renaming "%s" since importing it' |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 192 | ' failed: %s' % (ext.name, why)) |
| 193 | assert not self.inplace |
Michael W. Hudson | 7113d96 | 2002-03-01 14:16:31 +0000 | [diff] [blame] | 194 | basename, tail = os.path.splitext(ext_filename) |
| 195 | newname = basename + "_failed" + tail |
| 196 | if os.path.exists(newname): os.remove(newname) |
| 197 | os.rename(ext_filename, newname) |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 198 | |
| 199 | # XXX -- This relies on a Vile HACK in |
| 200 | # distutils.command.build_ext.build_extension(). The |
| 201 | # _built_objects attribute is stored there strictly for |
| 202 | # use here. |
Neal Norwitz | 03ffbcd | 2002-03-25 14:20:09 +0000 | [diff] [blame] | 203 | # If there is a failure, _built_objects may not be there, |
| 204 | # so catch the AttributeError and move on. |
| 205 | try: |
| 206 | for filename in self._built_objects: |
| 207 | os.remove(filename) |
| 208 | except AttributeError: |
| 209 | self.announce('unable to remove files (ignored)') |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 210 | else: |
| 211 | self.announce('*** WARNING: importing extension "%s" ' |
| 212 | 'failed: %s' % (ext.name, why)) |
Fred Drake | 9028d0a | 2001-12-06 22:59:54 +0000 | [diff] [blame] | 213 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 214 | def get_platform (self): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 215 | # Get value of sys.platform |
| 216 | platform = sys.platform |
| 217 | if platform[:6] =='cygwin': |
| 218 | platform = 'cygwin' |
Andrew M. Kuchling | 3c04494 | 2001-02-06 23:37:23 +0000 | [diff] [blame] | 219 | elif platform[:4] =='beos': |
| 220 | platform = 'beos' |
Jack Jansen | 244e761 | 2001-12-05 15:54:29 +0000 | [diff] [blame] | 221 | elif platform[:6] == 'darwin': |
| 222 | platform = 'darwin' |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 223 | elif platform[:6] == 'atheos': |
| 224 | platform = 'atheos' |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 225 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 226 | return platform |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 227 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 228 | def detect_modules(self): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 229 | # Ensure that /usr/local is always used |
Michael W. Hudson | 39230b3 | 2002-01-16 15:26:48 +0000 | [diff] [blame] | 230 | add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
| 231 | add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| 232 | |
| 233 | add_dir_to_list(self.compiler.library_dirs, |
| 234 | sysconfig.get_config_var("LIBDIR")) |
| 235 | add_dir_to_list(self.compiler.include_dirs, |
| 236 | sysconfig.get_config_var("INCLUDEDIR")) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 237 | |
Martin v. Löwis | 339d0f7 | 2001-08-17 18:39:25 +0000 | [diff] [blame] | 238 | try: |
| 239 | have_unicode = unicode |
| 240 | except NameError: |
| 241 | have_unicode = 0 |
| 242 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 243 | # lib_dirs and inc_dirs are used to search for files; |
| 244 | # if a file is found in one of those directories, it can |
| 245 | # be assumed that no additional -I,-L directives are needed. |
| 246 | lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib'] |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 247 | inc_dirs = self.compiler.include_dirs + ['/usr/include'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 248 | exts = [] |
| 249 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 250 | platform = self.get_platform() |
Martin v. Löwis | 8301256 | 2002-02-14 01:25:37 +0000 | [diff] [blame] | 251 | (srcdir,) = sysconfig.get_config_vars('srcdir') |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 252 | |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 253 | # Check for AtheOS which has libraries in non-standard locations |
| 254 | if platform == 'atheos': |
| 255 | lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] |
| 256 | lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) |
| 257 | inc_dirs += ['/system/include', '/atheos/autolnk/include'] |
| 258 | inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) |
| 259 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 260 | # Check for MacOS X, which doesn't need libm.a at all |
| 261 | math_libs = ['m'] |
Jack Jansen | 4439b7c | 2002-06-26 15:44:30 +0000 | [diff] [blame] | 262 | if platform in ['darwin', 'beos', 'mac']: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 263 | math_libs = [] |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 264 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 265 | # XXX Omitted modules: gl, pure, dl, SGI-specific modules |
| 266 | |
| 267 | # |
| 268 | # The following modules are all pretty straightforward, and compile |
| 269 | # on pretty much any POSIXish platform. |
| 270 | # |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 271 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 272 | # Some modules that are normally always on: |
| 273 | exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) ) |
| 274 | exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 275 | |
Fred Drake | 3a40f32 | 2001-10-12 21:00:48 +0000 | [diff] [blame] | 276 | exts.append( Extension('_hotshot', ['_hotshot.c']) ) |
Fred Drake | 2de7471 | 2001-02-01 05:26:54 +0000 | [diff] [blame] | 277 | exts.append( Extension('_weakref', ['_weakref.c']) ) |
Andrew M. Kuchling | d5c4306 | 2001-01-17 15:59:25 +0000 | [diff] [blame] | 278 | exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 279 | |
| 280 | # array objects |
| 281 | exts.append( Extension('array', ['arraymodule.c']) ) |
| 282 | # complex math library functions |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 283 | exts.append( Extension('cmath', ['cmathmodule.c'], |
| 284 | libraries=math_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 285 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 286 | # math library functions, e.g. sin() |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 287 | exts.append( Extension('math', ['mathmodule.c'], |
| 288 | libraries=math_libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 289 | # fast string operations implemented in C |
| 290 | exts.append( Extension('strop', ['stropmodule.c']) ) |
| 291 | # time operations and variables |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 292 | exts.append( Extension('time', ['timemodule.c'], |
| 293 | libraries=math_libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 294 | # operator.add() and similar goodies |
| 295 | exts.append( Extension('operator', ['operator.c']) ) |
| 296 | # access to the builtin codecs and codec registry |
| 297 | exts.append( Extension('_codecs', ['_codecsmodule.c']) ) |
Marc-André Lemburg | 261b8e2 | 2001-02-02 12:12:44 +0000 | [diff] [blame] | 298 | # Python C API test module |
Tim Peters | d66595f | 2001-02-04 03:09:53 +0000 | [diff] [blame] | 299 | exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 300 | # static Unicode character database |
Martin v. Löwis | 339d0f7 | 2001-08-17 18:39:25 +0000 | [diff] [blame] | 301 | if have_unicode: |
| 302 | exts.append( Extension('unicodedata', ['unicodedata.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 303 | # access to ISO C locale support |
| 304 | exts.append( Extension('_locale', ['_localemodule.c']) ) |
| 305 | |
| 306 | # Modules with some UNIX dependencies -- on by default: |
| 307 | # (If you have a really backward UNIX, select and socket may not be |
| 308 | # supported...) |
| 309 | |
| 310 | # fcntl(2) and ioctl(2) |
| 311 | exts.append( Extension('fcntl', ['fcntlmodule.c']) ) |
Jack Jansen | 73aa1ff | 2002-06-27 22:06:49 +0000 | [diff] [blame] | 312 | if platform not in ['mac']: |
| 313 | # pwd(3) |
| 314 | exts.append( Extension('pwd', ['pwdmodule.c']) ) |
| 315 | # grp(3) |
| 316 | exts.append( Extension('grp', ['grpmodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 317 | # posix (UNIX) errno values |
| 318 | exts.append( Extension('errno', ['errnomodule.c']) ) |
| 319 | # select(2); not on ancient System V |
| 320 | exts.append( Extension('select', ['selectmodule.c']) ) |
| 321 | |
| 322 | # The md5 module implements the RSA Data Security, Inc. MD5 |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 323 | # Message-Digest Algorithm, described in RFC 1321. The |
| 324 | # necessary files md5c.c and md5.h are included here. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 325 | exts.append( Extension('md5', ['md5module.c', 'md5c.c']) ) |
| 326 | |
| 327 | # The sha module implements the SHA checksum algorithm. |
| 328 | # (NIST's Secure Hash Algorithm.) |
| 329 | exts.append( Extension('sha', ['shamodule.c']) ) |
| 330 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 331 | # Helper module for various ascii-encoders |
| 332 | exts.append( Extension('binascii', ['binascii.c']) ) |
| 333 | |
| 334 | # Fred Drake's interface to the Python parser |
| 335 | exts.append( Extension('parser', ['parsermodule.c']) ) |
| 336 | |
Guido van Rossum | 2e1c09c | 2002-04-04 17:52:50 +0000 | [diff] [blame] | 337 | # cStringIO and cPickle |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 338 | exts.append( Extension('cStringIO', ['cStringIO.c']) ) |
| 339 | exts.append( Extension('cPickle', ['cPickle.c']) ) |
| 340 | |
| 341 | # Memory-mapped files (also works on Win32). |
Jack Jansen | 73aa1ff | 2002-06-27 22:06:49 +0000 | [diff] [blame] | 342 | if platform not in ['atheos', 'mac']: |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 343 | exts.append( Extension('mmap', ['mmapmodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 344 | |
| 345 | # Lance Ellinghaus's modules: |
| 346 | # enigma-inspired encryption |
| 347 | exts.append( Extension('rotor', ['rotormodule.c']) ) |
Jack Jansen | 73aa1ff | 2002-06-27 22:06:49 +0000 | [diff] [blame] | 348 | if platform not in ['mac']: |
| 349 | # syslog daemon interface |
| 350 | exts.append( Extension('syslog', ['syslogmodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 351 | |
| 352 | # George Neville-Neil's timing module: |
| 353 | exts.append( Extension('timing', ['timingmodule.c']) ) |
| 354 | |
| 355 | # |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 356 | # Here ends the simple stuff. From here on, modules need certain |
| 357 | # libraries, are platform-specific, or present other surprises. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 358 | # |
| 359 | |
| 360 | # Multimedia modules |
| 361 | # These don't work for 64-bit platforms!!! |
| 362 | # These represent audio samples or images as strings: |
| 363 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 364 | # Disabled on 64-bit platforms |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 365 | if sys.maxint != 9223372036854775807L: |
| 366 | # Operations on audio samples |
| 367 | exts.append( Extension('audioop', ['audioop.c']) ) |
| 368 | # Operations on images |
| 369 | exts.append( Extension('imageop', ['imageop.c']) ) |
| 370 | # Read SGI RGB image files (but coded portably) |
| 371 | exts.append( Extension('rgbimg', ['rgbimgmodule.c']) ) |
| 372 | |
| 373 | # readline |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 374 | if self.compiler.find_library_file(lib_dirs, 'readline'): |
| 375 | readline_libs = ['readline'] |
Andrew M. Kuchling | 5aa3c4a | 2001-08-16 20:30:18 +0000 | [diff] [blame] | 376 | if self.compiler.find_library_file(lib_dirs, |
| 377 | 'ncurses'): |
| 378 | readline_libs.append('ncurses') |
| 379 | elif self.compiler.find_library_file(lib_dirs + |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 380 | ['/usr/lib/termcap'], |
| 381 | 'termcap'): |
| 382 | readline_libs.append('termcap') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 383 | exts.append( Extension('readline', ['readline.c'], |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 384 | library_dirs=['/usr/lib/termcap'], |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 385 | libraries=readline_libs) ) |
Jack Jansen | 73aa1ff | 2002-06-27 22:06:49 +0000 | [diff] [blame] | 386 | if platform not in ['mac']: |
| 387 | # crypt module. |
| 388 | |
| 389 | if self.compiler.find_library_file(lib_dirs, 'crypt'): |
| 390 | libs = ['crypt'] |
| 391 | else: |
| 392 | libs = [] |
| 393 | exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 394 | |
| 395 | # socket(2) |
Guido van Rossum | 47d3a7a | 2002-06-13 14:41:32 +0000 | [diff] [blame] | 396 | exts.append( Extension('_socket', ['socketmodule.c'], |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 397 | depends = ['socketmodule.h']) ) |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 398 | # Detect SSL support for the socket module (via _ssl) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 399 | ssl_incs = find_file('openssl/ssl.h', inc_dirs, |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 400 | ['/usr/local/ssl/include', |
| 401 | '/usr/contrib/ssl/include/' |
| 402 | ] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 403 | ) |
| 404 | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 405 | ['/usr/local/ssl/lib', |
| 406 | '/usr/contrib/ssl/lib/' |
| 407 | ] ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 408 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 409 | if (ssl_incs is not None and |
| 410 | ssl_libs is not None): |
Marc-André Lemburg | a5d2b4c | 2002-02-16 18:23:30 +0000 | [diff] [blame] | 411 | exts.append( Extension('_ssl', ['_ssl.c'], |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 412 | include_dirs = ssl_incs, |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 413 | library_dirs = ssl_libs, |
Guido van Rossum | 47d3a7a | 2002-06-13 14:41:32 +0000 | [diff] [blame] | 414 | libraries = ['ssl', 'crypto'], |
Jeremy Hylton | 340043e | 2002-06-13 17:38:11 +0000 | [diff] [blame] | 415 | depends = ['socketmodule.h']), ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 416 | |
| 417 | # Modules that provide persistent dictionary-like semantics. You will |
| 418 | # probably want to arrange for at least one of them to be available on |
| 419 | # your machine, though none are defined by default because of library |
| 420 | # dependencies. The Python module anydbm.py provides an |
| 421 | # implementation independent wrapper for these; dumbdbm.py provides |
| 422 | # similar functionality (but slower of course) implemented in Python. |
| 423 | |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 424 | # Berkeley DB interface. |
| 425 | # |
| 426 | # This requires the Berkeley DB code, see |
| 427 | # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz |
| 428 | # |
| 429 | # (See http://pybsddb.sourceforge.net/ for an interface to |
| 430 | # Berkeley DB 3.x.) |
| 431 | |
| 432 | # when sorted in reverse order, keys for this dict must appear in the |
| 433 | # order you wish to search - e.g., search for db3 before db2, db2 |
| 434 | # before db1 |
| 435 | db_try_this = { |
| 436 | 'db4': {'libs': ('db-4.3', 'db-4.2', 'db-4.1', 'db-4.0'), |
| 437 | 'libdirs': ('/usr/local/BerkeleyDB.4.3/lib', |
| 438 | '/usr/local/BerkeleyDB.4.2/lib', |
| 439 | '/usr/local/BerkeleyDB.4.1/lib', |
| 440 | '/usr/local/BerkeleyDB.4.0/lib', |
| 441 | '/usr/lib', |
| 442 | '/opt/sfw', |
| 443 | '/sw/lib', |
| 444 | '/lib', |
| 445 | ), |
| 446 | 'incdirs': ('/usr/local/BerkeleyDB.4.3/include', |
| 447 | '/usr/local/BerkeleyDB.4.2/include', |
| 448 | '/usr/local/BerkeleyDB.4.1/include', |
| 449 | '/usr/local/BerkeleyDB.4.0/include', |
| 450 | '/usr/include/db3', |
| 451 | '/opt/sfw/include/db3', |
| 452 | '/sw/include/db3', |
| 453 | '/usr/local/include/db3', |
| 454 | ), |
| 455 | 'incs': ('db_185.h',)}, |
| 456 | 'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db-3.0'), |
| 457 | 'libdirs': ('/usr/local/BerkeleyDB.3.3/lib', |
| 458 | '/usr/local/BerkeleyDB.3.2/lib', |
| 459 | '/usr/local/BerkeleyDB.3.1/lib', |
| 460 | '/usr/local/BerkeleyDB.3.0/lib', |
| 461 | '/usr/lib', |
| 462 | '/opt/sfw', |
| 463 | '/sw/lib', |
| 464 | '/lib', |
| 465 | ), |
| 466 | 'incdirs': ('/usr/local/BerkeleyDB.3.3/include', |
| 467 | '/usr/local/BerkeleyDB.3.2/include', |
| 468 | '/usr/local/BerkeleyDB.3.1/include', |
| 469 | '/usr/local/BerkeleyDB.3.0/include', |
| 470 | '/usr/include/db3', |
| 471 | '/opt/sfw/include/db3', |
| 472 | '/sw/include/db3', |
| 473 | '/usr/local/include/db3', |
| 474 | ), |
| 475 | 'incs': ('db_185.h',)}, |
| 476 | 'db2': {'libs': ('db2',), |
| 477 | 'libdirs': ('/usr/lib', '/sw/lib', '/lib'), |
| 478 | 'incdirs': ('/usr/include/db2', |
| 479 | '/usr/local/include/db2', '/sw/include/db2'), |
| 480 | 'incs': ('db_185.h',)}, |
| 481 | # if you are willing to risk hash db file corruption you can |
| 482 | # uncomment the lines below for db1. Note that this will affect |
| 483 | # not only the bsddb module, but the dbhash and anydbm modules |
| 484 | # as well. you have been warned!!! |
| 485 | ##'db1': {'libs': ('db1', 'db'), |
| 486 | ## 'libdirs': ('/usr/lib', '/sw/lib', '/lib'), |
| 487 | ## 'incdirs': ('/usr/include/db1', '/usr/local/include/db1', |
| 488 | ## '/usr/include', '/usr/local/include'), |
| 489 | ## 'incs': ('db.h',)}, |
| 490 | } |
| 491 | |
| 492 | # override this list to affect the library version search order |
| 493 | # for example, if you want to force version 2 to be used: |
| 494 | # db_search_order = ["db2"] |
| 495 | db_search_order = db_try_this.keys() |
| 496 | db_search_order.sort() |
| 497 | db_search_order.reverse() |
| 498 | |
| 499 | find_lib_file = self.compiler.find_library_file |
| 500 | class found(Exception): pass |
| 501 | try: |
| 502 | for dbkey in db_search_order: |
| 503 | dbd = db_try_this[dbkey] |
| 504 | for dblib in dbd['libs']: |
| 505 | for dbinc in dbd['incs']: |
| 506 | db_incs = find_file(dbinc, [], dbd['incdirs']) |
| 507 | dblib_dir = find_lib_file(dbd['libdirs'], dblib) |
| 508 | if db_incs and dblib_dir: |
| 509 | dblib_dir = os.path.dirname(dblib_dir) |
| 510 | dblibs = [dblib] |
| 511 | raise found |
| 512 | except found: |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 513 | dblibs = [dblib] |
Barry Warsaw | 6fe3d70 | 2002-06-24 20:27:33 +0000 | [diff] [blame] | 514 | # A default source build puts Berkeley DB in something like |
| 515 | # /usr/local/Berkeley.3.3 and the lib dir under that isn't |
| 516 | # normally on ld.so's search path, unless the sysadmin has hacked |
| 517 | # /etc/ld.so.conf. We add the directory to runtime_library_dirs |
| 518 | # so the proper -R/--rpath flags get passed to the linker. This |
| 519 | # is usually correct and most trouble free, but may cause problems |
| 520 | # in some unusual system configurations (e.g. the directory is on |
| 521 | # an NFS server that goes away). |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 522 | if dbinc == 'db_185.h': |
| 523 | exts.append(Extension('bsddb', ['bsddbmodule.c'], |
| 524 | library_dirs=[dblib_dir], |
Barry Warsaw | 6fe3d70 | 2002-06-24 20:27:33 +0000 | [diff] [blame] | 525 | runtime_library_dirs=[dblib_dir], |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 526 | include_dirs=db_incs, |
| 527 | define_macros=[('HAVE_DB_185_H',1)], |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 528 | libraries=dblibs)) |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 529 | else: |
| 530 | exts.append(Extension('bsddb', ['bsddbmodule.c'], |
| 531 | library_dirs=[dblib_dir], |
Barry Warsaw | 6fe3d70 | 2002-06-24 20:27:33 +0000 | [diff] [blame] | 532 | runtime_library_dirs=[dblib_dir], |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 533 | include_dirs=db_incs, |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 534 | libraries=dblibs)) |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 535 | else: |
| 536 | db_incs = None |
| 537 | dblibs = [] |
| 538 | dblib_dir = None |
| 539 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 540 | # The standard Unix dbm module: |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 541 | if platform not in ['cygwin']: |
| 542 | if (self.compiler.find_library_file(lib_dirs, 'ndbm') |
| 543 | and find_file("ndbm.h", inc_dirs, []) is not None): |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 544 | exts.append( Extension('dbm', ['dbmmodule.c'], |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 545 | define_macros=[('HAVE_NDBM_H',None)], |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 546 | libraries = ['ndbm'] ) ) |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 547 | elif (platform in ['darwin'] |
| 548 | and find_file("ndbm.h", inc_dirs, []) is not None): |
| 549 | # Darwin has ndbm in libc |
Neil Schemenauer | c3ffef6 | 2001-10-21 22:14:44 +0000 | [diff] [blame] | 550 | exts.append( Extension('dbm', ['dbmmodule.c'], |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 551 | define_macros=[('HAVE_NDBM_H',None)]) ) |
| 552 | elif (self.compiler.find_library_file(lib_dirs, 'gdbm') |
| 553 | and find_file("gdbm/ndbm.h", inc_dirs, []) is not None): |
| 554 | exts.append( Extension('dbm', ['dbmmodule.c'], |
| 555 | define_macros=[('HAVE_GDBM_NDBM_H',None)], |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 556 | libraries = ['gdbm'] ) ) |
| 557 | elif db_incs is not None: |
| 558 | exts.append( Extension('dbm', ['dbmmodule.c'], |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 559 | library_dirs=[dblib_dir], |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 560 | include_dirs=db_incs, |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 561 | define_macros=[('HAVE_BERKDB_H',None), |
| 562 | ('DB_DBM_HSEARCH',None)], |
Skip Montanaro | 57454e5 | 2002-06-14 20:30:31 +0000 | [diff] [blame] | 563 | libraries=dblibs)) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 564 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 565 | # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: |
| 566 | if (self.compiler.find_library_file(lib_dirs, 'gdbm')): |
| 567 | exts.append( Extension('gdbm', ['gdbmmodule.c'], |
| 568 | libraries = ['gdbm'] ) ) |
| 569 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 570 | # The mpz module interfaces to the GNU Multiple Precision library. |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 571 | # You need to ftp the GNU MP library. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 572 | # This was originally written and tested against GMP 1.2 and 1.3.2. |
| 573 | # It has been modified by Rob Hooft to work with 2.0.2 as well, but I |
Guido van Rossum | 8efd6ce | 2001-12-17 17:24:43 +0000 | [diff] [blame] | 574 | # haven't tested it recently, and it definitely doesn't work with |
| 575 | # GMP 4.0. For more complete modules, refer to |
| 576 | # http://gmpy.sourceforge.net and |
| 577 | # http://www.egenix.com/files/python/mxNumber.html |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 578 | |
Greg Ward | 57fc210 | 2001-10-03 19:59:30 +0000 | [diff] [blame] | 579 | # A compatible MP library unencumbered by the GPL also exists. It was |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 580 | # posted to comp.sources.misc in volume 40 and is widely available from |
| 581 | # FTP archive sites. One URL for it is: |
| 582 | # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z |
| 583 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 584 | if (self.compiler.find_library_file(lib_dirs, 'gmp')): |
| 585 | exts.append( Extension('mpz', ['mpzmodule.c'], |
| 586 | libraries = ['gmp'] ) ) |
| 587 | |
| 588 | |
| 589 | # Unix-only modules |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 590 | if platform not in ['mac', 'win32']: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 591 | # Steen Lumholt's termios module |
| 592 | exts.append( Extension('termios', ['termios.c']) ) |
| 593 | # Jeremy Hylton's rlimit interface |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 594 | if platform not in ['atheos']: |
| 595 | exts.append( Extension('resource', ['resource.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 596 | |
Andrew M. Kuchling | cf393f3 | 2001-02-21 02:38:24 +0000 | [diff] [blame] | 597 | # Sun yellow pages. Some systems have the functions in libc. |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 598 | if platform not in ['cygwin', 'atheos']: |
Andrew M. Kuchling | 6efc6e7 | 2001-02-27 20:54:23 +0000 | [diff] [blame] | 599 | if (self.compiler.find_library_file(lib_dirs, 'nsl')): |
| 600 | libs = ['nsl'] |
| 601 | else: |
| 602 | libs = [] |
| 603 | exts.append( Extension('nis', ['nismodule.c'], |
| 604 | libraries = libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 605 | |
| 606 | # Curses support, requring the System V version of curses, often |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 607 | # provided by the ncurses library. |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 608 | if platform == 'sunos4': |
Andrew M. Kuchling | b69c758 | 2001-02-28 19:49:57 +0000 | [diff] [blame] | 609 | inc_dirs += ['/usr/5include'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 610 | lib_dirs += ['/usr/5lib'] |
| 611 | |
| 612 | if (self.compiler.find_library_file(lib_dirs, 'ncurses')): |
| 613 | curses_libs = ['ncurses'] |
| 614 | exts.append( Extension('_curses', ['_cursesmodule.c'], |
| 615 | libraries = curses_libs) ) |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 616 | elif (self.compiler.find_library_file(lib_dirs, 'curses') |
| 617 | and platform != 'darwin'): |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 618 | # OSX has an old Berkeley curses, not good enough for |
| 619 | # the _curses module. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 620 | if (self.compiler.find_library_file(lib_dirs, 'terminfo')): |
| 621 | curses_libs = ['curses', 'terminfo'] |
| 622 | else: |
| 623 | curses_libs = ['curses', 'termcap'] |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 624 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 625 | exts.append( Extension('_curses', ['_cursesmodule.c'], |
| 626 | libraries = curses_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 627 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 628 | # If the curses module is enabled, check for the panel module |
Andrew M. Kuchling | e7ffbb2 | 2001-12-06 15:57:16 +0000 | [diff] [blame] | 629 | if (module_enabled(exts, '_curses') and |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 630 | self.compiler.find_library_file(lib_dirs, 'panel')): |
| 631 | exts.append( Extension('_curses_panel', ['_curses_panel.c'], |
| 632 | libraries = ['panel'] + curses_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 633 | |
| 634 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 635 | |
| 636 | # Lee Busby's SIGFPE modules. |
| 637 | # The library to link fpectl with is platform specific. |
| 638 | # Choose *one* of the options below for fpectl: |
| 639 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 640 | if platform == 'irix5': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 641 | # For SGI IRIX (tested on 5.3): |
| 642 | exts.append( Extension('fpectl', ['fpectlmodule.c'], |
| 643 | libraries=['fpe']) ) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 644 | elif 0: # XXX how to detect SunPro? |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 645 | # For Solaris with SunPro compiler (tested on Solaris 2.5 |
| 646 | # with SunPro C 4.2): (Without the compiler you don't have |
| 647 | # -lsunmath.) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 648 | #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm |
| 649 | pass |
| 650 | else: |
| 651 | # For other systems: see instructions in fpectlmodule.c. |
| 652 | #fpectl fpectlmodule.c ... |
| 653 | exts.append( Extension('fpectl', ['fpectlmodule.c']) ) |
| 654 | |
| 655 | |
| 656 | # Andrew Kuchling's zlib module. |
| 657 | # This require zlib 1.1.3 (or later). |
| 658 | # See http://www.cdrom.com/pub/infozip/zlib/ |
Guido van Rossum | e697091 | 2001-04-15 15:16:12 +0000 | [diff] [blame] | 659 | zlib_inc = find_file('zlib.h', [], inc_dirs) |
| 660 | if zlib_inc is not None: |
| 661 | zlib_h = zlib_inc[0] + '/zlib.h' |
| 662 | version = '"0.0.0"' |
| 663 | version_req = '"1.1.3"' |
| 664 | fp = open(zlib_h) |
| 665 | while 1: |
| 666 | line = fp.readline() |
| 667 | if not line: |
| 668 | break |
| 669 | if line.find('#define ZLIB_VERSION', 0) == 0: |
| 670 | version = line.split()[2] |
| 671 | break |
| 672 | if version >= version_req: |
| 673 | if (self.compiler.find_library_file(lib_dirs, 'z')): |
| 674 | exts.append( Extension('zlib', ['zlibmodule.c'], |
| 675 | libraries = ['z']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 676 | |
| 677 | # Interface to the Expat XML parser |
| 678 | # |
Fred Drake | fc8341d | 2002-06-17 17:55:30 +0000 | [diff] [blame] | 679 | # Expat was written by James Clark and is now maintained by a |
| 680 | # group of developers on SourceForge; see www.libexpat.org for |
| 681 | # more information. The pyexpat module was written by Paul |
| 682 | # Prescod after a prototype by Jack Jansen. Source of Expat |
| 683 | # 1.95.2 is included in Modules/expat/. Usage of a system |
| 684 | # shared libexpat.so/expat.dll is not advised. |
| 685 | # |
| 686 | # More information on Expat can be found at www.libexpat.org. |
| 687 | # |
Martin v. Löwis | cf453fe | 2002-02-11 23:27:45 +0000 | [diff] [blame] | 688 | if sys.byteorder == "little": |
| 689 | xmlbo = "12" |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 690 | else: |
Martin v. Löwis | cf453fe | 2002-02-11 23:27:45 +0000 | [diff] [blame] | 691 | xmlbo = "21" |
Martin v. Löwis | 8301256 | 2002-02-14 01:25:37 +0000 | [diff] [blame] | 692 | expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') |
Martin v. Löwis | cf453fe | 2002-02-11 23:27:45 +0000 | [diff] [blame] | 693 | exts.append(Extension('pyexpat', |
| 694 | sources = [ |
| 695 | 'pyexpat.c', |
| 696 | 'expat/xmlparse.c', |
| 697 | 'expat/xmlrole.c', |
| 698 | 'expat/xmltok.c', |
| 699 | ], |
| 700 | define_macros = [ |
| 701 | ('HAVE_EXPAT_H',None), |
Martin v. Löwis | cf453fe | 2002-02-11 23:27:45 +0000 | [diff] [blame] | 702 | ('XML_NS', '1'), |
| 703 | ('XML_DTD', '1'), |
| 704 | ('XML_BYTE_ORDER', xmlbo), |
| 705 | ('XML_CONTEXT_BYTES','1024'), |
| 706 | ], |
Martin v. Löwis | 8301256 | 2002-02-14 01:25:37 +0000 | [diff] [blame] | 707 | include_dirs = [expatinc] |
Martin v. Löwis | cf453fe | 2002-02-11 23:27:45 +0000 | [diff] [blame] | 708 | )) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 709 | |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 710 | # Dynamic loading module |
Martin v. Löwis | 9322727 | 2002-01-01 20:18:30 +0000 | [diff] [blame] | 711 | dl_inc = find_file('dlfcn.h', [], inc_dirs) |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 712 | if (dl_inc is not None) and (platform not in ['atheos']): |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 713 | exts.append( Extension('dl', ['dlmodule.c']) ) |
| 714 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 715 | # Platform-specific libraries |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 716 | if platform == 'linux2': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 717 | # Linux-specific modules |
| 718 | exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) |
| 719 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 720 | if platform == 'sunos5': |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 721 | # SunOS specific modules |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 722 | exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 723 | |
Jack Jansen | 244e761 | 2001-12-05 15:54:29 +0000 | [diff] [blame] | 724 | if platform == 'darwin': |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 725 | # Mac OS X specific modules. Modules linked against the Carbon |
| 726 | # framework are only built for framework-enabled Pythons. As |
| 727 | # of MacOSX 10.1 importing the Carbon framework from a non-windowing |
| 728 | # application (MacOSX server, not logged in on the console) may |
| 729 | # result in Python crashing. |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 730 | # |
| 731 | # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't |
| 732 | # available here. This Makefile variable is also what the install |
| 733 | # procedure triggers on. |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 734 | exts.append( Extension('_CF', ['cf/_CFmodule.c', 'cf/pycfbridge.c'], |
Michael W. Hudson | 0c46c0c | 2002-03-07 09:58:56 +0000 | [diff] [blame] | 735 | extra_link_args=['-framework', 'CoreFoundation']) ) |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 736 | |
| 737 | framework = sysconfig.get_config_var('PYTHONFRAMEWORK') |
| 738 | if framework: |
| 739 | exts.append( Extension('gestalt', ['gestaltmodule.c'], |
| 740 | extra_link_args=['-framework', 'Carbon']) ) |
| 741 | exts.append( Extension('MacOS', ['macosmodule.c'], |
| 742 | extra_link_args=['-framework', 'Carbon']) ) |
| 743 | exts.append( Extension('icglue', ['icgluemodule.c'], |
| 744 | extra_link_args=['-framework', 'Carbon']) ) |
| 745 | exts.append( Extension('macfs', |
| 746 | ['macfsmodule.c', |
| 747 | '../Python/getapplbycreator.c'], |
| 748 | extra_link_args=['-framework', 'Carbon']) ) |
| 749 | exts.append( Extension('_Res', ['res/_Resmodule.c'], |
| 750 | extra_link_args=['-framework', 'Carbon']) ) |
| 751 | exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], |
| 752 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 753 | exts.append( Extension('Nav', ['Nav.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 754 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 755 | exts.append( Extension('_AE', ['ae/_AEmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 756 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 757 | exts.append( Extension('_App', ['app/_Appmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 758 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | dd67a8e | 2001-12-12 23:03:17 +0000 | [diff] [blame] | 759 | exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 760 | extra_link_args=['-framework', 'Carbon']) ) |
Just van Rossum | e9039b1 | 2001-12-13 13:41:36 +0000 | [diff] [blame] | 761 | exts.append( Extension('_CG', ['cg/_CGmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 762 | extra_link_args=['-framework', 'ApplicationServices', |
Just van Rossum | e9039b1 | 2001-12-13 13:41:36 +0000 | [diff] [blame] | 763 | '-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 764 | exts.append( Extension('_Cm', ['cm/_Cmmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 765 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 766 | exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 767 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 768 | exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 769 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 770 | exts.append( Extension('_Drag', ['drag/_Dragmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 771 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 772 | exts.append( Extension('_Evt', ['evt/_Evtmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 773 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 774 | exts.append( Extension('_Fm', ['fm/_Fmmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 775 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 776 | exts.append( Extension('_Icn', ['icn/_Icnmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 777 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 778 | exts.append( Extension('_List', ['list/_Listmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 779 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 780 | exts.append( Extension('_Menu', ['menu/_Menumodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 781 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 782 | exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 783 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 784 | exts.append( Extension('_Qd', ['qd/_Qdmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 785 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 786 | exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 787 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 788 | exts.append( Extension('_Qt', ['qt/_Qtmodule.c'], |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 789 | extra_link_args=['-framework', 'QuickTime', |
| 790 | '-framework', 'Carbon']) ) |
Jack Jansen | 796720b | 2002-01-21 23:10:36 +0000 | [diff] [blame] | 791 | exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 792 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 793 | exts.append( Extension('_TE', ['te/_TEmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 794 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 795 | # As there is no standardized place (yet) to put |
| 796 | # user-installed Mac libraries on OSX, we search for "waste" |
| 797 | # in parent directories of the Python source tree. You |
| 798 | # should put a symlink to your Waste installation in the |
| 799 | # same folder as your python source tree. Or modify the |
| 800 | # next few lines:-) |
| 801 | waste_incs = find_file("WASTE.h", [], |
| 802 | ['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)]) |
Jack Jansen | edeea04 | 2001-12-09 23:08:54 +0000 | [diff] [blame] | 803 | waste_libs = find_library_file(self.compiler, "WASTE", [], |
Jack Jansen | d1b2045 | 2002-07-08 21:39:36 +0000 | [diff] [blame] | 804 | [ "../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)]) |
Jack Jansen | edeea04 | 2001-12-09 23:08:54 +0000 | [diff] [blame] | 805 | if waste_incs != None and waste_libs != None: |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 806 | (srcdir,) = sysconfig.get_config_vars('srcdir') |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 807 | exts.append( Extension('waste', |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 808 | ['waste/wastemodule.c'] + [ |
| 809 | os.path.join(srcdir, d) for d in |
Jack Jansen | edeea04 | 2001-12-09 23:08:54 +0000 | [diff] [blame] | 810 | 'Mac/Wastemods/WEObjectHandlers.c', |
| 811 | 'Mac/Wastemods/WETabHooks.c', |
| 812 | 'Mac/Wastemods/WETabs.c' |
| 813 | ], |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 814 | include_dirs = waste_incs + [os.path.join(srcdir, 'Mac/Wastemods')], |
Jack Jansen | edeea04 | 2001-12-09 23:08:54 +0000 | [diff] [blame] | 815 | library_dirs = waste_libs, |
| 816 | libraries = ['WASTE'], |
| 817 | extra_link_args = ['-framework', 'Carbon'], |
| 818 | ) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 819 | exts.append( Extension('_Win', ['win/_Winmodule.c'], |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 820 | extra_link_args=['-framework', 'Carbon']) ) |
| 821 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 822 | self.extensions.extend(exts) |
| 823 | |
| 824 | # Call the method for detecting whether _tkinter can be compiled |
| 825 | self.detect_tkinter(inc_dirs, lib_dirs) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 826 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 827 | def detect_tkinter_darwin(self, inc_dirs, lib_dirs): |
| 828 | # The _tkinter module, using frameworks. Since frameworks are quite |
| 829 | # different the UNIX search logic is not sharable. |
| 830 | from os.path import join, exists |
| 831 | framework_dirs = [ |
| 832 | '/System/Library/Frameworks/', |
| 833 | '/Library/Frameworks', |
| 834 | join(os.getenv('HOME'), '/Library/Frameworks') |
| 835 | ] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 836 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 837 | # Find the directory that contains the Tcl.framwork and Tk.framework |
| 838 | # bundles. |
| 839 | # XXX distutils should support -F! |
| 840 | for F in framework_dirs: |
| 841 | # both Tcl.framework and Tk.framework should be present |
| 842 | for fw in 'Tcl', 'Tk': |
| 843 | if not exists(join(F, fw + '.framework')): |
| 844 | break |
| 845 | else: |
| 846 | # ok, F is now directory with both frameworks. Continure |
| 847 | # building |
| 848 | break |
| 849 | else: |
| 850 | # Tk and Tcl frameworks not found. Normal "unix" tkinter search |
| 851 | # will now resume. |
| 852 | return 0 |
| 853 | |
| 854 | # For 8.4a2, we must add -I options that point inside the Tcl and Tk |
| 855 | # frameworks. In later release we should hopefully be able to pass |
| 856 | # the -F option to gcc, which specifies a framework lookup path. |
| 857 | # |
| 858 | include_dirs = [ |
| 859 | join(F, fw + '.framework', H) |
| 860 | for fw in 'Tcl', 'Tk' |
| 861 | for H in 'Headers', 'Versions/Current/PrivateHeaders' |
| 862 | ] |
| 863 | |
| 864 | # For 8.4a2, the X11 headers are not included. Rather than include a |
| 865 | # complicated search, this is a hard-coded path. It could bail out |
| 866 | # if X11 libs are not found... |
| 867 | include_dirs.append('/usr/X11R6/include') |
| 868 | frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] |
| 869 | |
| 870 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 871 | define_macros=[('WITH_APPINIT', 1)], |
| 872 | include_dirs = include_dirs, |
| 873 | libraries = [], |
| 874 | extra_compile_args = frameworks, |
| 875 | extra_link_args = frameworks, |
| 876 | ) |
| 877 | self.extensions.append(ext) |
| 878 | return 1 |
| 879 | |
| 880 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 881 | def detect_tkinter(self, inc_dirs, lib_dirs): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 882 | # The _tkinter module. |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 883 | |
Jack Jansen | 0b06be7 | 2002-06-21 14:48:38 +0000 | [diff] [blame] | 884 | # Rather than complicate the code below, detecting and building |
| 885 | # AquaTk is a separate method. Only one Tkinter will be built on |
| 886 | # Darwin - either AquaTk, if it is found, or X11 based Tk. |
| 887 | platform = self.get_platform() |
| 888 | if platform == 'darwin' and \ |
| 889 | self.detect_tkinter_darwin(inc_dirs, lib_dirs): |
| 890 | return |
| 891 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 892 | # Assume we haven't found any of the libraries or include files |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 893 | # The versions with dots are used on Unix, and the versions without |
| 894 | # dots on Windows, for detection by cygwin. |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 895 | tcllib = tklib = tcl_includes = tk_includes = None |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 896 | for version in ['8.4', '84', '8.3', '83', '8.2', |
| 897 | '82', '8.1', '81', '8.0', '80']: |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 898 | tklib = self.compiler.find_library_file(lib_dirs, |
| 899 | 'tk' + version ) |
| 900 | tcllib = self.compiler.find_library_file(lib_dirs, |
| 901 | 'tcl' + version ) |
| 902 | if tklib and tcllib: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 903 | # Exit the loop when we've found the Tcl/Tk libraries |
| 904 | break |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 905 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 906 | # Now check for the header files |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 907 | if tklib and tcllib: |
| 908 | # Check for the include files on Debian, where |
| 909 | # they're put in /usr/include/{tcl,tk}X.Y |
Andrew M. Kuchling | 9a3fd8c | 2001-02-06 22:15:27 +0000 | [diff] [blame] | 910 | debian_tcl_include = [ '/usr/include/tcl' + version ] |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 911 | debian_tk_include = [ '/usr/include/tk' + version ] + \ |
| 912 | debian_tcl_include |
Andrew M. Kuchling | 9a3fd8c | 2001-02-06 22:15:27 +0000 | [diff] [blame] | 913 | tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) |
| 914 | tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 915 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 916 | if (tcllib is None or tklib is None and |
| 917 | tcl_includes is None or tk_includes is None): |
| 918 | # Something's missing, so give up |
| 919 | return |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 920 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 921 | # OK... everything seems to be present for Tcl/Tk. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 922 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 923 | include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] |
| 924 | for dir in tcl_includes + tk_includes: |
| 925 | if dir not in include_dirs: |
| 926 | include_dirs.append(dir) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 927 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 928 | # Check for various platform-specific directories |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 929 | if platform == 'sunos5': |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 930 | include_dirs.append('/usr/openwin/include') |
| 931 | added_lib_dirs.append('/usr/openwin/lib') |
| 932 | elif os.path.exists('/usr/X11R6/include'): |
| 933 | include_dirs.append('/usr/X11R6/include') |
| 934 | added_lib_dirs.append('/usr/X11R6/lib') |
| 935 | elif os.path.exists('/usr/X11R5/include'): |
| 936 | include_dirs.append('/usr/X11R5/include') |
| 937 | added_lib_dirs.append('/usr/X11R5/lib') |
| 938 | else: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 939 | # Assume default location for X11 |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 940 | include_dirs.append('/usr/X11/include') |
| 941 | added_lib_dirs.append('/usr/X11/lib') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 942 | |
Andrew M. Kuchling | 89fb72d | 2001-09-18 20:32:13 +0000 | [diff] [blame] | 943 | # If Cygwin, then verify that X is installed before proceeding |
| 944 | if platform == 'cygwin': |
| 945 | x11_inc = find_file('X11/Xlib.h', [], inc_dirs) |
| 946 | if x11_inc is None: |
| 947 | # X header files missing, so give up |
| 948 | return |
| 949 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 950 | # Check for BLT extension |
Fred Drake | 38419c0 | 2001-12-06 22:24:47 +0000 | [diff] [blame] | 951 | if self.compiler.find_library_file(lib_dirs + added_lib_dirs, |
| 952 | 'BLT8.0'): |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 953 | defs.append( ('WITH_BLT', 1) ) |
| 954 | libs.append('BLT8.0') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 955 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 956 | # Add the Tcl/Tk libraries |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 957 | libs.append('tk'+version) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 958 | libs.append('tcl'+version) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 959 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 960 | if platform in ['aix3', 'aix4']: |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 961 | libs.append('ld') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 962 | |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 963 | # Finally, link with the X11 libraries (not appropriate on cygwin) |
| 964 | if platform != "cygwin": |
| 965 | libs.append('X11') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 966 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 967 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 968 | define_macros=[('WITH_APPINIT', 1)] + defs, |
| 969 | include_dirs = include_dirs, |
| 970 | libraries = libs, |
| 971 | library_dirs = added_lib_dirs, |
| 972 | ) |
| 973 | self.extensions.append(ext) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 974 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 975 | # XXX handle these, but how to detect? |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 976 | # *** Uncomment and edit for PIL (TkImaging) extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 977 | # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 978 | # *** Uncomment and edit for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 979 | # -DWITH_TOGL togl.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 980 | # *** Uncomment these for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 981 | # -lGL -lGLU -lXext -lXmu \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 982 | |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 983 | class PyBuildInstall(install): |
| 984 | # Suppress the warning about installation into the lib_dynload |
| 985 | # directory, which is not in sys.path when running Python during |
| 986 | # installation: |
| 987 | def initialize_options (self): |
| 988 | install.initialize_options(self) |
| 989 | self.warn_dir=0 |
Michael W. Hudson | 5b10910 | 2002-01-23 15:04:41 +0000 | [diff] [blame] | 990 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 991 | def main(): |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 992 | # turn off warnings when deprecated modules are imported |
| 993 | import warnings |
| 994 | warnings.filterwarnings("ignore",category=DeprecationWarning) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 995 | setup(name = 'Python standard library', |
Neil Schemenauer | e7e2ece | 2001-01-17 21:58:00 +0000 | [diff] [blame] | 996 | version = '%d.%d' % sys.version_info[:2], |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 997 | cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall}, |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 998 | # The struct module is defined here, because build_ext won't be |
| 999 | # called unless there's at least one extension module defined. |
Andrew M. Kuchling | aece427 | 2001-02-28 20:56:49 +0000 | [diff] [blame] | 1000 | ext_modules=[Extension('struct', ['structmodule.c'])], |
| 1001 | |
| 1002 | # Scripts to install |
| 1003 | scripts = ['Tools/scripts/pydoc'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1004 | ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 1005 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1006 | # --install-platlib |
| 1007 | if __name__ == '__main__': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 1008 | main() |