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 | |
| 6 | import sys, os, getopt |
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 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 17 | def find_file(filename, std_dirs, paths): |
| 18 | """Searches for the directory where a given file is located, |
| 19 | and returns a possibly-empty list of additional directories, or None |
| 20 | if the file couldn't be found at all. |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 21 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 22 | 'filename' is the name of a file, such as readline.h or libcrypto.a. |
| 23 | 'std_dirs' is the list of standard system directories; if the |
| 24 | file is found in one of them, no additional directives are needed. |
| 25 | 'paths' is a list of additional locations to check; if the file is |
| 26 | found in one of them, the resulting list will contain the directory. |
| 27 | """ |
| 28 | |
| 29 | # Check the standard locations |
| 30 | for dir in std_dirs: |
| 31 | f = os.path.join(dir, filename) |
| 32 | if os.path.exists(f): return [] |
| 33 | |
| 34 | # Check the additional directories |
| 35 | for dir in paths: |
| 36 | f = os.path.join(dir, filename) |
| 37 | if os.path.exists(f): |
| 38 | return [dir] |
| 39 | |
| 40 | # Not found anywhere |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 41 | return None |
| 42 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 43 | def find_library_file(compiler, libname, std_dirs, paths): |
| 44 | filename = compiler.library_filename(libname, lib_type='shared') |
| 45 | result = find_file(filename, std_dirs, paths) |
| 46 | if result is not None: return result |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 47 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 48 | filename = compiler.library_filename(libname, lib_type='static') |
| 49 | result = find_file(filename, std_dirs, paths) |
| 50 | return result |
| 51 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 52 | def module_enabled(extlist, modname): |
| 53 | """Returns whether the module 'modname' is present in the list |
| 54 | of extensions 'extlist'.""" |
| 55 | extlist = [ext for ext in extlist if ext.name == modname] |
| 56 | return len(extlist) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 57 | |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 58 | def find_module_file(module, dirlist): |
| 59 | """Find a module in a set of possible folders. If it is not found |
| 60 | return the unadorned filename""" |
| 61 | list = find_file(module, [], dirlist) |
| 62 | if not list: |
| 63 | return module |
| 64 | if len(list) > 1: |
| 65 | self.announce("WARNING: multiple copies of %s found"%module) |
| 66 | return os.path.join(list[0], module) |
| 67 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 68 | class PyBuildExt(build_ext): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 69 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 70 | def build_extensions(self): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 71 | |
| 72 | # Detect which modules should be compiled |
| 73 | self.detect_modules() |
| 74 | |
| 75 | # Remove modules that are present on the disabled list |
| 76 | self.extensions = [ext for ext in self.extensions |
| 77 | if ext.name not in disabled_module_list] |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 78 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 79 | # Fix up the autodetected modules, prefixing all the source files |
| 80 | # with Modules/ and adding Python's include directory to the path. |
| 81 | (srcdir,) = sysconfig.get_config_vars('srcdir') |
| 82 | |
Neil Schemenauer | 726b78e | 2001-01-24 17:18:21 +0000 | [diff] [blame] | 83 | # Figure out the location of the source code for extension modules |
| 84 | moddir = os.path.join(os.getcwd(), srcdir, 'Modules') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 85 | moddir = os.path.normpath(moddir) |
| 86 | srcdir, tail = os.path.split(moddir) |
| 87 | srcdir = os.path.normpath(srcdir) |
| 88 | moddir = os.path.normpath(moddir) |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 89 | |
| 90 | moddirlist = [moddir] |
| 91 | incdirlist = ['./Include'] |
| 92 | |
| 93 | # Platform-dependent module source and include directories |
| 94 | platform = self.get_platform() |
| 95 | if platform == 'darwin1': |
| 96 | # Mac OS X also includes some mac-specific modules |
| 97 | macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules') |
| 98 | moddirlist.append(macmoddir) |
| 99 | incdirlist.append('./Mac/Include') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 100 | |
Andrew M. Kuchling | 3da989c | 2001-02-28 22:49:26 +0000 | [diff] [blame] | 101 | # Fix up the paths for scripts, too |
| 102 | self.distribution.scripts = [os.path.join(srcdir, filename) |
| 103 | for filename in self.distribution.scripts] |
| 104 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 105 | for ext in self.extensions[:]: |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 106 | ext.sources = [ find_module_file(filename, moddirlist) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 107 | for filename in ext.sources ] |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 108 | ext.include_dirs.append( '.' ) # to get config.h |
| 109 | for incdir in incdirlist: |
| 110 | ext.include_dirs.append( os.path.join(srcdir, incdir) ) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 111 | |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 112 | # If a module has already been built statically, |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 113 | # don't build it here |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 114 | if ext.name in sys.builtin_module_names: |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 115 | self.extensions.remove(ext) |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 116 | |
Andrew M. Kuchling | 8d7f086 | 2001-02-23 16:32:32 +0000 | [diff] [blame] | 117 | # Parse Modules/Setup to figure out which modules are turned |
| 118 | # on in the file. |
| 119 | input = text_file.TextFile('Modules/Setup', join_lines=1) |
| 120 | remove_modules = [] |
| 121 | while 1: |
| 122 | line = input.readline() |
| 123 | if not line: break |
| 124 | line = line.split() |
| 125 | remove_modules.append( line[0] ) |
| 126 | input.close() |
| 127 | |
| 128 | for ext in self.extensions[:]: |
| 129 | if ext.name in remove_modules: |
| 130 | self.extensions.remove(ext) |
| 131 | |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 132 | # When you run "make CC=altcc" or something similar, you really want |
| 133 | # those environment variables passed into the setup.py phase. Here's |
| 134 | # a small set of useful ones. |
| 135 | compiler = os.environ.get('CC') |
| 136 | linker_so = os.environ.get('LDSHARED') |
| 137 | args = {} |
| 138 | # unfortunately, distutils doesn't let us provide separate C and C++ |
| 139 | # compilers |
| 140 | if compiler is not None: |
Martin v. Löwis | 3e4b0e8 | 2001-08-10 08:56:17 +0000 | [diff] [blame] | 141 | (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT') |
| 142 | args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 143 | if linker_so is not None: |
Martin v. Löwis | 2f20dab | 2001-10-08 13:18:37 +0000 | [diff] [blame] | 144 | args['linker_so'] = linker_so |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 145 | self.compiler.set_executables(**args) |
| 146 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 147 | build_ext.build_extensions(self) |
| 148 | |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 149 | def build_extension(self, ext): |
| 150 | |
| 151 | try: |
| 152 | build_ext.build_extension(self, ext) |
| 153 | except (CCompilerError, DistutilsError), why: |
| 154 | self.announce('WARNING: building of extension "%s" failed: %s' % |
| 155 | (ext.name, sys.exc_info()[1])) |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 156 | return |
| 157 | try: |
| 158 | __import__(ext.name) |
| 159 | except ImportError: |
| 160 | self.announce('WARNING: removing "%s" since importing it failed' % |
| 161 | ext.name) |
| 162 | assert not self.inplace |
| 163 | fullname = self.get_ext_fullname(ext.name) |
| 164 | ext_filename = os.path.join(self.build_lib, |
| 165 | self.get_ext_filename(fullname)) |
| 166 | os.remove(ext_filename) |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 167 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 168 | def get_platform (self): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 169 | # Get value of sys.platform |
| 170 | platform = sys.platform |
| 171 | if platform[:6] =='cygwin': |
| 172 | platform = 'cygwin' |
Andrew M. Kuchling | 3c04494 | 2001-02-06 23:37:23 +0000 | [diff] [blame] | 173 | elif platform[:4] =='beos': |
| 174 | platform = 'beos' |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 175 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 176 | return platform |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 177 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 178 | def detect_modules(self): |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 179 | # Ensure that /usr/local is always used |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 180 | if '/usr/local/lib' not in self.compiler.library_dirs: |
Andrew M. Kuchling | 9b5abcd | 2001-03-17 16:56:35 +0000 | [diff] [blame] | 181 | self.compiler.library_dirs.insert(0, '/usr/local/lib') |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 182 | if '/usr/local/include' not in self.compiler.include_dirs: |
Andrew M. Kuchling | 9b5abcd | 2001-03-17 16:56:35 +0000 | [diff] [blame] | 183 | self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 184 | |
Martin v. Löwis | 339d0f7 | 2001-08-17 18:39:25 +0000 | [diff] [blame] | 185 | try: |
| 186 | have_unicode = unicode |
| 187 | except NameError: |
| 188 | have_unicode = 0 |
| 189 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 190 | # lib_dirs and inc_dirs are used to search for files; |
| 191 | # if a file is found in one of those directories, it can |
| 192 | # be assumed that no additional -I,-L directives are needed. |
| 193 | lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib'] |
Andrew M. Kuchling | 9b5abcd | 2001-03-17 16:56:35 +0000 | [diff] [blame] | 194 | inc_dirs = self.compiler.include_dirs + ['/usr/include'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 195 | exts = [] |
| 196 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 197 | platform = self.get_platform() |
Andrew M. Kuchling | 9b5abcd | 2001-03-17 16:56:35 +0000 | [diff] [blame] | 198 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 199 | # Check for MacOS X, which doesn't need libm.a at all |
| 200 | math_libs = ['m'] |
Andrew M. Kuchling | 3c04494 | 2001-02-06 23:37:23 +0000 | [diff] [blame] | 201 | if platform in ['Darwin1.2', 'beos']: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 202 | math_libs = [] |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 203 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 204 | # XXX Omitted modules: gl, pure, dl, SGI-specific modules |
| 205 | |
| 206 | # |
| 207 | # The following modules are all pretty straightforward, and compile |
| 208 | # on pretty much any POSIXish platform. |
| 209 | # |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 210 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 211 | # Some modules that are normally always on: |
| 212 | exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) ) |
| 213 | exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 214 | |
Fred Drake | 3a40f32 | 2001-10-12 21:00:48 +0000 | [diff] [blame] | 215 | exts.append( Extension('_hotshot', ['_hotshot.c']) ) |
Fred Drake | 2de7471 | 2001-02-01 05:26:54 +0000 | [diff] [blame] | 216 | exts.append( Extension('_weakref', ['_weakref.c']) ) |
Andrew M. Kuchling | d5c4306 | 2001-01-17 15:59:25 +0000 | [diff] [blame] | 217 | exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 218 | |
| 219 | # array objects |
| 220 | exts.append( Extension('array', ['arraymodule.c']) ) |
| 221 | # complex math library functions |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 222 | exts.append( Extension('cmath', ['cmathmodule.c'], |
| 223 | libraries=math_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 224 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 225 | # math library functions, e.g. sin() |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 226 | exts.append( Extension('math', ['mathmodule.c'], |
| 227 | libraries=math_libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 228 | # fast string operations implemented in C |
| 229 | exts.append( Extension('strop', ['stropmodule.c']) ) |
| 230 | # time operations and variables |
Andrew M. Kuchling | 5ddb25f | 2001-01-23 22:21:11 +0000 | [diff] [blame] | 231 | exts.append( Extension('time', ['timemodule.c'], |
| 232 | libraries=math_libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 233 | # operator.add() and similar goodies |
| 234 | exts.append( Extension('operator', ['operator.c']) ) |
| 235 | # access to the builtin codecs and codec registry |
| 236 | exts.append( Extension('_codecs', ['_codecsmodule.c']) ) |
Marc-André Lemburg | 261b8e2 | 2001-02-02 12:12:44 +0000 | [diff] [blame] | 237 | # Python C API test module |
Tim Peters | d66595f | 2001-02-04 03:09:53 +0000 | [diff] [blame] | 238 | exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 239 | # static Unicode character database |
Martin v. Löwis | 339d0f7 | 2001-08-17 18:39:25 +0000 | [diff] [blame] | 240 | if have_unicode: |
| 241 | exts.append( Extension('unicodedata', ['unicodedata.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 242 | # access to ISO C locale support |
| 243 | exts.append( Extension('_locale', ['_localemodule.c']) ) |
| 244 | |
| 245 | # Modules with some UNIX dependencies -- on by default: |
| 246 | # (If you have a really backward UNIX, select and socket may not be |
| 247 | # supported...) |
| 248 | |
| 249 | # fcntl(2) and ioctl(2) |
| 250 | exts.append( Extension('fcntl', ['fcntlmodule.c']) ) |
| 251 | # pwd(3) |
| 252 | exts.append( Extension('pwd', ['pwdmodule.c']) ) |
| 253 | # grp(3) |
| 254 | exts.append( Extension('grp', ['grpmodule.c']) ) |
| 255 | # posix (UNIX) errno values |
| 256 | exts.append( Extension('errno', ['errnomodule.c']) ) |
| 257 | # select(2); not on ancient System V |
| 258 | exts.append( Extension('select', ['selectmodule.c']) ) |
| 259 | |
| 260 | # The md5 module implements the RSA Data Security, Inc. MD5 |
| 261 | # Message-Digest Algorithm, described in RFC 1321. The necessary files |
| 262 | # md5c.c and md5.h are included here. |
| 263 | exts.append( Extension('md5', ['md5module.c', 'md5c.c']) ) |
| 264 | |
| 265 | # The sha module implements the SHA checksum algorithm. |
| 266 | # (NIST's Secure Hash Algorithm.) |
| 267 | exts.append( Extension('sha', ['shamodule.c']) ) |
| 268 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 269 | # Helper module for various ascii-encoders |
| 270 | exts.append( Extension('binascii', ['binascii.c']) ) |
| 271 | |
| 272 | # Fred Drake's interface to the Python parser |
| 273 | exts.append( Extension('parser', ['parsermodule.c']) ) |
| 274 | |
| 275 | # Digital Creations' cStringIO and cPickle |
| 276 | exts.append( Extension('cStringIO', ['cStringIO.c']) ) |
| 277 | exts.append( Extension('cPickle', ['cPickle.c']) ) |
| 278 | |
| 279 | # Memory-mapped files (also works on Win32). |
| 280 | exts.append( Extension('mmap', ['mmapmodule.c']) ) |
| 281 | |
| 282 | # Lance Ellinghaus's modules: |
| 283 | # enigma-inspired encryption |
| 284 | exts.append( Extension('rotor', ['rotormodule.c']) ) |
| 285 | # syslog daemon interface |
| 286 | exts.append( Extension('syslog', ['syslogmodule.c']) ) |
| 287 | |
| 288 | # George Neville-Neil's timing module: |
| 289 | exts.append( Extension('timing', ['timingmodule.c']) ) |
| 290 | |
| 291 | # |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 292 | # Here ends the simple stuff. From here on, modules need certain |
| 293 | # libraries, are platform-specific, or present other surprises. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 294 | # |
| 295 | |
| 296 | # Multimedia modules |
| 297 | # These don't work for 64-bit platforms!!! |
| 298 | # These represent audio samples or images as strings: |
| 299 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 300 | # Disabled on 64-bit platforms |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 301 | if sys.maxint != 9223372036854775807L: |
| 302 | # Operations on audio samples |
| 303 | exts.append( Extension('audioop', ['audioop.c']) ) |
| 304 | # Operations on images |
| 305 | exts.append( Extension('imageop', ['imageop.c']) ) |
| 306 | # Read SGI RGB image files (but coded portably) |
| 307 | exts.append( Extension('rgbimg', ['rgbimgmodule.c']) ) |
| 308 | |
| 309 | # readline |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 310 | if self.compiler.find_library_file(lib_dirs, 'readline'): |
| 311 | readline_libs = ['readline'] |
Andrew M. Kuchling | 5aa3c4a | 2001-08-16 20:30:18 +0000 | [diff] [blame] | 312 | if self.compiler.find_library_file(lib_dirs, |
| 313 | 'ncurses'): |
| 314 | readline_libs.append('ncurses') |
| 315 | elif self.compiler.find_library_file(lib_dirs + |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 316 | ['/usr/lib/termcap'], |
| 317 | 'termcap'): |
| 318 | readline_libs.append('termcap') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 319 | exts.append( Extension('readline', ['readline.c'], |
Marc-André Lemburg | 7c6fcda | 2001-01-26 18:03:24 +0000 | [diff] [blame] | 320 | library_dirs=['/usr/lib/termcap'], |
Marc-André Lemburg | 2efc323 | 2001-01-26 18:23:02 +0000 | [diff] [blame] | 321 | libraries=readline_libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 322 | |
Andrew M. Kuchling | 5aa3c4a | 2001-08-16 20:30:18 +0000 | [diff] [blame] | 323 | # crypt module. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 324 | |
| 325 | if self.compiler.find_library_file(lib_dirs, 'crypt'): |
| 326 | libs = ['crypt'] |
| 327 | else: |
| 328 | libs = [] |
| 329 | exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) |
| 330 | |
| 331 | # socket(2) |
| 332 | # Detect SSL support for the socket module |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 333 | ssl_incs = find_file('openssl/ssl.h', inc_dirs, |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 334 | ['/usr/local/ssl/include', |
| 335 | '/usr/contrib/ssl/include/' |
| 336 | ] |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 337 | ) |
| 338 | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, |
Andrew M. Kuchling | e7c8732 | 2001-01-19 16:58:21 +0000 | [diff] [blame] | 339 | ['/usr/local/ssl/lib', |
| 340 | '/usr/contrib/ssl/lib/' |
| 341 | ] ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 342 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 343 | if (ssl_incs is not None and |
| 344 | ssl_libs is not None): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 345 | exts.append( Extension('_socket', ['socketmodule.c'], |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 346 | include_dirs = ssl_incs, |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 347 | library_dirs = ssl_libs, |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 348 | libraries = ['ssl', 'crypto'], |
| 349 | define_macros = [('USE_SSL',1)] ) ) |
| 350 | else: |
| 351 | exts.append( Extension('_socket', ['socketmodule.c']) ) |
| 352 | |
| 353 | # Modules that provide persistent dictionary-like semantics. You will |
| 354 | # probably want to arrange for at least one of them to be available on |
| 355 | # your machine, though none are defined by default because of library |
| 356 | # dependencies. The Python module anydbm.py provides an |
| 357 | # implementation independent wrapper for these; dumbdbm.py provides |
| 358 | # similar functionality (but slower of course) implemented in Python. |
| 359 | |
| 360 | # The standard Unix dbm module: |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 361 | if platform not in ['cygwin']: |
| 362 | if (self.compiler.find_library_file(lib_dirs, 'ndbm')): |
| 363 | exts.append( Extension('dbm', ['dbmmodule.c'], |
| 364 | libraries = ['ndbm'] ) ) |
Neil Schemenauer | c3ffef6 | 2001-10-21 22:14:44 +0000 | [diff] [blame] | 365 | elif self.compiler.find_library_file(lib_dirs, 'db1'): |
| 366 | exts.append( Extension('dbm', ['dbmmodule.c'], |
| 367 | libraries = ['db1'] ) ) |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 368 | else: |
| 369 | exts.append( Extension('dbm', ['dbmmodule.c']) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 370 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 371 | # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: |
| 372 | if (self.compiler.find_library_file(lib_dirs, 'gdbm')): |
| 373 | exts.append( Extension('gdbm', ['gdbmmodule.c'], |
| 374 | libraries = ['gdbm'] ) ) |
| 375 | |
| 376 | # Berkeley DB interface. |
| 377 | # |
| 378 | # This requires the Berkeley DB code, see |
| 379 | # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz |
| 380 | # |
| 381 | # Edit the variables DB and DBPORT to point to the db top directory |
| 382 | # and the subdirectory of PORT where you built it. |
| 383 | # |
Greg Ward | 02fac83 | 2001-09-13 15:05:08 +0000 | [diff] [blame] | 384 | # (See http://pybsddb.sourceforge.net/ for an interface to |
| 385 | # Berkeley DB 3.x.) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 386 | |
Andrew M. Kuchling | e06337a | 2001-02-23 16:27:48 +0000 | [diff] [blame] | 387 | dblib = [] |
Skip Montanaro | e81f447 | 2001-08-21 04:23:21 +0000 | [diff] [blame] | 388 | if self.compiler.find_library_file(lib_dirs, 'db-3.1'): |
| 389 | dblib = ['db-3.1'] |
Neil Schemenauer | c3ffef6 | 2001-10-21 22:14:44 +0000 | [diff] [blame] | 390 | elif self.compiler.find_library_file(lib_dirs, 'db3'): |
| 391 | dblib = ['db3'] |
Skip Montanaro | e81f447 | 2001-08-21 04:23:21 +0000 | [diff] [blame] | 392 | elif self.compiler.find_library_file(lib_dirs, 'db2'): |
| 393 | dblib = ['db2'] |
| 394 | elif self.compiler.find_library_file(lib_dirs, 'db1'): |
| 395 | dblib = ['db1'] |
| 396 | elif self.compiler.find_library_file(lib_dirs, 'db'): |
Andrew M. Kuchling | e06337a | 2001-02-23 16:27:48 +0000 | [diff] [blame] | 397 | dblib = ['db'] |
| 398 | |
| 399 | db185_incs = find_file('db_185.h', inc_dirs, |
| 400 | ['/usr/include/db3', '/usr/include/db2']) |
| 401 | db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) |
| 402 | if db185_incs is not None: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 403 | exts.append( Extension('bsddb', ['bsddbmodule.c'], |
Andrew M. Kuchling | e06337a | 2001-02-23 16:27:48 +0000 | [diff] [blame] | 404 | include_dirs = db185_incs, |
| 405 | define_macros=[('HAVE_DB_185_H',1)], |
| 406 | libraries = dblib ) ) |
| 407 | elif db_inc is not None: |
| 408 | exts.append( Extension('bsddb', ['bsddbmodule.c'], |
| 409 | include_dirs = db_inc, |
| 410 | libraries = dblib) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 411 | |
| 412 | # The mpz module interfaces to the GNU Multiple Precision library. |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 413 | # You need to ftp the GNU MP library. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 414 | # This was originally written and tested against GMP 1.2 and 1.3.2. |
| 415 | # It has been modified by Rob Hooft to work with 2.0.2 as well, but I |
| 416 | # haven't tested it recently. For a more complete module, |
| 417 | # refer to pympz.sourceforge.net. |
| 418 | |
Greg Ward | 57fc210 | 2001-10-03 19:59:30 +0000 | [diff] [blame] | 419 | # 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] | 420 | # posted to comp.sources.misc in volume 40 and is widely available from |
| 421 | # FTP archive sites. One URL for it is: |
| 422 | # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z |
| 423 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 424 | if (self.compiler.find_library_file(lib_dirs, 'gmp')): |
| 425 | exts.append( Extension('mpz', ['mpzmodule.c'], |
| 426 | libraries = ['gmp'] ) ) |
| 427 | |
| 428 | |
| 429 | # Unix-only modules |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 430 | if platform not in ['mac', 'win32']: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 431 | # Steen Lumholt's termios module |
| 432 | exts.append( Extension('termios', ['termios.c']) ) |
| 433 | # Jeremy Hylton's rlimit interface |
Andrew M. Kuchling | fda3c3d | 2001-09-17 16:19:16 +0000 | [diff] [blame] | 434 | exts.append( Extension('resource', ['resource.c']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 435 | |
Andrew M. Kuchling | cf393f3 | 2001-02-21 02:38:24 +0000 | [diff] [blame] | 436 | # Sun yellow pages. Some systems have the functions in libc. |
Andrew M. Kuchling | 6efc6e7 | 2001-02-27 20:54:23 +0000 | [diff] [blame] | 437 | if platform not in ['cygwin']: |
| 438 | if (self.compiler.find_library_file(lib_dirs, 'nsl')): |
| 439 | libs = ['nsl'] |
| 440 | else: |
| 441 | libs = [] |
| 442 | exts.append( Extension('nis', ['nismodule.c'], |
| 443 | libraries = libs) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 444 | |
| 445 | # Curses support, requring the System V version of curses, often |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 446 | # provided by the ncurses library. |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 447 | if platform == 'sunos4': |
Andrew M. Kuchling | b69c758 | 2001-02-28 19:49:57 +0000 | [diff] [blame] | 448 | inc_dirs += ['/usr/5include'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 449 | lib_dirs += ['/usr/5lib'] |
| 450 | |
| 451 | if (self.compiler.find_library_file(lib_dirs, 'ncurses')): |
| 452 | curses_libs = ['ncurses'] |
| 453 | exts.append( Extension('_curses', ['_cursesmodule.c'], |
| 454 | libraries = curses_libs) ) |
Jack Jansen | 4ca5f38 | 2001-09-04 09:05:11 +0000 | [diff] [blame] | 455 | elif (self.compiler.find_library_file(lib_dirs, 'curses')) and platform != 'darwin1': |
| 456 | # OSX has an old Berkeley curses, not good enough for the _curses module. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 457 | if (self.compiler.find_library_file(lib_dirs, 'terminfo')): |
| 458 | curses_libs = ['curses', 'terminfo'] |
| 459 | else: |
| 460 | curses_libs = ['curses', 'termcap'] |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 461 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 462 | exts.append( Extension('_curses', ['_cursesmodule.c'], |
| 463 | libraries = curses_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 464 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 465 | # If the curses module is enabled, check for the panel module |
| 466 | if (os.path.exists('Modules/_curses_panel.c') and |
| 467 | module_enabled(exts, '_curses') and |
| 468 | self.compiler.find_library_file(lib_dirs, 'panel')): |
| 469 | exts.append( Extension('_curses_panel', ['_curses_panel.c'], |
| 470 | libraries = ['panel'] + curses_libs) ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 471 | |
| 472 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 473 | |
| 474 | # Lee Busby's SIGFPE modules. |
| 475 | # The library to link fpectl with is platform specific. |
| 476 | # Choose *one* of the options below for fpectl: |
| 477 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 478 | if platform == 'irix5': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 479 | # For SGI IRIX (tested on 5.3): |
| 480 | exts.append( Extension('fpectl', ['fpectlmodule.c'], |
| 481 | libraries=['fpe']) ) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 482 | elif 0: # XXX how to detect SunPro? |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 483 | # For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): |
| 484 | # (Without the compiler you don't have -lsunmath.) |
| 485 | #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm |
| 486 | pass |
| 487 | else: |
| 488 | # For other systems: see instructions in fpectlmodule.c. |
| 489 | #fpectl fpectlmodule.c ... |
| 490 | exts.append( Extension('fpectl', ['fpectlmodule.c']) ) |
| 491 | |
| 492 | |
| 493 | # Andrew Kuchling's zlib module. |
| 494 | # This require zlib 1.1.3 (or later). |
| 495 | # See http://www.cdrom.com/pub/infozip/zlib/ |
Guido van Rossum | e697091 | 2001-04-15 15:16:12 +0000 | [diff] [blame] | 496 | zlib_inc = find_file('zlib.h', [], inc_dirs) |
| 497 | if zlib_inc is not None: |
| 498 | zlib_h = zlib_inc[0] + '/zlib.h' |
| 499 | version = '"0.0.0"' |
| 500 | version_req = '"1.1.3"' |
| 501 | fp = open(zlib_h) |
| 502 | while 1: |
| 503 | line = fp.readline() |
| 504 | if not line: |
| 505 | break |
| 506 | if line.find('#define ZLIB_VERSION', 0) == 0: |
| 507 | version = line.split()[2] |
| 508 | break |
| 509 | if version >= version_req: |
| 510 | if (self.compiler.find_library_file(lib_dirs, 'z')): |
| 511 | exts.append( Extension('zlib', ['zlibmodule.c'], |
| 512 | libraries = ['z']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 513 | |
| 514 | # Interface to the Expat XML parser |
| 515 | # |
| 516 | # Expat is written by James Clark and must be downloaded separately |
| 517 | # (see below). The pyexpat module was written by Paul Prescod after a |
| 518 | # prototype by Jack Jansen. |
| 519 | # |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 520 | # The Expat dist includes Windows .lib and .dll files. Home page is |
| 521 | # at http://www.jclark.com/xml/expat.html, the current production |
| 522 | # release is always ftp://ftp.jclark.com/pub/xml/expat.zip. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 523 | # |
| 524 | # EXPAT_DIR, below, should point to the expat/ directory created by |
| 525 | # unpacking the Expat source distribution. |
| 526 | # |
Andrew M. Kuchling | 5bbc7b9 | 2001-01-18 20:39:34 +0000 | [diff] [blame] | 527 | # Note: the expat build process doesn't yet build a libexpat.a; you |
| 528 | # can do this manually while we try convince the author to add it. To |
| 529 | # do so, cd to EXPAT_DIR, run "make" if you have not done so, then |
| 530 | # run: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 531 | # |
| 532 | # ar cr libexpat.a xmltok/*.o xmlparse/*.o |
| 533 | # |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 534 | expat_defs = [] |
| 535 | expat_incs = find_file('expat.h', inc_dirs, []) |
| 536 | if expat_incs is not None: |
| 537 | # expat.h was found |
| 538 | expat_defs = [('HAVE_EXPAT_H', 1)] |
| 539 | else: |
| 540 | expat_incs = find_file('xmlparse.h', inc_dirs, []) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 541 | |
Martin v. Löwis | 1ab29b2 | 2001-01-21 10:54:52 +0000 | [diff] [blame] | 542 | if (expat_incs is not None and |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 543 | self.compiler.find_library_file(lib_dirs, 'expat')): |
| 544 | exts.append( Extension('pyexpat', ['pyexpat.c'], |
| 545 | define_macros = expat_defs, |
| 546 | libraries = ['expat']) ) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 547 | |
| 548 | # Platform-specific libraries |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 549 | if platform == 'linux2': |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 550 | # Linux-specific modules |
| 551 | exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) |
| 552 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 553 | if platform == 'sunos5': |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 554 | # SunOS specific modules |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 555 | exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 556 | |
| 557 | if platform == 'darwin1': |
| 558 | # Mac OS X specific modules. These are ported over from MacPython |
| 559 | # and still experimental. Some (such as gestalt or icglue) are |
| 560 | # already generally useful, some (the GUI ones) really need to |
| 561 | # be used from a framework. |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 562 | # |
| 563 | # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't |
| 564 | # available here. This Makefile variable is also what the install |
| 565 | # procedure triggers on. |
| 566 | frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 567 | exts.append( Extension('gestalt', ['gestaltmodule.c']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 568 | exts.append( Extension('MacOS', ['macosmodule.c'], |
| 569 | extra_link_args=['-framework', 'Carbon']) ) |
| 570 | exts.append( Extension('icglue', ['icgluemodule.c'], |
| 571 | extra_link_args=['-framework', 'Carbon']) ) |
| 572 | exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], |
| 573 | extra_link_args=['-framework', 'Carbon']) ) |
| 574 | exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) |
| 575 | exts.append( Extension('_Res', ['res/_Resmodule.c']) ) |
| 576 | exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], |
| 577 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 578 | if frameworkdir: |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 579 | exts.append( Extension('Nav', ['Nav.c'], |
| 580 | extra_link_args=['-framework', 'Carbon']) ) |
| 581 | exts.append( Extension('_AE', ['ae/_AEmodule.c'], |
| 582 | extra_link_args=['-framework', 'Carbon']) ) |
| 583 | exts.append( Extension('_App', ['app/_Appmodule.c'], |
| 584 | extra_link_args=['-framework', 'Carbon']) ) |
| 585 | exts.append( Extension('_Cm', ['cm/_Cmmodule.c'], |
| 586 | extra_link_args=['-framework', 'Carbon']) ) |
| 587 | exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'], |
| 588 | extra_link_args=['-framework', 'Carbon']) ) |
| 589 | exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'], |
| 590 | extra_link_args=['-framework', 'Carbon']) ) |
| 591 | exts.append( Extension('_Drag', ['drag/_Dragmodule.c'], |
| 592 | extra_link_args=['-framework', 'Carbon']) ) |
| 593 | exts.append( Extension('_Evt', ['evt/_Evtmodule.c'], |
| 594 | extra_link_args=['-framework', 'Carbon']) ) |
| 595 | exts.append( Extension('_Fm', ['fm/_Fmmodule.c'], |
| 596 | extra_link_args=['-framework', 'Carbon']) ) |
| 597 | exts.append( Extension('_Icn', ['icn/_Icnmodule.c'], |
| 598 | extra_link_args=['-framework', 'Carbon']) ) |
| 599 | exts.append( Extension('_List', ['list/_Listmodule.c'], |
| 600 | extra_link_args=['-framework', 'Carbon']) ) |
| 601 | exts.append( Extension('_Menu', ['menu/_Menumodule.c'], |
| 602 | extra_link_args=['-framework', 'Carbon']) ) |
| 603 | exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'], |
| 604 | extra_link_args=['-framework', 'Carbon']) ) |
| 605 | exts.append( Extension('_Qd', ['qd/_Qdmodule.c'], |
| 606 | extra_link_args=['-framework', 'Carbon']) ) |
| 607 | exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'], |
| 608 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 609 | exts.append( Extension('_Qt', ['qt/_Qtmodule.c'], |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 610 | extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) ) |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 611 | ## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 612 | exts.append( Extension('_TE', ['te/_TEmodule.c'], |
| 613 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 2f760c3 | 2001-09-04 21:33:12 +0000 | [diff] [blame] | 614 | ## exts.append( Extension('waste', ['waste/wastemodule.c']) ) |
Jack Jansen | 666b1e7 | 2001-10-31 12:11:48 +0000 | [diff] [blame] | 615 | exts.append( Extension('_Win', ['win/_Winmodule.c'], |
| 616 | extra_link_args=['-framework', 'Carbon']) ) |
Jack Jansen | 144ebcc | 2001-08-05 22:31:19 +0000 | [diff] [blame] | 617 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 618 | self.extensions.extend(exts) |
| 619 | |
| 620 | # Call the method for detecting whether _tkinter can be compiled |
| 621 | self.detect_tkinter(inc_dirs, lib_dirs) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 622 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 623 | |
| 624 | def detect_tkinter(self, inc_dirs, lib_dirs): |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 625 | # The _tkinter module. |
Martin v. Löwis | b1d1969 | 2001-03-21 07:44:53 +0000 | [diff] [blame] | 626 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 627 | # 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] | 628 | # The versions with dots are used on Unix, and the versions without |
| 629 | # dots on Windows, for detection by cygwin. |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 630 | tcllib = tklib = tcl_includes = tk_includes = None |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 631 | for version in ['8.4', '84', '8.3', '83', '8.2', |
| 632 | '82', '8.1', '81', '8.0', '80']: |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 633 | tklib = self.compiler.find_library_file(lib_dirs, |
| 634 | 'tk' + version ) |
| 635 | tcllib = self.compiler.find_library_file(lib_dirs, |
| 636 | 'tcl' + version ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 637 | if tklib and tcllib: |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 638 | # Exit the loop when we've found the Tcl/Tk libraries |
| 639 | break |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 640 | |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 641 | # Now check for the header files |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 642 | if tklib and tcllib: |
| 643 | # Check for the include files on Debian, where |
| 644 | # they're put in /usr/include/{tcl,tk}X.Y |
Andrew M. Kuchling | 9a3fd8c | 2001-02-06 22:15:27 +0000 | [diff] [blame] | 645 | debian_tcl_include = [ '/usr/include/tcl' + version ] |
| 646 | debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include |
| 647 | tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) |
| 648 | tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 649 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 650 | if (tcllib is None or tklib is None and |
| 651 | tcl_includes is None or tk_includes is None): |
| 652 | # Something's missing, so give up |
| 653 | return |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 654 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 655 | # OK... everything seems to be present for Tcl/Tk. |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 656 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 657 | include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] |
| 658 | for dir in tcl_includes + tk_includes: |
| 659 | if dir not in include_dirs: |
| 660 | include_dirs.append(dir) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 661 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 662 | # Check for various platform-specific directories |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 663 | platform = self.get_platform() |
| 664 | if platform == 'sunos5': |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 665 | include_dirs.append('/usr/openwin/include') |
| 666 | added_lib_dirs.append('/usr/openwin/lib') |
| 667 | elif os.path.exists('/usr/X11R6/include'): |
| 668 | include_dirs.append('/usr/X11R6/include') |
| 669 | added_lib_dirs.append('/usr/X11R6/lib') |
| 670 | elif os.path.exists('/usr/X11R5/include'): |
| 671 | include_dirs.append('/usr/X11R5/include') |
| 672 | added_lib_dirs.append('/usr/X11R5/lib') |
| 673 | else: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 674 | # Assume default location for X11 |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 675 | include_dirs.append('/usr/X11/include') |
| 676 | added_lib_dirs.append('/usr/X11/lib') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 677 | |
Andrew M. Kuchling | 89fb72d | 2001-09-18 20:32:13 +0000 | [diff] [blame] | 678 | # If Cygwin, then verify that X is installed before proceeding |
| 679 | if platform == 'cygwin': |
| 680 | x11_inc = find_file('X11/Xlib.h', [], inc_dirs) |
| 681 | if x11_inc is None: |
| 682 | # X header files missing, so give up |
| 683 | return |
| 684 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 685 | # Check for BLT extension |
| 686 | if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'BLT8.0'): |
| 687 | defs.append( ('WITH_BLT', 1) ) |
| 688 | libs.append('BLT8.0') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 689 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 690 | # Add the Tcl/Tk libraries |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 691 | libs.append('tk'+version) |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 692 | libs.append('tcl'+version) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 693 | |
Andrew M. Kuchling | 34febf5 | 2001-01-24 03:31:07 +0000 | [diff] [blame] | 694 | if platform in ['aix3', 'aix4']: |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 695 | libs.append('ld') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 696 | |
Martin v. Löwis | 3db5b8c | 2001-07-24 06:54:01 +0000 | [diff] [blame] | 697 | # Finally, link with the X11 libraries (not appropriate on cygwin) |
| 698 | if platform != "cygwin": |
| 699 | libs.append('X11') |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 700 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 701 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
| 702 | define_macros=[('WITH_APPINIT', 1)] + defs, |
| 703 | include_dirs = include_dirs, |
| 704 | libraries = libs, |
| 705 | library_dirs = added_lib_dirs, |
| 706 | ) |
| 707 | self.extensions.append(ext) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 708 | |
Andrew M. Kuchling | fbe7376 | 2001-01-18 18:44:20 +0000 | [diff] [blame] | 709 | # XXX handle these, but how to detect? |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 710 | # *** Uncomment and edit for PIL (TkImaging) extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 711 | # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 712 | # *** Uncomment and edit for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 713 | # -DWITH_TOGL togl.c \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 714 | # *** Uncomment these for TOGL extension only: |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 715 | # -lGL -lGLU -lXext -lXmu \ |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 716 | |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 717 | class PyBuildInstall(install): |
| 718 | # Suppress the warning about installation into the lib_dynload |
| 719 | # directory, which is not in sys.path when running Python during |
| 720 | # installation: |
| 721 | def initialize_options (self): |
| 722 | install.initialize_options(self) |
| 723 | self.warn_dir=0 |
| 724 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 725 | def main(): |
Andrew M. Kuchling | 6268669 | 2001-05-21 20:48:09 +0000 | [diff] [blame] | 726 | # turn off warnings when deprecated modules are imported |
| 727 | import warnings |
| 728 | warnings.filterwarnings("ignore",category=DeprecationWarning) |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 729 | setup(name = 'Python standard library', |
Neil Schemenauer | e7e2ece | 2001-01-17 21:58:00 +0000 | [diff] [blame] | 730 | version = '%d.%d' % sys.version_info[:2], |
Andrew M. Kuchling | f52d27e | 2001-05-21 20:29:27 +0000 | [diff] [blame] | 731 | cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall}, |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 732 | # The struct module is defined here, because build_ext won't be |
| 733 | # called unless there's at least one extension module defined. |
Andrew M. Kuchling | aece427 | 2001-02-28 20:56:49 +0000 | [diff] [blame] | 734 | ext_modules=[Extension('struct', ['structmodule.c'])], |
| 735 | |
| 736 | # Scripts to install |
| 737 | scripts = ['Tools/scripts/pydoc'] |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 738 | ) |
Fredrik Lundh | ade711a | 2001-01-24 08:00:28 +0000 | [diff] [blame] | 739 | |
Andrew M. Kuchling | 00e0f21 | 2001-01-17 15:23:23 +0000 | [diff] [blame] | 740 | # --install-platlib |
| 741 | if __name__ == '__main__': |
| 742 | sysconfig.set_python_build() |
| 743 | main() |