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