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