blob: 037226d7ab4541b208eaac1a77ccf19f684f26d0 [file] [log] [blame]
Andrew M. Kuchling66012fe2001-01-26 21:56:581# Autodetecting setup.py script for building the Python extensions
2#
Fredrik Lundhade711a2001-01-24 08:00:283
Andrew M. Kuchling66012fe2001-01-26 21:56:584__version__ = "$Revision$"
5
6import sys, os, getopt
Andrew M. Kuchling00e0f212001-01-17 15:23:237from distutils import sysconfig
Andrew M. Kuchling8d7f0862001-02-23 16:32:328from distutils import text_file
Marc-André Lemburg7c6fcda2001-01-26 18:03:249from distutils.errors import *
Andrew M. Kuchling00e0f212001-01-17 15:23:2310from distutils.core import Extension, setup
11from distutils.command.build_ext import build_ext
Andrew M. Kuchlingf52d27e2001-05-21 20:29:2712from distutils.command.install import install
Andrew M. Kuchling00e0f212001-01-17 15:23:2313
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:2017def 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:2821
Andrew M. Kuchlingfbe73762001-01-18 18:44:2022 '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:2341 return None
42
Andrew M. Kuchlingfbe73762001-01-18 18:44:2043def 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:2847
Andrew M. Kuchlingfbe73762001-01-18 18:44:2048 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:2352def 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:2857
Jack Jansen144ebcc2001-08-05 22:31:1958def 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)
Michael W. Hudson1e7eb052002-03-01 08:58:3267
Andrew M. Kuchling00e0f212001-01-17 15:23:2368class PyBuildExt(build_ext):
Fredrik Lundhade711a2001-01-24 08:00:2869
Andrew M. Kuchling00e0f212001-01-17 15:23:2370 def build_extensions(self):
Andrew M. Kuchling00e0f212001-01-17 15:23:2371
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:2878
Andrew M. Kuchling00e0f212001-01-17 15:23:2379 # 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:2183 # 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:2385 moddir = os.path.normpath(moddir)
86 srcdir, tail = os.path.split(moddir)
87 srcdir = os.path.normpath(srcdir)
88 moddir = os.path.normpath(moddir)
Michael W. Hudson1e7eb052002-03-01 08:58:3289
Jack Jansen144ebcc2001-08-05 22:31:1990 moddirlist = [moddir]
91 incdirlist = ['./Include']
Michael W. Hudson1e7eb052002-03-01 08:58:3292
Jack Jansen144ebcc2001-08-05 22:31:1993 # Platform-dependent module source and include directories
94 platform = self.get_platform()
Jack Jansen244e7612001-12-05 15:54:2995 if platform == 'darwin':
Jack Jansen144ebcc2001-08-05 22:31:1996 # 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:23100
Andrew M. Kuchling3da989c2001-02-28 22:49:26101 # 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:20105 for ext in self.extensions[:]:
Jack Jansen144ebcc2001-08-05 22:31:19106 ext.sources = [ find_module_file(filename, moddirlist)
Andrew M. Kuchling00e0f212001-01-17 15:23:23107 for filename in ext.sources ]
Jack Jansen144ebcc2001-08-05 22:31:19108 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:20111
Andrew M. Kuchlinge7c87322001-01-19 16:58:21112 # If a module has already been built statically,
Andrew M. Kuchlingfbe73762001-01-18 18:44:20113 # don't build it here
Andrew M. Kuchlinge7c87322001-01-19 16:58:21114 if ext.name in sys.builtin_module_names:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20115 self.extensions.remove(ext)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34116
Andrew M. Kuchling8d7f0862001-02-23 16:32:32117 # Parse Modules/Setup to figure out which modules are turned
Michael W. Hudson1e7eb052002-03-01 08:58:32118 # on in the file.
Andrew M. Kuchling8d7f0862001-02-23 16:32:32119 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()
Michael W. Hudson1e7eb052002-03-01 08:58:32127
Andrew M. Kuchling8d7f0862001-02-23 16:32:32128 for ext in self.extensions[:]:
129 if ext.name in remove_modules:
130 self.extensions.remove(ext)
Michael W. Hudson1e7eb052002-03-01 08:58:32131
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34132 # 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:17141 (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT')
142 args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34143 if linker_so is not None:
Martin v. Löwis2f20dab2001-10-08 13:18:37144 args['linker_so'] = linker_so
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34145 self.compiler.set_executables(**args)
146
Andrew M. Kuchling00e0f212001-01-17 15:23:23147 build_ext.build_extensions(self)
148
Marc-André Lemburg7c6fcda2001-01-26 18:03:24149 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:09156 return
Jack Jansenf49c6f92001-11-01 14:44:15157 # 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:
Michael W. Hudson1e7eb052002-03-01 08:58:32160 self.announce(
161 'WARNING: skipping import check for Carbon-based "%s"' %
162 ext.name)
163 return
Andrew M. Kuchling62686692001-05-21 20:48:09164 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:24174
Fred Drake9028d0a2001-12-06 22:59:54175 # 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.
Michael W. Hudson7ab59232002-03-25 13:59:28179 # If there is a failure, _built_objects may not be there,
180 # so catch the AttributeError and move on.
181 try:
182 for filename in self._built_objects:
183 os.remove(filename)
184 except AttributeError:
185 self.announce('unable to remove files (ignored)')
Fred Drake9028d0a2001-12-06 22:59:54186
Andrew M. Kuchling34febf52001-01-24 03:31:07187 def get_platform (self):
Fredrik Lundhade711a2001-01-24 08:00:28188 # Get value of sys.platform
189 platform = sys.platform
190 if platform[:6] =='cygwin':
191 platform = 'cygwin'
Andrew M. Kuchling3c044942001-02-06 23:37:23192 elif platform[:4] =='beos':
193 platform = 'beos'
Jack Jansen244e7612001-12-05 15:54:29194 elif platform[:6] == 'darwin':
195 platform = 'darwin'
Andrew M. Kuchling34febf52001-01-24 03:31:07196
Fredrik Lundhade711a2001-01-24 08:00:28197 return platform
Andrew M. Kuchling34febf52001-01-24 03:31:07198
Andrew M. Kuchling00e0f212001-01-17 15:23:23199 def detect_modules(self):
Fredrik Lundhade711a2001-01-24 08:00:28200 # Ensure that /usr/local is always used
Andrew M. Kuchlingfbe73762001-01-18 18:44:20201 if '/usr/local/lib' not in self.compiler.library_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35202 self.compiler.library_dirs.insert(0, '/usr/local/lib')
Andrew M. Kuchlingfbe73762001-01-18 18:44:20203 if '/usr/local/include' not in self.compiler.include_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35204 self.compiler.include_dirs.insert(0, '/usr/local/include' )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20205
Martin v. Löwis339d0f72001-08-17 18:39:25206 try:
207 have_unicode = unicode
208 except NameError:
209 have_unicode = 0
210
Andrew M. Kuchlingfbe73762001-01-18 18:44:20211 # lib_dirs and inc_dirs are used to search for files;
212 # if a file is found in one of those directories, it can
213 # be assumed that no additional -I,-L directives are needed.
214 lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
Michael W. Hudson1e7eb052002-03-01 08:58:32215 inc_dirs = self.compiler.include_dirs + ['/usr/include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23216 exts = []
217
Fredrik Lundhade711a2001-01-24 08:00:28218 platform = self.get_platform()
Michael W. Hudson1e7eb052002-03-01 08:58:32219
Fredrik Lundhade711a2001-01-24 08:00:28220 # Check for MacOS X, which doesn't need libm.a at all
221 math_libs = ['m']
Jack Jansen244e7612001-12-05 15:54:29222 if platform in ['darwin', 'beos']:
Fredrik Lundhade711a2001-01-24 08:00:28223 math_libs = []
Michael W. Hudson1e7eb052002-03-01 08:58:32224
Andrew M. Kuchling00e0f212001-01-17 15:23:23225 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
226
227 #
228 # The following modules are all pretty straightforward, and compile
229 # on pretty much any POSIXish platform.
230 #
Fredrik Lundhade711a2001-01-24 08:00:28231
Andrew M. Kuchling00e0f212001-01-17 15:23:23232 # Some modules that are normally always on:
233 exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
234 exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28235
Fred Drake3a40f322001-10-12 21:00:48236 exts.append( Extension('_hotshot', ['_hotshot.c']) )
Fred Drake2de74712001-02-01 05:26:54237 exts.append( Extension('_weakref', ['_weakref.c']) )
Andrew M. Kuchlingd5c43062001-01-17 15:59:25238 exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23239
240 # array objects
241 exts.append( Extension('array', ['arraymodule.c']) )
242 # complex math library functions
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11243 exts.append( Extension('cmath', ['cmathmodule.c'],
244 libraries=math_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28245
Andrew M. Kuchling00e0f212001-01-17 15:23:23246 # math library functions, e.g. sin()
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11247 exts.append( Extension('math', ['mathmodule.c'],
248 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23249 # fast string operations implemented in C
250 exts.append( Extension('strop', ['stropmodule.c']) )
251 # time operations and variables
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11252 exts.append( Extension('time', ['timemodule.c'],
253 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23254 # operator.add() and similar goodies
255 exts.append( Extension('operator', ['operator.c']) )
256 # access to the builtin codecs and codec registry
257 exts.append( Extension('_codecs', ['_codecsmodule.c']) )
Marc-André Lemburg261b8e22001-02-02 12:12:44258 # Python C API test module
Tim Petersd66595f2001-02-04 03:09:53259 exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23260 # static Unicode character database
Martin v. Löwis339d0f72001-08-17 18:39:25261 if have_unicode:
262 exts.append( Extension('unicodedata', ['unicodedata.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23263 # access to ISO C locale support
264 exts.append( Extension('_locale', ['_localemodule.c']) )
265
266 # Modules with some UNIX dependencies -- on by default:
267 # (If you have a really backward UNIX, select and socket may not be
268 # supported...)
269
270 # fcntl(2) and ioctl(2)
271 exts.append( Extension('fcntl', ['fcntlmodule.c']) )
272 # pwd(3)
273 exts.append( Extension('pwd', ['pwdmodule.c']) )
274 # grp(3)
275 exts.append( Extension('grp', ['grpmodule.c']) )
276 # posix (UNIX) errno values
277 exts.append( Extension('errno', ['errnomodule.c']) )
278 # select(2); not on ancient System V
279 exts.append( Extension('select', ['selectmodule.c']) )
280
281 # The md5 module implements the RSA Data Security, Inc. MD5
Fred Drake38419c02001-12-06 22:24:47282 # Message-Digest Algorithm, described in RFC 1321. The
283 # necessary files md5c.c and md5.h are included here.
Andrew M. Kuchling00e0f212001-01-17 15:23:23284 exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
285
286 # The sha module implements the SHA checksum algorithm.
287 # (NIST's Secure Hash Algorithm.)
288 exts.append( Extension('sha', ['shamodule.c']) )
289
Andrew M. Kuchling00e0f212001-01-17 15:23:23290 # Helper module for various ascii-encoders
291 exts.append( Extension('binascii', ['binascii.c']) )
292
293 # Fred Drake's interface to the Python parser
294 exts.append( Extension('parser', ['parsermodule.c']) )
295
296 # Digital Creations' cStringIO and cPickle
297 exts.append( Extension('cStringIO', ['cStringIO.c']) )
298 exts.append( Extension('cPickle', ['cPickle.c']) )
299
300 # Memory-mapped files (also works on Win32).
301 exts.append( Extension('mmap', ['mmapmodule.c']) )
302
303 # Lance Ellinghaus's modules:
304 # enigma-inspired encryption
305 exts.append( Extension('rotor', ['rotormodule.c']) )
306 # syslog daemon interface
307 exts.append( Extension('syslog', ['syslogmodule.c']) )
308
309 # George Neville-Neil's timing module:
310 exts.append( Extension('timing', ['timingmodule.c']) )
311
312 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34313 # Here ends the simple stuff. From here on, modules need certain
314 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23315 #
316
317 # Multimedia modules
318 # These don't work for 64-bit platforms!!!
319 # These represent audio samples or images as strings:
320
Fredrik Lundhade711a2001-01-24 08:00:28321 # Disabled on 64-bit platforms
Andrew M. Kuchling00e0f212001-01-17 15:23:23322 if sys.maxint != 9223372036854775807L:
323 # Operations on audio samples
324 exts.append( Extension('audioop', ['audioop.c']) )
325 # Operations on images
326 exts.append( Extension('imageop', ['imageop.c']) )
327 # Read SGI RGB image files (but coded portably)
328 exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
329
330 # readline
Marc-André Lemburg2efc3232001-01-26 18:23:02331 if self.compiler.find_library_file(lib_dirs, 'readline'):
332 readline_libs = ['readline']
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18333 if self.compiler.find_library_file(lib_dirs,
334 'ncurses'):
335 readline_libs.append('ncurses')
336 elif self.compiler.find_library_file(lib_dirs +
Marc-André Lemburg2efc3232001-01-26 18:23:02337 ['/usr/lib/termcap'],
338 'termcap'):
339 readline_libs.append('termcap')
Andrew M. Kuchling00e0f212001-01-17 15:23:23340 exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg7c6fcda2001-01-26 18:03:24341 library_dirs=['/usr/lib/termcap'],
Marc-André Lemburg2efc3232001-01-26 18:23:02342 libraries=readline_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23343
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18344 # crypt module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23345
346 if self.compiler.find_library_file(lib_dirs, 'crypt'):
347 libs = ['crypt']
348 else:
349 libs = []
350 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
351
352 # socket(2)
353 # Detect SSL support for the socket module
Andrew M. Kuchlingfbe73762001-01-18 18:44:20354 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21355 ['/usr/local/ssl/include',
356 '/usr/contrib/ssl/include/'
357 ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:20358 )
359 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21360 ['/usr/local/ssl/lib',
361 '/usr/contrib/ssl/lib/'
362 ] )
Fredrik Lundhade711a2001-01-24 08:00:28363
Andrew M. Kuchlingfbe73762001-01-18 18:44:20364 if (ssl_incs is not None and
365 ssl_libs is not None):
Andrew M. Kuchling00e0f212001-01-17 15:23:23366 exts.append( Extension('_socket', ['socketmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20367 include_dirs = ssl_incs,
Fredrik Lundhade711a2001-01-24 08:00:28368 library_dirs = ssl_libs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23369 libraries = ['ssl', 'crypto'],
370 define_macros = [('USE_SSL',1)] ) )
371 else:
372 exts.append( Extension('_socket', ['socketmodule.c']) )
373
374 # Modules that provide persistent dictionary-like semantics. You will
375 # probably want to arrange for at least one of them to be available on
376 # your machine, though none are defined by default because of library
377 # dependencies. The Python module anydbm.py provides an
378 # implementation independent wrapper for these; dumbdbm.py provides
379 # similar functionality (but slower of course) implemented in Python.
380
381 # The standard Unix dbm module:
Andrew M. Kuchling34febf52001-01-24 03:31:07382 if platform not in ['cygwin']:
383 if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
384 exts.append( Extension('dbm', ['dbmmodule.c'],
385 libraries = ['ndbm'] ) )
Neil Schemenauerc3ffef62001-10-21 22:14:44386 elif self.compiler.find_library_file(lib_dirs, 'db1'):
387 exts.append( Extension('dbm', ['dbmmodule.c'],
388 libraries = ['db1'] ) )
Andrew M. Kuchling34febf52001-01-24 03:31:07389 else:
390 exts.append( Extension('dbm', ['dbmmodule.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28391
Andrew M. Kuchling00e0f212001-01-17 15:23:23392 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
393 if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
394 exts.append( Extension('gdbm', ['gdbmmodule.c'],
395 libraries = ['gdbm'] ) )
396
397 # Berkeley DB interface.
398 #
399 # This requires the Berkeley DB code, see
400 # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
401 #
402 # Edit the variables DB and DBPORT to point to the db top directory
403 # and the subdirectory of PORT where you built it.
404 #
Greg Ward02fac832001-09-13 15:05:08405 # (See http://pybsddb.sourceforge.net/ for an interface to
406 # Berkeley DB 3.x.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23407
Andrew M. Kuchlinge06337a2001-02-23 16:27:48408 dblib = []
Martin v. Löwisf5c76772001-11-24 09:28:42409 if self.compiler.find_library_file(lib_dirs, 'db-3.2'):
410 dblib = ['db-3.2']
411 elif self.compiler.find_library_file(lib_dirs, 'db-3.1'):
Skip Montanaroe81f4472001-08-21 04:23:21412 dblib = ['db-3.1']
Neil Schemenauerc3ffef62001-10-21 22:14:44413 elif self.compiler.find_library_file(lib_dirs, 'db3'):
414 dblib = ['db3']
Skip Montanaroe81f4472001-08-21 04:23:21415 elif self.compiler.find_library_file(lib_dirs, 'db2'):
416 dblib = ['db2']
417 elif self.compiler.find_library_file(lib_dirs, 'db1'):
418 dblib = ['db1']
419 elif self.compiler.find_library_file(lib_dirs, 'db'):
Andrew M. Kuchlinge06337a2001-02-23 16:27:48420 dblib = ['db']
Michael W. Hudson1e7eb052002-03-01 08:58:32421
Andrew M. Kuchlinge06337a2001-02-23 16:27:48422 db185_incs = find_file('db_185.h', inc_dirs,
423 ['/usr/include/db3', '/usr/include/db2'])
424 db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
425 if db185_incs is not None:
Andrew M. Kuchling00e0f212001-01-17 15:23:23426 exts.append( Extension('bsddb', ['bsddbmodule.c'],
Andrew M. Kuchlinge06337a2001-02-23 16:27:48427 include_dirs = db185_incs,
428 define_macros=[('HAVE_DB_185_H',1)],
429 libraries = dblib ) )
430 elif db_inc is not None:
431 exts.append( Extension('bsddb', ['bsddbmodule.c'],
432 include_dirs = db_inc,
433 libraries = dblib) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23434
435 # The mpz module interfaces to the GNU Multiple Precision library.
Fredrik Lundhade711a2001-01-24 08:00:28436 # You need to ftp the GNU MP library.
Andrew M. Kuchling00e0f212001-01-17 15:23:23437 # This was originally written and tested against GMP 1.2 and 1.3.2.
438 # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
Guido van Rossum8efd6ce2001-12-17 17:24:43439 # haven't tested it recently, and it definitely doesn't work with
440 # GMP 4.0. For more complete modules, refer to
441 # http://gmpy.sourceforge.net and
442 # http://www.egenix.com/files/python/mxNumber.html
Andrew M. Kuchling00e0f212001-01-17 15:23:23443
Greg Ward57fc2102001-10-03 19:59:30444 # A compatible MP library unencumbered by the GPL also exists. It was
Andrew M. Kuchling00e0f212001-01-17 15:23:23445 # posted to comp.sources.misc in volume 40 and is widely available from
446 # FTP archive sites. One URL for it is:
447 # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
448
Andrew M. Kuchling00e0f212001-01-17 15:23:23449 if (self.compiler.find_library_file(lib_dirs, 'gmp')):
450 exts.append( Extension('mpz', ['mpzmodule.c'],
451 libraries = ['gmp'] ) )
452
453
454 # Unix-only modules
Andrew M. Kuchling34febf52001-01-24 03:31:07455 if platform not in ['mac', 'win32']:
Andrew M. Kuchling00e0f212001-01-17 15:23:23456 # Steen Lumholt's termios module
457 exts.append( Extension('termios', ['termios.c']) )
458 # Jeremy Hylton's rlimit interface
Andrew M. Kuchlingfda3c3d2001-09-17 16:19:16459 exts.append( Extension('resource', ['resource.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23460
Andrew M. Kuchlingcf393f32001-02-21 02:38:24461 # Sun yellow pages. Some systems have the functions in libc.
Andrew M. Kuchling6efc6e72001-02-27 20:54:23462 if platform not in ['cygwin']:
463 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
464 libs = ['nsl']
465 else:
466 libs = []
467 exts.append( Extension('nis', ['nismodule.c'],
468 libraries = libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23469
470 # Curses support, requring the System V version of curses, often
Fredrik Lundhade711a2001-01-24 08:00:28471 # provided by the ncurses library.
Andrew M. Kuchling34febf52001-01-24 03:31:07472 if platform == 'sunos4':
Andrew M. Kuchlingb69c7582001-02-28 19:49:57473 inc_dirs += ['/usr/5include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23474 lib_dirs += ['/usr/5lib']
475
476 if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
477 curses_libs = ['ncurses']
478 exts.append( Extension('_curses', ['_cursesmodule.c'],
479 libraries = curses_libs) )
Fred Drake38419c02001-12-06 22:24:47480 elif (self.compiler.find_library_file(lib_dirs, 'curses')
481 and platform != 'darwin'):
Michael W. Hudson1e7eb052002-03-01 08:58:32482 # OSX has an old Berkeley curses, not good enough for
483 # the _curses module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23484 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
485 curses_libs = ['curses', 'terminfo']
486 else:
487 curses_libs = ['curses', 'termcap']
Fredrik Lundhade711a2001-01-24 08:00:28488
Andrew M. Kuchling00e0f212001-01-17 15:23:23489 exts.append( Extension('_curses', ['_cursesmodule.c'],
490 libraries = curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28491
Andrew M. Kuchling00e0f212001-01-17 15:23:23492 # If the curses module is enabled, check for the panel module
Andrew M. Kuchlinge7ffbb22001-12-06 15:57:16493 if (module_enabled(exts, '_curses') and
Andrew M. Kuchling00e0f212001-01-17 15:23:23494 self.compiler.find_library_file(lib_dirs, 'panel')):
495 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
496 libraries = ['panel'] + curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28497
498
Andrew M. Kuchling00e0f212001-01-17 15:23:23499
500 # Lee Busby's SIGFPE modules.
501 # The library to link fpectl with is platform specific.
502 # Choose *one* of the options below for fpectl:
503
Andrew M. Kuchling34febf52001-01-24 03:31:07504 if platform == 'irix5':
Andrew M. Kuchling00e0f212001-01-17 15:23:23505 # For SGI IRIX (tested on 5.3):
506 exts.append( Extension('fpectl', ['fpectlmodule.c'],
507 libraries=['fpe']) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20508 elif 0: # XXX how to detect SunPro?
Fred Drake38419c02001-12-06 22:24:47509 # For Solaris with SunPro compiler (tested on Solaris 2.5
510 # with SunPro C 4.2): (Without the compiler you don't have
511 # -lsunmath.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23512 #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
513 pass
514 else:
515 # For other systems: see instructions in fpectlmodule.c.
516 #fpectl fpectlmodule.c ...
517 exts.append( Extension('fpectl', ['fpectlmodule.c']) )
518
519
520 # Andrew Kuchling's zlib module.
521 # This require zlib 1.1.3 (or later).
522 # See http://www.cdrom.com/pub/infozip/zlib/
Guido van Rossume6970912001-04-15 15:16:12523 zlib_inc = find_file('zlib.h', [], inc_dirs)
524 if zlib_inc is not None:
525 zlib_h = zlib_inc[0] + '/zlib.h'
526 version = '"0.0.0"'
527 version_req = '"1.1.3"'
528 fp = open(zlib_h)
529 while 1:
530 line = fp.readline()
531 if not line:
532 break
533 if line.find('#define ZLIB_VERSION', 0) == 0:
534 version = line.split()[2]
535 break
536 if version >= version_req:
537 if (self.compiler.find_library_file(lib_dirs, 'z')):
538 exts.append( Extension('zlib', ['zlibmodule.c'],
539 libraries = ['z']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23540
541 # Interface to the Expat XML parser
542 #
543 # Expat is written by James Clark and must be downloaded separately
544 # (see below). The pyexpat module was written by Paul Prescod after a
545 # prototype by Jack Jansen.
546 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34547 # The Expat dist includes Windows .lib and .dll files. Home page is
548 # at http://www.jclark.com/xml/expat.html, the current production
549 # release is always ftp://ftp.jclark.com/pub/xml/expat.zip.
Andrew M. Kuchling00e0f212001-01-17 15:23:23550 #
551 # EXPAT_DIR, below, should point to the expat/ directory created by
552 # unpacking the Expat source distribution.
553 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34554 # Note: the expat build process doesn't yet build a libexpat.a; you
555 # can do this manually while we try convince the author to add it. To
556 # do so, cd to EXPAT_DIR, run "make" if you have not done so, then
557 # run:
Andrew M. Kuchling00e0f212001-01-17 15:23:23558 #
559 # ar cr libexpat.a xmltok/*.o xmlparse/*.o
560 #
Andrew M. Kuchlingfbe73762001-01-18 18:44:20561 expat_defs = []
562 expat_incs = find_file('expat.h', inc_dirs, [])
563 if expat_incs is not None:
564 # expat.h was found
565 expat_defs = [('HAVE_EXPAT_H', 1)]
566 else:
567 expat_incs = find_file('xmlparse.h', inc_dirs, [])
Fredrik Lundhade711a2001-01-24 08:00:28568
Martin v. Löwis1ab29b22001-01-21 10:54:52569 if (expat_incs is not None and
Andrew M. Kuchlingfbe73762001-01-18 18:44:20570 self.compiler.find_library_file(lib_dirs, 'expat')):
571 exts.append( Extension('pyexpat', ['pyexpat.c'],
572 define_macros = expat_defs,
573 libraries = ['expat']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23574
575 # Platform-specific libraries
Andrew M. Kuchling34febf52001-01-24 03:31:07576 if platform == 'linux2':
Andrew M. Kuchling00e0f212001-01-17 15:23:23577 # Linux-specific modules
578 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
579
Andrew M. Kuchling34febf52001-01-24 03:31:07580 if platform == 'sunos5':
Fredrik Lundhade711a2001-01-24 08:00:28581 # SunOS specific modules
Andrew M. Kuchling00e0f212001-01-17 15:23:23582 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
Michael W. Hudson1e7eb052002-03-01 08:58:32583
Jack Jansen244e7612001-12-05 15:54:29584 if platform == 'darwin':
Jack Jansen144ebcc2001-08-05 22:31:19585 # Mac OS X specific modules. These are ported over from MacPython
586 # and still experimental. Some (such as gestalt or icglue) are
587 # already generally useful, some (the GUI ones) really need to
588 # be used from a framework.
Jack Jansen2f760c32001-09-04 21:33:12589 #
590 # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
591 # available here. This Makefile variable is also what the install
592 # procedure triggers on.
593 frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
Michael W. Hudson6dcabf32002-03-07 10:04:49594 exts.append( Extension('gestalt', ['gestaltmodule.c'],
Michael W. Hudson7ab59232002-03-25 13:59:28595 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48596 exts.append( Extension('MacOS', ['macosmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32597 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48598 exts.append( Extension('icglue', ['icgluemodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32599 extra_link_args=['-framework', 'Carbon']) )
Fred Drake38419c02001-12-06 22:24:47600 exts.append( Extension('macfs',
601 ['macfsmodule.c',
602 '../Python/getapplbycreator.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32603 extra_link_args=['-framework', 'Carbon']) )
Michael W. Hudson6dcabf32002-03-07 10:04:49604 exts.append( Extension('_CF', ['cf/_CFmodule.c'],
605 extra_link_args=['-framework', 'CoreFoundation']) )
606 exts.append( Extension('_Res', ['res/_Resmodule.c'],
607 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48608 exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32609 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12610 if frameworkdir:
Jack Jansen666b1e72001-10-31 12:11:48611 exts.append( Extension('Nav', ['Nav.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32612 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48613 exts.append( Extension('_AE', ['ae/_AEmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32614 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48615 exts.append( Extension('_App', ['app/_Appmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32616 extra_link_args=['-framework', 'Carbon']) )
Jack Jansendd67a8e2001-12-12 23:03:17617 exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32618 extra_link_args=['-framework', 'Carbon']) )
Just van Rossume9039b12001-12-13 13:41:36619 exts.append( Extension('_CG', ['cg/_CGmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32620 extra_link_args=['-framework', 'ApplicationServices',
Just van Rossume9039b12001-12-13 13:41:36621 '-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48622 exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32623 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48624 exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32625 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48626 exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32627 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48628 exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32629 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48630 exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32631 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48632 exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32633 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48634 exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32635 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48636 exts.append( Extension('_List', ['list/_Listmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32637 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48638 exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32639 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48640 exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32641 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48642 exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32643 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48644 exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32645 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12646 exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
Fred Drake38419c02001-12-06 22:24:47647 extra_link_args=['-framework', 'QuickTime',
648 '-framework', 'Carbon']) )
Jack Jansen38d966b2002-03-26 13:43:04649 exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'],
650 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48651 exts.append( Extension('_TE', ['te/_TEmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32652 extra_link_args=['-framework', 'Carbon']) )
Jack Jansenedeea042001-12-09 23:08:54653 # As there is no standardized place (yet) to put user-installed
654 # Mac libraries on OSX you should put a symlink to your Waste
655 # installation in the same folder as your python source tree.
656 # Or modify the next two lines:-)
657 waste_incs = find_file("WASTE.h", [], ["../waste/C_C++ Headers"])
658 waste_libs = find_library_file(self.compiler, "WASTE", [],
659 ["../waste/Static Libraries"])
660 if waste_incs != None and waste_libs != None:
Michael W. Hudson1e7eb052002-03-01 08:58:32661 exts.append( Extension('waste',
Jack Jansenedeea042001-12-09 23:08:54662 ['waste/wastemodule.c',
663 'Mac/Wastemods/WEObjectHandlers.c',
664 'Mac/Wastemods/WETabHooks.c',
665 'Mac/Wastemods/WETabs.c'
666 ],
667 include_dirs = waste_incs + ['Mac/Wastemods'],
668 library_dirs = waste_libs,
669 libraries = ['WASTE'],
670 extra_link_args = ['-framework', 'Carbon'],
671 ) )
Jack Jansen666b1e72001-10-31 12:11:48672 exts.append( Extension('_Win', ['win/_Winmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32673 extra_link_args=['-framework', 'Carbon']) )
674
Andrew M. Kuchlingfbe73762001-01-18 18:44:20675 self.extensions.extend(exts)
676
677 # Call the method for detecting whether _tkinter can be compiled
678 self.detect_tkinter(inc_dirs, lib_dirs)
Fredrik Lundhade711a2001-01-24 08:00:28679
Andrew M. Kuchlingfbe73762001-01-18 18:44:20680
681 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:23682 # The _tkinter module.
Michael W. Hudson1e7eb052002-03-01 08:58:32683
Andrew M. Kuchlingfbe73762001-01-18 18:44:20684 # Assume we haven't found any of the libraries or include files
Martin v. Löwis3db5b8c2001-07-24 06:54:01685 # The versions with dots are used on Unix, and the versions without
686 # dots on Windows, for detection by cygwin.
Andrew M. Kuchlingfbe73762001-01-18 18:44:20687 tcllib = tklib = tcl_includes = tk_includes = None
Martin v. Löwis3db5b8c2001-07-24 06:54:01688 for version in ['8.4', '84', '8.3', '83', '8.2',
689 '82', '8.1', '81', '8.0', '80']:
Michael W. Hudson1e7eb052002-03-01 08:58:32690 tklib = self.compiler.find_library_file(lib_dirs,
691 'tk' + version )
692 tcllib = self.compiler.find_library_file(lib_dirs,
693 'tcl' + version )
694 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:23695 # Exit the loop when we've found the Tcl/Tk libraries
696 break
Andrew M. Kuchling00e0f212001-01-17 15:23:23697
Fredrik Lundhade711a2001-01-24 08:00:28698 # Now check for the header files
Andrew M. Kuchlingfbe73762001-01-18 18:44:20699 if tklib and tcllib:
700 # Check for the include files on Debian, where
701 # they're put in /usr/include/{tcl,tk}X.Y
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27702 debian_tcl_include = [ '/usr/include/tcl' + version ]
Fred Drake38419c02001-12-06 22:24:47703 debian_tk_include = [ '/usr/include/tk' + version ] + \
704 debian_tcl_include
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27705 tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
706 tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
Andrew M. Kuchling00e0f212001-01-17 15:23:23707
Andrew M. Kuchlingfbe73762001-01-18 18:44:20708 if (tcllib is None or tklib is None and
709 tcl_includes is None or tk_includes is None):
710 # Something's missing, so give up
711 return
Fredrik Lundhade711a2001-01-24 08:00:28712
Andrew M. Kuchlingfbe73762001-01-18 18:44:20713 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:23714
Andrew M. Kuchlingfbe73762001-01-18 18:44:20715 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
716 for dir in tcl_includes + tk_includes:
717 if dir not in include_dirs:
718 include_dirs.append(dir)
Fredrik Lundhade711a2001-01-24 08:00:28719
Andrew M. Kuchlingfbe73762001-01-18 18:44:20720 # Check for various platform-specific directories
Andrew M. Kuchling34febf52001-01-24 03:31:07721 platform = self.get_platform()
722 if platform == 'sunos5':
Andrew M. Kuchlingfbe73762001-01-18 18:44:20723 include_dirs.append('/usr/openwin/include')
724 added_lib_dirs.append('/usr/openwin/lib')
725 elif os.path.exists('/usr/X11R6/include'):
726 include_dirs.append('/usr/X11R6/include')
727 added_lib_dirs.append('/usr/X11R6/lib')
728 elif os.path.exists('/usr/X11R5/include'):
729 include_dirs.append('/usr/X11R5/include')
730 added_lib_dirs.append('/usr/X11R5/lib')
731 else:
Fredrik Lundhade711a2001-01-24 08:00:28732 # Assume default location for X11
Andrew M. Kuchlingfbe73762001-01-18 18:44:20733 include_dirs.append('/usr/X11/include')
734 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:23735
Andrew M. Kuchling89fb72d2001-09-18 20:32:13736 # If Cygwin, then verify that X is installed before proceeding
737 if platform == 'cygwin':
738 x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
739 if x11_inc is None:
740 # X header files missing, so give up
741 return
742
Andrew M. Kuchlingfbe73762001-01-18 18:44:20743 # Check for BLT extension
Fred Drake38419c02001-12-06 22:24:47744 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
745 'BLT8.0'):
Andrew M. Kuchlingfbe73762001-01-18 18:44:20746 defs.append( ('WITH_BLT', 1) )
747 libs.append('BLT8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23748
Andrew M. Kuchlingfbe73762001-01-18 18:44:20749 # Add the Tcl/Tk libraries
Fredrik Lundhade711a2001-01-24 08:00:28750 libs.append('tk'+version)
Andrew M. Kuchlingfbe73762001-01-18 18:44:20751 libs.append('tcl'+version)
Fredrik Lundhade711a2001-01-24 08:00:28752
Andrew M. Kuchling34febf52001-01-24 03:31:07753 if platform in ['aix3', 'aix4']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20754 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:23755
Martin v. Löwis3db5b8c2001-07-24 06:54:01756 # Finally, link with the X11 libraries (not appropriate on cygwin)
757 if platform != "cygwin":
758 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:23759
Andrew M. Kuchlingfbe73762001-01-18 18:44:20760 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
761 define_macros=[('WITH_APPINIT', 1)] + defs,
762 include_dirs = include_dirs,
763 libraries = libs,
764 library_dirs = added_lib_dirs,
765 )
766 self.extensions.append(ext)
Fredrik Lundhade711a2001-01-24 08:00:28767
Andrew M. Kuchlingfbe73762001-01-18 18:44:20768 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:23769 # *** Uncomment and edit for PIL (TkImaging) extension only:
Fredrik Lundhade711a2001-01-24 08:00:28770 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23771 # *** Uncomment and edit for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28772 # -DWITH_TOGL togl.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23773 # *** Uncomment these for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28774 # -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling00e0f212001-01-17 15:23:23775
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27776class PyBuildInstall(install):
777 # Suppress the warning about installation into the lib_dynload
778 # directory, which is not in sys.path when running Python during
779 # installation:
780 def initialize_options (self):
781 install.initialize_options(self)
782 self.warn_dir=0
Michael W. Hudson1e7eb052002-03-01 08:58:32783
Andrew M. Kuchling00e0f212001-01-17 15:23:23784def main():
Andrew M. Kuchling62686692001-05-21 20:48:09785 # turn off warnings when deprecated modules are imported
786 import warnings
787 warnings.filterwarnings("ignore",category=DeprecationWarning)
Andrew M. Kuchling00e0f212001-01-17 15:23:23788 setup(name = 'Python standard library',
Neil Schemenauere7e2ece2001-01-17 21:58:00789 version = '%d.%d' % sys.version_info[:2],
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27790 cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
Andrew M. Kuchling00e0f212001-01-17 15:23:23791 # The struct module is defined here, because build_ext won't be
792 # called unless there's at least one extension module defined.
Andrew M. Kuchlingaece4272001-02-28 20:56:49793 ext_modules=[Extension('struct', ['structmodule.c'])],
794
795 # Scripts to install
796 scripts = ['Tools/scripts/pydoc']
Andrew M. Kuchling00e0f212001-01-17 15:23:23797 )
Fredrik Lundhade711a2001-01-24 08:00:28798
Andrew M. Kuchling00e0f212001-01-17 15:23:23799# --install-platlib
800if __name__ == '__main__':
801 sysconfig.set_python_build()
802 main()