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