blob: 919bc64cca5d2ffb07c4b6ac9e2d2cb5bd0b0648 [file] [log] [blame]
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +00001# To be fixed:
2# Implement --disable-modules setting
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +00003
4import sys, os, string, getopt
5from distutils import sysconfig
6from distutils.core import Extension, setup
7from distutils.command.build_ext import build_ext
8
9# This global variable is used to hold the list of modules to be disabled.
10disabled_module_list = []
11
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000012def find_file(filename, std_dirs, paths):
13 """Searches for the directory where a given file is located,
14 and returns a possibly-empty list of additional directories, or None
15 if the file couldn't be found at all.
16
17 'filename' is the name of a file, such as readline.h or libcrypto.a.
18 'std_dirs' is the list of standard system directories; if the
19 file is found in one of them, no additional directives are needed.
20 'paths' is a list of additional locations to check; if the file is
21 found in one of them, the resulting list will contain the directory.
22 """
23
24 # Check the standard locations
25 for dir in std_dirs:
26 f = os.path.join(dir, filename)
27 if os.path.exists(f): return []
28
29 # Check the additional directories
30 for dir in paths:
31 f = os.path.join(dir, filename)
32 if os.path.exists(f):
33 return [dir]
34
35 # Not found anywhere
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000036 return None
37
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000038def find_library_file(compiler, libname, std_dirs, paths):
39 filename = compiler.library_filename(libname, lib_type='shared')
40 result = find_file(filename, std_dirs, paths)
41 if result is not None: return result
42
43 filename = compiler.library_filename(libname, lib_type='static')
44 result = find_file(filename, std_dirs, paths)
45 return result
46
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000047def module_enabled(extlist, modname):
48 """Returns whether the module 'modname' is present in the list
49 of extensions 'extlist'."""
50 extlist = [ext for ext in extlist if ext.name == modname]
51 return len(extlist)
52
53class PyBuildExt(build_ext):
54
55 def build_extensions(self):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000056
57 # Detect which modules should be compiled
58 self.detect_modules()
59
60 # Remove modules that are present on the disabled list
61 self.extensions = [ext for ext in self.extensions
62 if ext.name not in disabled_module_list]
63
64 # Fix up the autodetected modules, prefixing all the source files
65 # with Modules/ and adding Python's include directory to the path.
66 (srcdir,) = sysconfig.get_config_vars('srcdir')
67
68 #
69 moddir = os.path.join(os.getcwd(), 'Modules', srcdir)
70 moddir = os.path.normpath(moddir)
71 srcdir, tail = os.path.split(moddir)
72 srcdir = os.path.normpath(srcdir)
73 moddir = os.path.normpath(moddir)
74
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000075 for ext in self.extensions[:]:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000076 ext.sources = [ os.path.join(moddir, filename)
77 for filename in ext.sources ]
78 ext.include_dirs.append( '.' ) # to get config.h
Andrew M. Kuchlinge3d6e412001-01-19 02:50:34 +000079 ext.include_dirs.append( os.path.join(srcdir, './Include') )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000080
81 # Try importing a module; if it's already been built statically,
82 # don't build it here
83 try:
84 __import__(ext.name)
85 except ImportError:
86 pass # Not built, so this is what we expect
87 else:
88 self.extensions.remove(ext)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +000089
90 # When you run "make CC=altcc" or something similar, you really want
91 # those environment variables passed into the setup.py phase. Here's
92 # a small set of useful ones.
93 compiler = os.environ.get('CC')
94 linker_so = os.environ.get('LDSHARED')
95 args = {}
96 # unfortunately, distutils doesn't let us provide separate C and C++
97 # compilers
98 if compiler is not None:
99 args['compiler_so'] = compiler
100 if linker_so is not None:
101 args['linker_so'] = linker_so + ' -shared'
102 self.compiler.set_executables(**args)
103
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000104 build_ext.build_extensions(self)
105
106 def detect_modules(self):
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000107 # Ensure that /usr/local is always used
108 if '/usr/local/lib' not in self.compiler.library_dirs:
109 self.compiler.library_dirs.append('/usr/local/lib')
110 if '/usr/local/include' not in self.compiler.include_dirs:
111 self.compiler.include_dirs.append( '/usr/local/include' )
112
113 # lib_dirs and inc_dirs are used to search for files;
114 # if a file is found in one of those directories, it can
115 # be assumed that no additional -I,-L directives are needed.
116 lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
117 inc_dirs = ['/usr/include'] + self.compiler.include_dirs
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000118 exts = []
119
120 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
121
122 #
123 # The following modules are all pretty straightforward, and compile
124 # on pretty much any POSIXish platform.
125 #
126
127 # Some modules that are normally always on:
128 exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
129 exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000130
Andrew M. Kuchlingd5c43062001-01-17 15:59:25 +0000131 exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000132
133 # array objects
134 exts.append( Extension('array', ['arraymodule.c']) )
135 # complex math library functions
136 exts.append( Extension('cmath', ['cmathmodule.c'], libraries=['m']) )
137 # math library functions, e.g. sin()
138 exts.append( Extension('math', ['mathmodule.c'], libraries=['m']) )
139 # fast string operations implemented in C
140 exts.append( Extension('strop', ['stropmodule.c']) )
141 # time operations and variables
142 exts.append( Extension('time', ['timemodule.c'], libraries=['m']) )
143 # operator.add() and similar goodies
144 exts.append( Extension('operator', ['operator.c']) )
145 # access to the builtin codecs and codec registry
146 exts.append( Extension('_codecs', ['_codecsmodule.c']) )
147 # static Unicode character database
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000148 exts.append( Extension('unicodedata',
149 ['unicodedata.c', 'unicodedatabase.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000150 # Unicode Character Name expansion hash table
151 exts.append( Extension('ucnhash', ['ucnhash.c']) )
152 # access to ISO C locale support
153 exts.append( Extension('_locale', ['_localemodule.c']) )
154
155 # Modules with some UNIX dependencies -- on by default:
156 # (If you have a really backward UNIX, select and socket may not be
157 # supported...)
158
159 # fcntl(2) and ioctl(2)
160 exts.append( Extension('fcntl', ['fcntlmodule.c']) )
161 # pwd(3)
162 exts.append( Extension('pwd', ['pwdmodule.c']) )
163 # grp(3)
164 exts.append( Extension('grp', ['grpmodule.c']) )
165 # posix (UNIX) errno values
166 exts.append( Extension('errno', ['errnomodule.c']) )
167 # select(2); not on ancient System V
168 exts.append( Extension('select', ['selectmodule.c']) )
169
170 # The md5 module implements the RSA Data Security, Inc. MD5
171 # Message-Digest Algorithm, described in RFC 1321. The necessary files
172 # md5c.c and md5.h are included here.
173 exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
174
175 # The sha module implements the SHA checksum algorithm.
176 # (NIST's Secure Hash Algorithm.)
177 exts.append( Extension('sha', ['shamodule.c']) )
178
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000179 # Tommy Burnette's 'new' module (creates new empty objects of certain
180 # kinds):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000181 exts.append( Extension('new', ['newmodule.c']) )
182
183 # Helper module for various ascii-encoders
184 exts.append( Extension('binascii', ['binascii.c']) )
185
186 # Fred Drake's interface to the Python parser
187 exts.append( Extension('parser', ['parsermodule.c']) )
188
189 # Digital Creations' cStringIO and cPickle
190 exts.append( Extension('cStringIO', ['cStringIO.c']) )
191 exts.append( Extension('cPickle', ['cPickle.c']) )
192
193 # Memory-mapped files (also works on Win32).
194 exts.append( Extension('mmap', ['mmapmodule.c']) )
195
196 # Lance Ellinghaus's modules:
197 # enigma-inspired encryption
198 exts.append( Extension('rotor', ['rotormodule.c']) )
199 # syslog daemon interface
200 exts.append( Extension('syslog', ['syslogmodule.c']) )
201
202 # George Neville-Neil's timing module:
203 exts.append( Extension('timing', ['timingmodule.c']) )
204
205 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000206 # Here ends the simple stuff. From here on, modules need certain
207 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000208 #
209
210 # Multimedia modules
211 # These don't work for 64-bit platforms!!!
212 # These represent audio samples or images as strings:
213
214 # Disabled on 64-bit platforms
215 if sys.maxint != 9223372036854775807L:
216 # Operations on audio samples
217 exts.append( Extension('audioop', ['audioop.c']) )
218 # Operations on images
219 exts.append( Extension('imageop', ['imageop.c']) )
220 # Read SGI RGB image files (but coded portably)
221 exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
222
223 # readline
Andrew M. Kuchling4f9e9432001-01-17 20:20:44 +0000224 if (self.compiler.find_library_file(lib_dirs, 'readline')):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000225 exts.append( Extension('readline', ['readline.c'],
226 libraries=['readline', 'termcap']) )
227
228 # The crypt module is now disabled by default because it breaks builds
229 # on many systems (where -lcrypt is needed), e.g. Linux (I believe).
230
231 if self.compiler.find_library_file(lib_dirs, 'crypt'):
232 libs = ['crypt']
233 else:
234 libs = []
235 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
236
237 # socket(2)
238 # Detect SSL support for the socket module
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000239 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
240 ['/usr/local/ssl/include']
241 )
242 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
243 ['/usr/local/ssl/lib'] )
244
245 if (ssl_incs is not None and
246 ssl_libs is not None):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000247 exts.append( Extension('_socket', ['socketmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000248 include_dirs = ssl_incs,
249 library_dirs = ssl_libs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000250 libraries = ['ssl', 'crypto'],
251 define_macros = [('USE_SSL',1)] ) )
252 else:
253 exts.append( Extension('_socket', ['socketmodule.c']) )
254
255 # Modules that provide persistent dictionary-like semantics. You will
256 # probably want to arrange for at least one of them to be available on
257 # your machine, though none are defined by default because of library
258 # dependencies. The Python module anydbm.py provides an
259 # implementation independent wrapper for these; dumbdbm.py provides
260 # similar functionality (but slower of course) implemented in Python.
261
262 # The standard Unix dbm module:
263 if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
264 exts.append( Extension('dbm', ['dbmmodule.c'],
265 libraries = ['ndbm'] ) )
266 else:
267 exts.append( Extension('dbm', ['dbmmodule.c']) )
268
269 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
270 if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
271 exts.append( Extension('gdbm', ['gdbmmodule.c'],
272 libraries = ['gdbm'] ) )
273
274 # Berkeley DB interface.
275 #
276 # This requires the Berkeley DB code, see
277 # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
278 #
279 # Edit the variables DB and DBPORT to point to the db top directory
280 # and the subdirectory of PORT where you built it.
281 #
282 # (See http://electricrain.com/greg/python/bsddb3/ for an interface to
283 # BSD DB 3.x.)
284
285 # Note: If a db.h file is found by configure, bsddb will be enabled
286 # automatically via Setup.config.in. It only needs to be enabled here
287 # if it is not automatically enabled there; check the generated
288 # Setup.config before enabling it here.
289
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000290 db_incs = find_file('db_185.h', inc_dirs, [])
291 if (db_incs is not None and
292 self.compiler.find_library_file(lib_dirs, 'db') ):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000293 exts.append( Extension('bsddb', ['bsddbmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000294 include_dirs = db_incs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000295 libraries = ['db'] ) )
296
297 # The mpz module interfaces to the GNU Multiple Precision library.
298 # You need to ftp the GNU MP library.
299 # This was originally written and tested against GMP 1.2 and 1.3.2.
300 # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
301 # haven't tested it recently. For a more complete module,
302 # refer to pympz.sourceforge.net.
303
304 # A compatible MP library unencombered by the GPL also exists. It was
305 # posted to comp.sources.misc in volume 40 and is widely available from
306 # FTP archive sites. One URL for it is:
307 # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
308
309 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
310 if (self.compiler.find_library_file(lib_dirs, 'gmp')):
311 exts.append( Extension('mpz', ['mpzmodule.c'],
312 libraries = ['gmp'] ) )
313
314
315 # Unix-only modules
316 if sys.platform not in ['mac', 'win32']:
317 # Steen Lumholt's termios module
318 exts.append( Extension('termios', ['termios.c']) )
319 # Jeremy Hylton's rlimit interface
320 exts.append( Extension('resource', ['resource.c']) )
321
322 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
323 exts.append( Extension('nis', ['nismodule.c'],
324 libraries = ['nsl']) )
325
326 # Curses support, requring the System V version of curses, often
327 # provided by the ncurses library.
328 if sys.platform == 'sunos4':
329 include_dirs += ['/usr/5include']
330 lib_dirs += ['/usr/5lib']
331
332 if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
333 curses_libs = ['ncurses']
334 exts.append( Extension('_curses', ['_cursesmodule.c'],
335 libraries = curses_libs) )
336 elif (self.compiler.find_library_file(lib_dirs, 'curses')):
337 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
338 curses_libs = ['curses', 'terminfo']
339 else:
340 curses_libs = ['curses', 'termcap']
341
342 exts.append( Extension('_curses', ['_cursesmodule.c'],
343 libraries = curses_libs) )
344
345 # If the curses module is enabled, check for the panel module
346 if (os.path.exists('Modules/_curses_panel.c') and
347 module_enabled(exts, '_curses') and
348 self.compiler.find_library_file(lib_dirs, 'panel')):
349 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
350 libraries = ['panel'] + curses_libs) )
351
352
353
354 # Lee Busby's SIGFPE modules.
355 # The library to link fpectl with is platform specific.
356 # Choose *one* of the options below for fpectl:
357
358 if sys.platform == 'irix5':
359 # For SGI IRIX (tested on 5.3):
360 exts.append( Extension('fpectl', ['fpectlmodule.c'],
361 libraries=['fpe']) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000362 elif 0: # XXX how to detect SunPro?
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000363 # For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2):
364 # (Without the compiler you don't have -lsunmath.)
365 #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
366 pass
367 else:
368 # For other systems: see instructions in fpectlmodule.c.
369 #fpectl fpectlmodule.c ...
370 exts.append( Extension('fpectl', ['fpectlmodule.c']) )
371
372
373 # Andrew Kuchling's zlib module.
374 # This require zlib 1.1.3 (or later).
375 # See http://www.cdrom.com/pub/infozip/zlib/
376 if (self.compiler.find_library_file(lib_dirs, 'z')):
377 exts.append( Extension('zlib', ['zlibmodule.c'],
378 libraries = ['z']) )
379
380 # Interface to the Expat XML parser
381 #
382 # Expat is written by James Clark and must be downloaded separately
383 # (see below). The pyexpat module was written by Paul Prescod after a
384 # prototype by Jack Jansen.
385 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000386 # The Expat dist includes Windows .lib and .dll files. Home page is
387 # at http://www.jclark.com/xml/expat.html, the current production
388 # release is always ftp://ftp.jclark.com/pub/xml/expat.zip.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000389 #
390 # EXPAT_DIR, below, should point to the expat/ directory created by
391 # unpacking the Expat source distribution.
392 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000393 # Note: the expat build process doesn't yet build a libexpat.a; you
394 # can do this manually while we try convince the author to add it. To
395 # do so, cd to EXPAT_DIR, run "make" if you have not done so, then
396 # run:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000397 #
398 # ar cr libexpat.a xmltok/*.o xmlparse/*.o
399 #
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000400 expat_defs = []
401 expat_incs = find_file('expat.h', inc_dirs, [])
402 if expat_incs is not None:
403 # expat.h was found
404 expat_defs = [('HAVE_EXPAT_H', 1)]
405 else:
406 expat_incs = find_file('xmlparse.h', inc_dirs, [])
407
408 if (expat_incs and
409 self.compiler.find_library_file(lib_dirs, 'expat')):
410 exts.append( Extension('pyexpat', ['pyexpat.c'],
411 define_macros = expat_defs,
412 libraries = ['expat']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000413
414 # Platform-specific libraries
415 plat = sys.platform
416 if plat == 'linux2':
417 # Linux-specific modules
418 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
419
420 if plat == 'sunos5':
421 # SunOS specific modules
422 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
423
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000424 self.extensions.extend(exts)
425
426 # Call the method for detecting whether _tkinter can be compiled
427 self.detect_tkinter(inc_dirs, lib_dirs)
428
429
430 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000431 # The _tkinter module.
432 #
433 # The command for _tkinter is long and site specific. Please
434 # uncomment and/or edit those parts as indicated. If you don't have a
435 # specific extension (e.g. Tix or BLT), leave the corresponding line
436 # commented out. (Leave the trailing backslashes in! If you
437 # experience strange errors, you may want to join all uncommented
438 # lines and remove the backslashes -- the backslash interpretation is
439 # done by the shell's "read" command and it may not be implemented on
440 # every system.
441
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000442 # Assume we haven't found any of the libraries or include files
443 tcllib = tklib = tcl_includes = tk_includes = None
Andrew M. Kuchlingd5c43062001-01-17 15:59:25 +0000444 for version in ['8.4', '8.3', '8.2', '8.1', '8.0']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000445 tklib = self.compiler.find_library_file(lib_dirs,
446 'tk' + version )
447 tcllib = self.compiler.find_library_file(lib_dirs,
448 'tcl' + version )
449 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000450 # Exit the loop when we've found the Tcl/Tk libraries
451 break
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000452
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000453 # Now check for the header files
454 if tklib and tcllib:
455 # Check for the include files on Debian, where
456 # they're put in /usr/include/{tcl,tk}X.Y
457 debian_tcl_include = ( '/usr/include/tcl' + version )
458 debian_tk_include = ( '/usr/include/tk' + version )
459 tcl_includes = find_file('tcl.h', inc_dirs,
460 [debian_tcl_include]
461 )
462 tk_includes = find_file('tk.h', inc_dirs,
463 [debian_tk_include]
464 )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000465
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000466 if (tcllib is None or tklib is None and
467 tcl_includes is None or tk_includes is None):
468 # Something's missing, so give up
469 return
470
471 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000472
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000473 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
474 for dir in tcl_includes + tk_includes:
475 if dir not in include_dirs:
476 include_dirs.append(dir)
477
478 # Check for various platform-specific directories
479 if sys.platform == 'sunos5':
480 include_dirs.append('/usr/openwin/include')
481 added_lib_dirs.append('/usr/openwin/lib')
482 elif os.path.exists('/usr/X11R6/include'):
483 include_dirs.append('/usr/X11R6/include')
484 added_lib_dirs.append('/usr/X11R6/lib')
485 elif os.path.exists('/usr/X11R5/include'):
486 include_dirs.append('/usr/X11R5/include')
487 added_lib_dirs.append('/usr/X11R5/lib')
488 else:
489 # Assume default location for X11
490 include_dirs.append('/usr/X11/include')
491 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000492
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000493 # Check for Tix extension
494 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'tix4.1.8.0'):
495 defs.append( ('WITH_TIX', 1) )
496 libs.append('tix4.1.8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000497
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000498 # Check for BLT extension
499 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'BLT8.0'):
500 defs.append( ('WITH_BLT', 1) )
501 libs.append('BLT8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000502
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000503 # Add the Tcl/Tk libraries
504 libs.append('tk'+version)
505 libs.append('tcl'+version)
506
507 if sys.platform in ['aix3', 'aix4']:
508 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000509
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000510 # Finally, link with the X11 libraries
511 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000512
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000513 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
514 define_macros=[('WITH_APPINIT', 1)] + defs,
515 include_dirs = include_dirs,
516 libraries = libs,
517 library_dirs = added_lib_dirs,
518 )
519 self.extensions.append(ext)
520
521 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000522 # *** Uncomment and edit for PIL (TkImaging) extension only:
523 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
524 # *** Uncomment and edit for TOGL extension only:
525 # -DWITH_TOGL togl.c \
526 # *** Uncomment these for TOGL extension only:
527 # -lGL -lGLU -lXext -lXmu \
528
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000529def main():
530 setup(name = 'Python standard library',
Neil Schemenauere7e2ece2001-01-17 21:58:00 +0000531 version = '%d.%d' % sys.version_info[:2],
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000532 cmdclass = {'build_ext':PyBuildExt},
533 # The struct module is defined here, because build_ext won't be
534 # called unless there's at least one extension module defined.
535 ext_modules=[Extension('struct', ['structmodule.c'])]
536 )
537
538# --install-platlib
539if __name__ == '__main__':
540 sysconfig.set_python_build()
541 main()