blob: f529032a2cdbfb40fd4d9f5083c91b0ffc62535b [file] [log] [blame]
Andrew M. Kuchling66012fe2001-01-26 21:56:58 +00001# Autodetecting setup.py script for building the Python extensions
2#
Fredrik Lundhade711a2001-01-24 08:00:28 +00003
Andrew M. Kuchling66012fe2001-01-26 21:56:58 +00004__version__ = "$Revision$"
5
6import sys, os, getopt
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +00007from distutils import sysconfig
Andrew M. Kuchling8d7f0862001-02-23 16:32:32 +00008from distutils import text_file
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +00009from distutils.errors import *
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000010from distutils.core import Extension, setup
11from distutils.command.build_ext import build_ext
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +000012from distutils.command.install import install
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000013
14# This global variable is used to hold the list of modules to be disabled.
15disabled_module_list = []
16
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000017def 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 Lundhade711a2001-01-24 08:00:28 +000021
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000022 '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. Kuchling00e0f212001-01-17 15:23:23 +000041 return None
42
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000043def 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 Lundhade711a2001-01-24 08:00:28 +000047
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000048 filename = compiler.library_filename(libname, lib_type='static')
49 result = find_file(filename, std_dirs, paths)
50 return result
51
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000052def 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 Lundhade711a2001-01-24 08:00:28 +000057
Jack Jansen144ebcc2001-08-05 22:31:19 +000058def find_module_file(module, dirlist):
59 """Find a module in a set of possible folders. If it is not found
60 return the unadorned filename"""
61 list = find_file(module, [], dirlist)
62 if not list:
63 return module
64 if len(list) > 1:
65 self.announce("WARNING: multiple copies of %s found"%module)
66 return os.path.join(list[0], module)
67
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000068class PyBuildExt(build_ext):
Fredrik Lundhade711a2001-01-24 08:00:28 +000069
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000070 def build_extensions(self):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000071
72 # Detect which modules should be compiled
73 self.detect_modules()
74
75 # Remove modules that are present on the disabled list
76 self.extensions = [ext for ext in self.extensions
77 if ext.name not in disabled_module_list]
Fredrik Lundhade711a2001-01-24 08:00:28 +000078
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000079 # Fix up the autodetected modules, prefixing all the source files
80 # with Modules/ and adding Python's include directory to the path.
81 (srcdir,) = sysconfig.get_config_vars('srcdir')
82
Neil Schemenauer726b78e2001-01-24 17:18:21 +000083 # Figure out the location of the source code for extension modules
84 moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000085 moddir = os.path.normpath(moddir)
86 srcdir, tail = os.path.split(moddir)
87 srcdir = os.path.normpath(srcdir)
88 moddir = os.path.normpath(moddir)
Jack Jansen144ebcc2001-08-05 22:31:19 +000089
90 moddirlist = [moddir]
91 incdirlist = ['./Include']
92
93 # Platform-dependent module source and include directories
94 platform = self.get_platform()
Jack Jansen244e7612001-12-05 15:54:29 +000095 if platform == 'darwin':
Jack Jansen144ebcc2001-08-05 22:31:19 +000096 # Mac OS X also includes some mac-specific modules
97 macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
98 moddirlist.append(macmoddir)
99 incdirlist.append('./Mac/Include')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000100
Andrew M. Kuchling3da989c2001-02-28 22:49:26 +0000101 # Fix up the paths for scripts, too
102 self.distribution.scripts = [os.path.join(srcdir, filename)
103 for filename in self.distribution.scripts]
104
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000105 for ext in self.extensions[:]:
Jack Jansen144ebcc2001-08-05 22:31:19 +0000106 ext.sources = [ find_module_file(filename, moddirlist)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000107 for filename in ext.sources ]
Jack Jansen144ebcc2001-08-05 22:31:19 +0000108 ext.include_dirs.append( '.' ) # to get config.h
109 for incdir in incdirlist:
110 ext.include_dirs.append( os.path.join(srcdir, incdir) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000111
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000112 # If a module has already been built statically,
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000113 # don't build it here
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000114 if ext.name in sys.builtin_module_names:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000115 self.extensions.remove(ext)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000116
Andrew M. Kuchling8d7f0862001-02-23 16:32:32 +0000117 # Parse Modules/Setup to figure out which modules are turned
118 # on in the file.
119 input = text_file.TextFile('Modules/Setup', join_lines=1)
120 remove_modules = []
121 while 1:
122 line = input.readline()
123 if not line: break
124 line = line.split()
125 remove_modules.append( line[0] )
126 input.close()
127
128 for ext in self.extensions[:]:
129 if ext.name in remove_modules:
130 self.extensions.remove(ext)
131
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000132 # When you run "make CC=altcc" or something similar, you really want
133 # those environment variables passed into the setup.py phase. Here's
134 # a small set of useful ones.
135 compiler = os.environ.get('CC')
136 linker_so = os.environ.get('LDSHARED')
137 args = {}
138 # unfortunately, distutils doesn't let us provide separate C and C++
139 # compilers
140 if compiler is not None:
Martin v. Löwis3e4b0e82001-08-10 08:56:17 +0000141 (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT')
142 args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000143 if linker_so is not None:
Martin v. Löwis2f20dab2001-10-08 13:18:37 +0000144 args['linker_so'] = linker_so
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000145 self.compiler.set_executables(**args)
146
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000147 build_ext.build_extensions(self)
148
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000149 def build_extension(self, ext):
150
151 try:
152 build_ext.build_extension(self, ext)
153 except (CCompilerError, DistutilsError), why:
154 self.announce('WARNING: building of extension "%s" failed: %s' %
155 (ext.name, sys.exc_info()[1]))
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000156 return
Jack Jansenf49c6f92001-11-01 14:44:15 +0000157 # Workaround for Mac OS X: The Carbon-based modules cannot be
158 # reliably imported into a command-line Python
159 if 'Carbon' in ext.extra_link_args:
Fred Drake38419c02001-12-06 22:24:47 +0000160 self.announce(
161 'WARNING: skipping import check for Carbon-based "%s"' %
162 ext.name)
Jack Jansenf49c6f92001-11-01 14:44:15 +0000163 return
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000164 try:
165 __import__(ext.name)
166 except ImportError:
167 self.announce('WARNING: removing "%s" since importing it failed' %
168 ext.name)
169 assert not self.inplace
170 fullname = self.get_ext_fullname(ext.name)
171 ext_filename = os.path.join(self.build_lib,
172 self.get_ext_filename(fullname))
173 os.remove(ext_filename)
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000174
Fred Drake9028d0a2001-12-06 22:59:54 +0000175 # XXX -- This relies on a Vile HACK in
176 # distutils.command.build_ext.build_extension(). The
177 # _built_objects attribute is stored there strictly for
178 # use here.
179 for filename in self._built_objects:
180 os.remove(filename)
181
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000182 def get_platform (self):
Fredrik Lundhade711a2001-01-24 08:00:28 +0000183 # Get value of sys.platform
184 platform = sys.platform
185 if platform[:6] =='cygwin':
186 platform = 'cygwin'
Andrew M. Kuchling3c044942001-02-06 23:37:23 +0000187 elif platform[:4] =='beos':
188 platform = 'beos'
Jack Jansen244e7612001-12-05 15:54:29 +0000189 elif platform[:6] == 'darwin':
190 platform = 'darwin'
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000191
Fredrik Lundhade711a2001-01-24 08:00:28 +0000192 return platform
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000193
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000194 def detect_modules(self):
Fredrik Lundhade711a2001-01-24 08:00:28 +0000195 # Ensure that /usr/local is always used
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000196 if '/usr/local/lib' not in self.compiler.library_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000197 self.compiler.library_dirs.insert(0, '/usr/local/lib')
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000198 if '/usr/local/include' not in self.compiler.include_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000199 self.compiler.include_dirs.insert(0, '/usr/local/include' )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000200
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000201 try:
202 have_unicode = unicode
203 except NameError:
204 have_unicode = 0
205
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000206 # lib_dirs and inc_dirs are used to search for files;
207 # if a file is found in one of those directories, it can
208 # be assumed that no additional -I,-L directives are needed.
209 lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000210 inc_dirs = self.compiler.include_dirs + ['/usr/include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000211 exts = []
212
Fredrik Lundhade711a2001-01-24 08:00:28 +0000213 platform = self.get_platform()
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000214
Fredrik Lundhade711a2001-01-24 08:00:28 +0000215 # Check for MacOS X, which doesn't need libm.a at all
216 math_libs = ['m']
Jack Jansen244e7612001-12-05 15:54:29 +0000217 if platform in ['darwin', 'beos']:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000218 math_libs = []
Jack Jansen144ebcc2001-08-05 22:31:19 +0000219
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000220 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
221
222 #
223 # The following modules are all pretty straightforward, and compile
224 # on pretty much any POSIXish platform.
225 #
Fredrik Lundhade711a2001-01-24 08:00:28 +0000226
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000227 # Some modules that are normally always on:
228 exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
229 exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000230
Fred Drake3a40f322001-10-12 21:00:48 +0000231 exts.append( Extension('_hotshot', ['_hotshot.c']) )
Fred Drake2de74712001-02-01 05:26:54 +0000232 exts.append( Extension('_weakref', ['_weakref.c']) )
Andrew M. Kuchlingd5c43062001-01-17 15:59:25 +0000233 exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000234
235 # array objects
236 exts.append( Extension('array', ['arraymodule.c']) )
237 # complex math library functions
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000238 exts.append( Extension('cmath', ['cmathmodule.c'],
239 libraries=math_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000240
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000241 # math library functions, e.g. sin()
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000242 exts.append( Extension('math', ['mathmodule.c'],
243 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000244 # fast string operations implemented in C
245 exts.append( Extension('strop', ['stropmodule.c']) )
246 # time operations and variables
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000247 exts.append( Extension('time', ['timemodule.c'],
248 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000249 # operator.add() and similar goodies
250 exts.append( Extension('operator', ['operator.c']) )
251 # access to the builtin codecs and codec registry
252 exts.append( Extension('_codecs', ['_codecsmodule.c']) )
Marc-André Lemburg261b8e22001-02-02 12:12:44 +0000253 # Python C API test module
Tim Petersd66595f2001-02-04 03:09:53 +0000254 exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000255 # static Unicode character database
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000256 if have_unicode:
257 exts.append( Extension('unicodedata', ['unicodedata.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000258 # access to ISO C locale support
259 exts.append( Extension('_locale', ['_localemodule.c']) )
260
261 # Modules with some UNIX dependencies -- on by default:
262 # (If you have a really backward UNIX, select and socket may not be
263 # supported...)
264
265 # fcntl(2) and ioctl(2)
266 exts.append( Extension('fcntl', ['fcntlmodule.c']) )
267 # pwd(3)
268 exts.append( Extension('pwd', ['pwdmodule.c']) )
269 # grp(3)
270 exts.append( Extension('grp', ['grpmodule.c']) )
271 # posix (UNIX) errno values
272 exts.append( Extension('errno', ['errnomodule.c']) )
273 # select(2); not on ancient System V
274 exts.append( Extension('select', ['selectmodule.c']) )
275
276 # The md5 module implements the RSA Data Security, Inc. MD5
Fred Drake38419c02001-12-06 22:24:47 +0000277 # Message-Digest Algorithm, described in RFC 1321. The
278 # necessary files md5c.c and md5.h are included here.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000279 exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
280
281 # The sha module implements the SHA checksum algorithm.
282 # (NIST's Secure Hash Algorithm.)
283 exts.append( Extension('sha', ['shamodule.c']) )
284
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000285 # Helper module for various ascii-encoders
286 exts.append( Extension('binascii', ['binascii.c']) )
287
288 # Fred Drake's interface to the Python parser
289 exts.append( Extension('parser', ['parsermodule.c']) )
290
291 # Digital Creations' cStringIO and cPickle
292 exts.append( Extension('cStringIO', ['cStringIO.c']) )
293 exts.append( Extension('cPickle', ['cPickle.c']) )
294
295 # Memory-mapped files (also works on Win32).
296 exts.append( Extension('mmap', ['mmapmodule.c']) )
297
298 # Lance Ellinghaus's modules:
299 # enigma-inspired encryption
300 exts.append( Extension('rotor', ['rotormodule.c']) )
301 # syslog daemon interface
302 exts.append( Extension('syslog', ['syslogmodule.c']) )
303
304 # George Neville-Neil's timing module:
305 exts.append( Extension('timing', ['timingmodule.c']) )
306
307 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000308 # Here ends the simple stuff. From here on, modules need certain
309 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000310 #
311
312 # Multimedia modules
313 # These don't work for 64-bit platforms!!!
314 # These represent audio samples or images as strings:
315
Fredrik Lundhade711a2001-01-24 08:00:28 +0000316 # Disabled on 64-bit platforms
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000317 if sys.maxint != 9223372036854775807L:
318 # Operations on audio samples
319 exts.append( Extension('audioop', ['audioop.c']) )
320 # Operations on images
321 exts.append( Extension('imageop', ['imageop.c']) )
322 # Read SGI RGB image files (but coded portably)
323 exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
324
325 # readline
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000326 if self.compiler.find_library_file(lib_dirs, 'readline'):
327 readline_libs = ['readline']
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18 +0000328 if self.compiler.find_library_file(lib_dirs,
329 'ncurses'):
330 readline_libs.append('ncurses')
331 elif self.compiler.find_library_file(lib_dirs +
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000332 ['/usr/lib/termcap'],
333 'termcap'):
334 readline_libs.append('termcap')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000335 exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000336 library_dirs=['/usr/lib/termcap'],
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000337 libraries=readline_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000338
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18 +0000339 # crypt module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000340
341 if self.compiler.find_library_file(lib_dirs, 'crypt'):
342 libs = ['crypt']
343 else:
344 libs = []
345 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
346
347 # socket(2)
348 # Detect SSL support for the socket module
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000349 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000350 ['/usr/local/ssl/include',
351 '/usr/contrib/ssl/include/'
352 ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000353 )
354 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000355 ['/usr/local/ssl/lib',
356 '/usr/contrib/ssl/lib/'
357 ] )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000358
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000359 if (ssl_incs is not None and
360 ssl_libs is not None):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000361 exts.append( Extension('_socket', ['socketmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000362 include_dirs = ssl_incs,
Fredrik Lundhade711a2001-01-24 08:00:28 +0000363 library_dirs = ssl_libs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000364 libraries = ['ssl', 'crypto'],
365 define_macros = [('USE_SSL',1)] ) )
366 else:
367 exts.append( Extension('_socket', ['socketmodule.c']) )
368
369 # Modules that provide persistent dictionary-like semantics. You will
370 # probably want to arrange for at least one of them to be available on
371 # your machine, though none are defined by default because of library
372 # dependencies. The Python module anydbm.py provides an
373 # implementation independent wrapper for these; dumbdbm.py provides
374 # similar functionality (but slower of course) implemented in Python.
375
376 # The standard Unix dbm module:
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000377 if platform not in ['cygwin']:
378 if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
379 exts.append( Extension('dbm', ['dbmmodule.c'],
380 libraries = ['ndbm'] ) )
Neil Schemenauerc3ffef62001-10-21 22:14:44 +0000381 elif self.compiler.find_library_file(lib_dirs, 'db1'):
382 exts.append( Extension('dbm', ['dbmmodule.c'],
383 libraries = ['db1'] ) )
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000384 else:
385 exts.append( Extension('dbm', ['dbmmodule.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000386
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000387 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
388 if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
389 exts.append( Extension('gdbm', ['gdbmmodule.c'],
390 libraries = ['gdbm'] ) )
391
392 # Berkeley DB interface.
393 #
394 # This requires the Berkeley DB code, see
395 # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
396 #
397 # Edit the variables DB and DBPORT to point to the db top directory
398 # and the subdirectory of PORT where you built it.
399 #
Greg Ward02fac832001-09-13 15:05:08 +0000400 # (See http://pybsddb.sourceforge.net/ for an interface to
401 # Berkeley DB 3.x.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000402
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000403 dblib = []
Martin v. Löwisf5c76772001-11-24 09:28:42 +0000404 if self.compiler.find_library_file(lib_dirs, 'db-3.2'):
405 dblib = ['db-3.2']
406 elif self.compiler.find_library_file(lib_dirs, 'db-3.1'):
Skip Montanaroe81f4472001-08-21 04:23:21 +0000407 dblib = ['db-3.1']
Neil Schemenauerc3ffef62001-10-21 22:14:44 +0000408 elif self.compiler.find_library_file(lib_dirs, 'db3'):
409 dblib = ['db3']
Skip Montanaroe81f4472001-08-21 04:23:21 +0000410 elif self.compiler.find_library_file(lib_dirs, 'db2'):
411 dblib = ['db2']
412 elif self.compiler.find_library_file(lib_dirs, 'db1'):
413 dblib = ['db1']
414 elif self.compiler.find_library_file(lib_dirs, 'db'):
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000415 dblib = ['db']
416
417 db185_incs = find_file('db_185.h', inc_dirs,
418 ['/usr/include/db3', '/usr/include/db2'])
419 db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
420 if db185_incs is not None:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000421 exts.append( Extension('bsddb', ['bsddbmodule.c'],
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000422 include_dirs = db185_incs,
423 define_macros=[('HAVE_DB_185_H',1)],
424 libraries = dblib ) )
425 elif db_inc is not None:
426 exts.append( Extension('bsddb', ['bsddbmodule.c'],
427 include_dirs = db_inc,
428 libraries = dblib) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000429
430 # The mpz module interfaces to the GNU Multiple Precision library.
Fredrik Lundhade711a2001-01-24 08:00:28 +0000431 # You need to ftp the GNU MP library.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000432 # This was originally written and tested against GMP 1.2 and 1.3.2.
433 # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
434 # haven't tested it recently. For a more complete module,
435 # refer to pympz.sourceforge.net.
436
Greg Ward57fc2102001-10-03 19:59:30 +0000437 # A compatible MP library unencumbered by the GPL also exists. It was
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000438 # posted to comp.sources.misc in volume 40 and is widely available from
439 # FTP archive sites. One URL for it is:
440 # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
441
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000442 if (self.compiler.find_library_file(lib_dirs, 'gmp')):
443 exts.append( Extension('mpz', ['mpzmodule.c'],
444 libraries = ['gmp'] ) )
445
446
447 # Unix-only modules
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000448 if platform not in ['mac', 'win32']:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000449 # Steen Lumholt's termios module
450 exts.append( Extension('termios', ['termios.c']) )
451 # Jeremy Hylton's rlimit interface
Andrew M. Kuchlingfda3c3d2001-09-17 16:19:16 +0000452 exts.append( Extension('resource', ['resource.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000453
Andrew M. Kuchlingcf393f32001-02-21 02:38:24 +0000454 # Sun yellow pages. Some systems have the functions in libc.
Andrew M. Kuchling6efc6e72001-02-27 20:54:23 +0000455 if platform not in ['cygwin']:
456 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
457 libs = ['nsl']
458 else:
459 libs = []
460 exts.append( Extension('nis', ['nismodule.c'],
461 libraries = libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000462
463 # Curses support, requring the System V version of curses, often
Fredrik Lundhade711a2001-01-24 08:00:28 +0000464 # provided by the ncurses library.
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000465 if platform == 'sunos4':
Andrew M. Kuchlingb69c7582001-02-28 19:49:57 +0000466 inc_dirs += ['/usr/5include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000467 lib_dirs += ['/usr/5lib']
468
469 if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
470 curses_libs = ['ncurses']
471 exts.append( Extension('_curses', ['_cursesmodule.c'],
472 libraries = curses_libs) )
Fred Drake38419c02001-12-06 22:24:47 +0000473 elif (self.compiler.find_library_file(lib_dirs, 'curses')
474 and platform != 'darwin'):
475 # OSX has an old Berkeley curses, not good enough for
476 # the _curses module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000477 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
478 curses_libs = ['curses', 'terminfo']
479 else:
480 curses_libs = ['curses', 'termcap']
Fredrik Lundhade711a2001-01-24 08:00:28 +0000481
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000482 exts.append( Extension('_curses', ['_cursesmodule.c'],
483 libraries = curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000484
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000485 # If the curses module is enabled, check for the panel module
Andrew M. Kuchlinge7ffbb22001-12-06 15:57:16 +0000486 if (module_enabled(exts, '_curses') and
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000487 self.compiler.find_library_file(lib_dirs, 'panel')):
488 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
489 libraries = ['panel'] + curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000490
491
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000492
493 # Lee Busby's SIGFPE modules.
494 # The library to link fpectl with is platform specific.
495 # Choose *one* of the options below for fpectl:
496
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000497 if platform == 'irix5':
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000498 # For SGI IRIX (tested on 5.3):
499 exts.append( Extension('fpectl', ['fpectlmodule.c'],
500 libraries=['fpe']) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000501 elif 0: # XXX how to detect SunPro?
Fred Drake38419c02001-12-06 22:24:47 +0000502 # For Solaris with SunPro compiler (tested on Solaris 2.5
503 # with SunPro C 4.2): (Without the compiler you don't have
504 # -lsunmath.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000505 #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
506 pass
507 else:
508 # For other systems: see instructions in fpectlmodule.c.
509 #fpectl fpectlmodule.c ...
510 exts.append( Extension('fpectl', ['fpectlmodule.c']) )
511
512
513 # Andrew Kuchling's zlib module.
514 # This require zlib 1.1.3 (or later).
515 # See http://www.cdrom.com/pub/infozip/zlib/
Guido van Rossume6970912001-04-15 15:16:12 +0000516 zlib_inc = find_file('zlib.h', [], inc_dirs)
517 if zlib_inc is not None:
518 zlib_h = zlib_inc[0] + '/zlib.h'
519 version = '"0.0.0"'
520 version_req = '"1.1.3"'
521 fp = open(zlib_h)
522 while 1:
523 line = fp.readline()
524 if not line:
525 break
526 if line.find('#define ZLIB_VERSION', 0) == 0:
527 version = line.split()[2]
528 break
529 if version >= version_req:
530 if (self.compiler.find_library_file(lib_dirs, 'z')):
531 exts.append( Extension('zlib', ['zlibmodule.c'],
532 libraries = ['z']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000533
534 # Interface to the Expat XML parser
535 #
536 # Expat is written by James Clark and must be downloaded separately
537 # (see below). The pyexpat module was written by Paul Prescod after a
538 # prototype by Jack Jansen.
539 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000540 # The Expat dist includes Windows .lib and .dll files. Home page is
541 # at http://www.jclark.com/xml/expat.html, the current production
542 # release is always ftp://ftp.jclark.com/pub/xml/expat.zip.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000543 #
544 # EXPAT_DIR, below, should point to the expat/ directory created by
545 # unpacking the Expat source distribution.
546 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000547 # Note: the expat build process doesn't yet build a libexpat.a; you
548 # can do this manually while we try convince the author to add it. To
549 # do so, cd to EXPAT_DIR, run "make" if you have not done so, then
550 # run:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000551 #
552 # ar cr libexpat.a xmltok/*.o xmlparse/*.o
553 #
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000554 expat_defs = []
555 expat_incs = find_file('expat.h', inc_dirs, [])
556 if expat_incs is not None:
557 # expat.h was found
558 expat_defs = [('HAVE_EXPAT_H', 1)]
559 else:
560 expat_incs = find_file('xmlparse.h', inc_dirs, [])
Fredrik Lundhade711a2001-01-24 08:00:28 +0000561
Martin v. Löwis1ab29b22001-01-21 10:54:52 +0000562 if (expat_incs is not None and
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000563 self.compiler.find_library_file(lib_dirs, 'expat')):
564 exts.append( Extension('pyexpat', ['pyexpat.c'],
565 define_macros = expat_defs,
566 libraries = ['expat']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000567
568 # Platform-specific libraries
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000569 if platform == 'linux2':
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000570 # Linux-specific modules
571 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
572
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000573 if platform == 'sunos5':
Fredrik Lundhade711a2001-01-24 08:00:28 +0000574 # SunOS specific modules
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000575 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
Jack Jansen144ebcc2001-08-05 22:31:19 +0000576
Jack Jansen244e7612001-12-05 15:54:29 +0000577 if platform == 'darwin':
Jack Jansen144ebcc2001-08-05 22:31:19 +0000578 # Mac OS X specific modules. These are ported over from MacPython
579 # and still experimental. Some (such as gestalt or icglue) are
580 # already generally useful, some (the GUI ones) really need to
581 # be used from a framework.
Jack Jansen2f760c32001-09-04 21:33:12 +0000582 #
583 # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
584 # available here. This Makefile variable is also what the install
585 # procedure triggers on.
586 frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
Jack Jansen144ebcc2001-08-05 22:31:19 +0000587 exts.append( Extension('gestalt', ['gestaltmodule.c']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000588 exts.append( Extension('MacOS', ['macosmodule.c'],
589 extra_link_args=['-framework', 'Carbon']) )
590 exts.append( Extension('icglue', ['icgluemodule.c'],
591 extra_link_args=['-framework', 'Carbon']) )
Fred Drake38419c02001-12-06 22:24:47 +0000592 exts.append( Extension('macfs',
593 ['macfsmodule.c',
594 '../Python/getapplbycreator.c'],
Jack Jansen666b1e72001-10-31 12:11:48 +0000595 extra_link_args=['-framework', 'Carbon']) )
596 exts.append( Extension('_CF', ['cf/_CFmodule.c']) )
597 exts.append( Extension('_Res', ['res/_Resmodule.c']) )
598 exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
599 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000600 if frameworkdir:
Jack Jansen666b1e72001-10-31 12:11:48 +0000601 exts.append( Extension('Nav', ['Nav.c'],
602 extra_link_args=['-framework', 'Carbon']) )
603 exts.append( Extension('_AE', ['ae/_AEmodule.c'],
604 extra_link_args=['-framework', 'Carbon']) )
605 exts.append( Extension('_App', ['app/_Appmodule.c'],
606 extra_link_args=['-framework', 'Carbon']) )
Jack Jansendd67a8e2001-12-12 23:03:17 +0000607 exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'],
608 extra_link_args=['-framework', 'Carbon']) )
Just van Rossume9039b12001-12-13 13:41:36 +0000609 exts.append( Extension('_CG', ['cg/_CGmodule.c'],
610 extra_link_args=['-framework', 'ApplicationServices',
611 '-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000612 exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
613 extra_link_args=['-framework', 'Carbon']) )
614 exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
615 extra_link_args=['-framework', 'Carbon']) )
616 exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
617 extra_link_args=['-framework', 'Carbon']) )
618 exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
619 extra_link_args=['-framework', 'Carbon']) )
620 exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
621 extra_link_args=['-framework', 'Carbon']) )
622 exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
623 extra_link_args=['-framework', 'Carbon']) )
624 exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
625 extra_link_args=['-framework', 'Carbon']) )
626 exts.append( Extension('_List', ['list/_Listmodule.c'],
627 extra_link_args=['-framework', 'Carbon']) )
628 exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
629 extra_link_args=['-framework', 'Carbon']) )
630 exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
631 extra_link_args=['-framework', 'Carbon']) )
632 exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
633 extra_link_args=['-framework', 'Carbon']) )
634 exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
635 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000636 exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
Fred Drake38419c02001-12-06 22:24:47 +0000637 extra_link_args=['-framework', 'QuickTime',
638 '-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000639## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000640 exts.append( Extension('_TE', ['te/_TEmodule.c'],
641 extra_link_args=['-framework', 'Carbon']) )
Jack Jansenedeea042001-12-09 23:08:54 +0000642 # As there is no standardized place (yet) to put user-installed
643 # Mac libraries on OSX you should put a symlink to your Waste
644 # installation in the same folder as your python source tree.
645 # Or modify the next two lines:-)
646 waste_incs = find_file("WASTE.h", [], ["../waste/C_C++ Headers"])
647 waste_libs = find_library_file(self.compiler, "WASTE", [],
648 ["../waste/Static Libraries"])
649 if waste_incs != None and waste_libs != None:
650 exts.append( Extension('waste',
651 ['waste/wastemodule.c',
652 'Mac/Wastemods/WEObjectHandlers.c',
653 'Mac/Wastemods/WETabHooks.c',
654 'Mac/Wastemods/WETabs.c'
655 ],
656 include_dirs = waste_incs + ['Mac/Wastemods'],
657 library_dirs = waste_libs,
658 libraries = ['WASTE'],
659 extra_link_args = ['-framework', 'Carbon'],
660 ) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000661 exts.append( Extension('_Win', ['win/_Winmodule.c'],
662 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen144ebcc2001-08-05 22:31:19 +0000663
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000664 self.extensions.extend(exts)
665
666 # Call the method for detecting whether _tkinter can be compiled
667 self.detect_tkinter(inc_dirs, lib_dirs)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000668
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000669
670 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000671 # The _tkinter module.
Martin v. Löwisb1d19692001-03-21 07:44:53 +0000672
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000673 # Assume we haven't found any of the libraries or include files
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000674 # The versions with dots are used on Unix, and the versions without
675 # dots on Windows, for detection by cygwin.
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000676 tcllib = tklib = tcl_includes = tk_includes = None
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000677 for version in ['8.4', '84', '8.3', '83', '8.2',
678 '82', '8.1', '81', '8.0', '80']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000679 tklib = self.compiler.find_library_file(lib_dirs,
680 'tk' + version )
681 tcllib = self.compiler.find_library_file(lib_dirs,
682 'tcl' + version )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000683 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000684 # Exit the loop when we've found the Tcl/Tk libraries
685 break
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000686
Fredrik Lundhade711a2001-01-24 08:00:28 +0000687 # Now check for the header files
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000688 if tklib and tcllib:
689 # Check for the include files on Debian, where
690 # they're put in /usr/include/{tcl,tk}X.Y
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27 +0000691 debian_tcl_include = [ '/usr/include/tcl' + version ]
Fred Drake38419c02001-12-06 22:24:47 +0000692 debian_tk_include = [ '/usr/include/tk' + version ] + \
693 debian_tcl_include
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27 +0000694 tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
695 tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000696
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000697 if (tcllib is None or tklib is None and
698 tcl_includes is None or tk_includes is None):
699 # Something's missing, so give up
700 return
Fredrik Lundhade711a2001-01-24 08:00:28 +0000701
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000702 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000703
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000704 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
705 for dir in tcl_includes + tk_includes:
706 if dir not in include_dirs:
707 include_dirs.append(dir)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000708
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000709 # Check for various platform-specific directories
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000710 platform = self.get_platform()
711 if platform == 'sunos5':
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000712 include_dirs.append('/usr/openwin/include')
713 added_lib_dirs.append('/usr/openwin/lib')
714 elif os.path.exists('/usr/X11R6/include'):
715 include_dirs.append('/usr/X11R6/include')
716 added_lib_dirs.append('/usr/X11R6/lib')
717 elif os.path.exists('/usr/X11R5/include'):
718 include_dirs.append('/usr/X11R5/include')
719 added_lib_dirs.append('/usr/X11R5/lib')
720 else:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000721 # Assume default location for X11
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000722 include_dirs.append('/usr/X11/include')
723 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000724
Andrew M. Kuchling89fb72d2001-09-18 20:32:13 +0000725 # If Cygwin, then verify that X is installed before proceeding
726 if platform == 'cygwin':
727 x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
728 if x11_inc is None:
729 # X header files missing, so give up
730 return
731
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000732 # Check for BLT extension
Fred Drake38419c02001-12-06 22:24:47 +0000733 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
734 'BLT8.0'):
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000735 defs.append( ('WITH_BLT', 1) )
736 libs.append('BLT8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000737
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000738 # Add the Tcl/Tk libraries
Fredrik Lundhade711a2001-01-24 08:00:28 +0000739 libs.append('tk'+version)
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000740 libs.append('tcl'+version)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000741
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000742 if platform in ['aix3', 'aix4']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000743 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000744
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000745 # Finally, link with the X11 libraries (not appropriate on cygwin)
746 if platform != "cygwin":
747 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000748
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000749 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
750 define_macros=[('WITH_APPINIT', 1)] + defs,
751 include_dirs = include_dirs,
752 libraries = libs,
753 library_dirs = added_lib_dirs,
754 )
755 self.extensions.append(ext)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000756
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000757 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000758 # *** Uncomment and edit for PIL (TkImaging) extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000759 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000760 # *** Uncomment and edit for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000761 # -DWITH_TOGL togl.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000762 # *** Uncomment these for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000763 # -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000764
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +0000765class PyBuildInstall(install):
766 # Suppress the warning about installation into the lib_dynload
767 # directory, which is not in sys.path when running Python during
768 # installation:
769 def initialize_options (self):
770 install.initialize_options(self)
771 self.warn_dir=0
772
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000773def main():
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000774 # turn off warnings when deprecated modules are imported
775 import warnings
776 warnings.filterwarnings("ignore",category=DeprecationWarning)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000777 setup(name = 'Python standard library',
Neil Schemenauere7e2ece2001-01-17 21:58:00 +0000778 version = '%d.%d' % sys.version_info[:2],
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +0000779 cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000780 # The struct module is defined here, because build_ext won't be
781 # called unless there's at least one extension module defined.
Andrew M. Kuchlingaece4272001-02-28 20:56:49 +0000782 ext_modules=[Extension('struct', ['structmodule.c'])],
783
784 # Scripts to install
785 scripts = ['Tools/scripts/pydoc']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000786 )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000787
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000788# --install-platlib
789if __name__ == '__main__':
790 sysconfig.set_python_build()
791 main()