blob: ae2ef0a06eb0f4835815b1d2f2095d0e6075c24d [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
Michael W. Hudsonca785ac2002-12-24 14:45:546import sys, os, getopt, imp
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
Jason Tishler763603d2003-02-21 12:18:17164 # Workaround for Cygwin: Cygwin currently has fork issues when many
165 # modules have been imported
166 if self.get_platform() == 'cygwin':
167 self.announce('WARNING: skipping import check for Cygwin-based "%s"'
168 % ext.name)
169 return
Michael W. Hudsonca785ac2002-12-24 14:45:54170 ext_filename = os.path.join(
171 self.build_lib,
172 self.get_ext_filename(self.get_ext_fullname(ext.name)))
Andrew M. Kuchling62686692001-05-21 20:48:09173 try:
Michael W. Hudson58b245c2002-12-24 14:52:49174 imp.load_dynamic(ext.name, ext_filename)
Michael W. Hudsonca785ac2002-12-24 14:45:54175 except ImportError, why:
Michael W. Hudsond4781522002-12-06 15:33:01176 if 1:
177 self.announce('*** WARNING: renaming "%s" since importing it'
178 ' failed: %s' % (ext.name, why))
179 assert not self.inplace
180 basename, tail = os.path.splitext(ext_filename)
181 newname = basename + "_failed" + tail
182 if os.path.exists(newname): os.remove(newname)
183 os.rename(ext_filename, newname)
Marc-André Lemburg7c6fcda2001-01-26 18:03:24184
Michael W. Hudsond4781522002-12-06 15:33:01185 # XXX -- This relies on a Vile HACK in
186 # distutils.command.build_ext.build_extension(). The
187 # _built_objects attribute is stored there strictly for
188 # use here.
189 # If there is a failure, _built_objects may not be there,
190 # so catch the AttributeError and move on.
191 try:
192 for filename in self._built_objects:
193 os.remove(filename)
194 except AttributeError:
195 self.announce('unable to remove files (ignored)')
196 else:
197 self.announce('*** WARNING: importing extension "%s" '
198 'failed: %s' % (ext.name, why))
Fred Drake9028d0a2001-12-06 22:59:54199
Andrew M. Kuchling34febf52001-01-24 03:31:07200 def get_platform (self):
Fredrik Lundhade711a2001-01-24 08:00:28201 # Get value of sys.platform
202 platform = sys.platform
203 if platform[:6] =='cygwin':
204 platform = 'cygwin'
Andrew M. Kuchling3c044942001-02-06 23:37:23205 elif platform[:4] =='beos':
206 platform = 'beos'
Jack Jansen244e7612001-12-05 15:54:29207 elif platform[:6] == 'darwin':
208 platform = 'darwin'
Andrew M. Kuchling34febf52001-01-24 03:31:07209
Fredrik Lundhade711a2001-01-24 08:00:28210 return platform
Andrew M. Kuchling34febf52001-01-24 03:31:07211
Andrew M. Kuchling00e0f212001-01-17 15:23:23212 def detect_modules(self):
Fredrik Lundhade711a2001-01-24 08:00:28213 # Ensure that /usr/local is always used
Andrew M. Kuchlingfbe73762001-01-18 18:44:20214 if '/usr/local/lib' not in self.compiler.library_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35215 self.compiler.library_dirs.insert(0, '/usr/local/lib')
Andrew M. Kuchlingfbe73762001-01-18 18:44:20216 if '/usr/local/include' not in self.compiler.include_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35217 self.compiler.include_dirs.insert(0, '/usr/local/include' )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20218
Martin v. Löwis339d0f72001-08-17 18:39:25219 try:
220 have_unicode = unicode
221 except NameError:
222 have_unicode = 0
223
Andrew M. Kuchlingfbe73762001-01-18 18:44:20224 # lib_dirs and inc_dirs are used to search for files;
225 # if a file is found in one of those directories, it can
226 # be assumed that no additional -I,-L directives are needed.
227 lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
Michael W. Hudson1e7eb052002-03-01 08:58:32228 inc_dirs = self.compiler.include_dirs + ['/usr/include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23229 exts = []
230
Fredrik Lundhade711a2001-01-24 08:00:28231 platform = self.get_platform()
Michael W. Hudson1e7eb052002-03-01 08:58:32232
Fredrik Lundhade711a2001-01-24 08:00:28233 # Check for MacOS X, which doesn't need libm.a at all
234 math_libs = ['m']
Jack Jansen244e7612001-12-05 15:54:29235 if platform in ['darwin', 'beos']:
Fredrik Lundhade711a2001-01-24 08:00:28236 math_libs = []
Michael W. Hudson1e7eb052002-03-01 08:58:32237
Andrew M. Kuchling00e0f212001-01-17 15:23:23238 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
239
240 #
241 # The following modules are all pretty straightforward, and compile
242 # on pretty much any POSIXish platform.
243 #
Fredrik Lundhade711a2001-01-24 08:00:28244
Andrew M. Kuchling00e0f212001-01-17 15:23:23245 # Some modules that are normally always on:
246 exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
247 exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28248
Fred Drake3a40f322001-10-12 21:00:48249 exts.append( Extension('_hotshot', ['_hotshot.c']) )
Fred Drake2de74712001-02-01 05:26:54250 exts.append( Extension('_weakref', ['_weakref.c']) )
Andrew M. Kuchlingd5c43062001-01-17 15:59:25251 exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23252
253 # array objects
254 exts.append( Extension('array', ['arraymodule.c']) )
255 # complex math library functions
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11256 exts.append( Extension('cmath', ['cmathmodule.c'],
257 libraries=math_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28258
Andrew M. Kuchling00e0f212001-01-17 15:23:23259 # math library functions, e.g. sin()
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11260 exts.append( Extension('math', ['mathmodule.c'],
261 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23262 # fast string operations implemented in C
263 exts.append( Extension('strop', ['stropmodule.c']) )
264 # time operations and variables
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11265 exts.append( Extension('time', ['timemodule.c'],
266 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23267 # operator.add() and similar goodies
268 exts.append( Extension('operator', ['operator.c']) )
269 # access to the builtin codecs and codec registry
270 exts.append( Extension('_codecs', ['_codecsmodule.c']) )
Marc-André Lemburg261b8e22001-02-02 12:12:44271 # Python C API test module
Tim Petersd66595f2001-02-04 03:09:53272 exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23273 # static Unicode character database
Martin v. Löwis339d0f72001-08-17 18:39:25274 if have_unicode:
275 exts.append( Extension('unicodedata', ['unicodedata.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23276 # access to ISO C locale support
277 exts.append( Extension('_locale', ['_localemodule.c']) )
278
279 # Modules with some UNIX dependencies -- on by default:
280 # (If you have a really backward UNIX, select and socket may not be
281 # supported...)
282
283 # fcntl(2) and ioctl(2)
284 exts.append( Extension('fcntl', ['fcntlmodule.c']) )
285 # pwd(3)
286 exts.append( Extension('pwd', ['pwdmodule.c']) )
287 # grp(3)
288 exts.append( Extension('grp', ['grpmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23289 # select(2); not on ancient System V
290 exts.append( Extension('select', ['selectmodule.c']) )
291
292 # The md5 module implements the RSA Data Security, Inc. MD5
Fred Drake38419c02001-12-06 22:24:47293 # Message-Digest Algorithm, described in RFC 1321. The
294 # necessary files md5c.c and md5.h are included here.
Andrew M. Kuchling00e0f212001-01-17 15:23:23295 exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
296
297 # The sha module implements the SHA checksum algorithm.
298 # (NIST's Secure Hash Algorithm.)
299 exts.append( Extension('sha', ['shamodule.c']) )
300
Andrew M. Kuchling00e0f212001-01-17 15:23:23301 # Helper module for various ascii-encoders
302 exts.append( Extension('binascii', ['binascii.c']) )
303
304 # Fred Drake's interface to the Python parser
305 exts.append( Extension('parser', ['parsermodule.c']) )
306
307 # Digital Creations' cStringIO and cPickle
308 exts.append( Extension('cStringIO', ['cStringIO.c']) )
309 exts.append( Extension('cPickle', ['cPickle.c']) )
310
311 # Memory-mapped files (also works on Win32).
312 exts.append( Extension('mmap', ['mmapmodule.c']) )
313
314 # Lance Ellinghaus's modules:
315 # enigma-inspired encryption
316 exts.append( Extension('rotor', ['rotormodule.c']) )
317 # syslog daemon interface
318 exts.append( Extension('syslog', ['syslogmodule.c']) )
319
320 # George Neville-Neil's timing module:
321 exts.append( Extension('timing', ['timingmodule.c']) )
322
323 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34324 # Here ends the simple stuff. From here on, modules need certain
325 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23326 #
327
328 # Multimedia modules
329 # These don't work for 64-bit platforms!!!
330 # These represent audio samples or images as strings:
331
Fredrik Lundhade711a2001-01-24 08:00:28332 # Disabled on 64-bit platforms
Andrew M. Kuchling00e0f212001-01-17 15:23:23333 if sys.maxint != 9223372036854775807L:
334 # Operations on audio samples
335 exts.append( Extension('audioop', ['audioop.c']) )
336 # Operations on images
337 exts.append( Extension('imageop', ['imageop.c']) )
338 # Read SGI RGB image files (but coded portably)
339 exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
340
341 # readline
Marc-André Lemburg2efc3232001-01-26 18:23:02342 if self.compiler.find_library_file(lib_dirs, 'readline'):
343 readline_libs = ['readline']
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18344 if self.compiler.find_library_file(lib_dirs,
345 'ncurses'):
346 readline_libs.append('ncurses')
347 elif self.compiler.find_library_file(lib_dirs +
Marc-André Lemburg2efc3232001-01-26 18:23:02348 ['/usr/lib/termcap'],
349 'termcap'):
350 readline_libs.append('termcap')
Andrew M. Kuchling00e0f212001-01-17 15:23:23351 exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg7c6fcda2001-01-26 18:03:24352 library_dirs=['/usr/lib/termcap'],
Marc-André Lemburg2efc3232001-01-26 18:23:02353 libraries=readline_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23354
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18355 # crypt module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23356
357 if self.compiler.find_library_file(lib_dirs, 'crypt'):
358 libs = ['crypt']
359 else:
360 libs = []
361 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
362
363 # socket(2)
364 # Detect SSL support for the socket module
Andrew M. Kuchlingfbe73762001-01-18 18:44:20365 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21366 ['/usr/local/ssl/include',
367 '/usr/contrib/ssl/include/'
368 ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:20369 )
370 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21371 ['/usr/local/ssl/lib',
372 '/usr/contrib/ssl/lib/'
373 ] )
Fredrik Lundhade711a2001-01-24 08:00:28374
Martin v. Löwisfeacecc2003-05-18 13:42:58375 if ssl_incs is not None:
376 krb5_h = find_file('krb5.h', inc_dirs,
377 ['/usr/kerberos/include'])
378 if krb5_h:
379 ssl_incs += krb5_h
Barry Warsaw971f0f02003-04-27 04:00:01380
381 if ssl_incs is not None and ssl_libs is not None:
Barry Warsaw9f3e9492002-10-10 00:59:16382 rtlibs = None
383 if platform.startswith('sunos'):
384 rtlibs = ssl_libs
Andrew M. Kuchling00e0f212001-01-17 15:23:23385 exts.append( Extension('_socket', ['socketmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20386 include_dirs = ssl_incs,
Fredrik Lundhade711a2001-01-24 08:00:28387 library_dirs = ssl_libs,
Barry Warsaw9f3e9492002-10-10 00:59:16388 runtime_library_dirs = rtlibs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23389 libraries = ['ssl', 'crypto'],
390 define_macros = [('USE_SSL',1)] ) )
391 else:
392 exts.append( Extension('_socket', ['socketmodule.c']) )
393
394 # Modules that provide persistent dictionary-like semantics. You will
395 # probably want to arrange for at least one of them to be available on
396 # your machine, though none are defined by default because of library
397 # dependencies. The Python module anydbm.py provides an
398 # implementation independent wrapper for these; dumbdbm.py provides
399 # similar functionality (but slower of course) implemented in Python.
400
401 # The standard Unix dbm module:
Andrew M. Kuchling34febf52001-01-24 03:31:07402 if platform not in ['cygwin']:
403 if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
404 exts.append( Extension('dbm', ['dbmmodule.c'],
405 libraries = ['ndbm'] ) )
Neil Schemenauerc3ffef62001-10-21 22:14:44406 elif self.compiler.find_library_file(lib_dirs, 'db1'):
407 exts.append( Extension('dbm', ['dbmmodule.c'],
408 libraries = ['db1'] ) )
Barry Warsaw8e0ef042003-05-22 17:36:54409 elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
410 exts.append( Extension('dbm', ['dbmmodule.c'],
411 libraries = ['gdbm'] ) )
Andrew M. Kuchling34febf52001-01-24 03:31:07412 else:
413 exts.append( Extension('dbm', ['dbmmodule.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28414
Andrew M. Kuchling00e0f212001-01-17 15:23:23415 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
416 if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
417 exts.append( Extension('gdbm', ['gdbmmodule.c'],
418 libraries = ['gdbm'] ) )
419
420 # Berkeley DB interface.
421 #
422 # This requires the Berkeley DB code, see
423 # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
424 #
425 # Edit the variables DB and DBPORT to point to the db top directory
426 # and the subdirectory of PORT where you built it.
427 #
Greg Ward02fac832001-09-13 15:05:08428 # (See http://pybsddb.sourceforge.net/ for an interface to
429 # Berkeley DB 3.x.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23430
Andrew M. Kuchlinge06337a2001-02-23 16:27:48431 dblib = []
Martin v. Löwisf5c76772001-11-24 09:28:42432 if self.compiler.find_library_file(lib_dirs, 'db-3.2'):
433 dblib = ['db-3.2']
434 elif self.compiler.find_library_file(lib_dirs, 'db-3.1'):
Skip Montanaroe81f4472001-08-21 04:23:21435 dblib = ['db-3.1']
Neil Schemenauerc3ffef62001-10-21 22:14:44436 elif self.compiler.find_library_file(lib_dirs, 'db3'):
437 dblib = ['db3']
Skip Montanaroe81f4472001-08-21 04:23:21438 elif self.compiler.find_library_file(lib_dirs, 'db2'):
439 dblib = ['db2']
440 elif self.compiler.find_library_file(lib_dirs, 'db1'):
441 dblib = ['db1']
442 elif self.compiler.find_library_file(lib_dirs, 'db'):
Andrew M. Kuchlinge06337a2001-02-23 16:27:48443 dblib = ['db']
Michael W. Hudson1e7eb052002-03-01 08:58:32444
Andrew M. Kuchlinge06337a2001-02-23 16:27:48445 db185_incs = find_file('db_185.h', inc_dirs,
446 ['/usr/include/db3', '/usr/include/db2'])
447 db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
448 if db185_incs is not None:
Andrew M. Kuchling00e0f212001-01-17 15:23:23449 exts.append( Extension('bsddb', ['bsddbmodule.c'],
Andrew M. Kuchlinge06337a2001-02-23 16:27:48450 include_dirs = db185_incs,
451 define_macros=[('HAVE_DB_185_H',1)],
452 libraries = dblib ) )
453 elif db_inc is not None:
454 exts.append( Extension('bsddb', ['bsddbmodule.c'],
455 include_dirs = db_inc,
456 libraries = dblib) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23457
458 # The mpz module interfaces to the GNU Multiple Precision library.
Fredrik Lundhade711a2001-01-24 08:00:28459 # You need to ftp the GNU MP library.
Andrew M. Kuchling00e0f212001-01-17 15:23:23460 # This was originally written and tested against GMP 1.2 and 1.3.2.
461 # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
Guido van Rossum8efd6ce2001-12-17 17:24:43462 # haven't tested it recently, and it definitely doesn't work with
463 # GMP 4.0. For more complete modules, refer to
464 # http://gmpy.sourceforge.net and
465 # http://www.egenix.com/files/python/mxNumber.html
Andrew M. Kuchling00e0f212001-01-17 15:23:23466
Greg Ward57fc2102001-10-03 19:59:30467 # A compatible MP library unencumbered by the GPL also exists. It was
Andrew M. Kuchling00e0f212001-01-17 15:23:23468 # posted to comp.sources.misc in volume 40 and is widely available from
469 # FTP archive sites. One URL for it is:
470 # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
471
Andrew M. Kuchling00e0f212001-01-17 15:23:23472 if (self.compiler.find_library_file(lib_dirs, 'gmp')):
473 exts.append( Extension('mpz', ['mpzmodule.c'],
474 libraries = ['gmp'] ) )
475
476
477 # Unix-only modules
Andrew M. Kuchling34febf52001-01-24 03:31:07478 if platform not in ['mac', 'win32']:
Andrew M. Kuchling00e0f212001-01-17 15:23:23479 # Steen Lumholt's termios module
480 exts.append( Extension('termios', ['termios.c']) )
481 # Jeremy Hylton's rlimit interface
Andrew M. Kuchlingfda3c3d2001-09-17 16:19:16482 exts.append( Extension('resource', ['resource.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23483
Andrew M. Kuchlingcf393f32001-02-21 02:38:24484 # Sun yellow pages. Some systems have the functions in libc.
Andrew M. Kuchling6efc6e72001-02-27 20:54:23485 if platform not in ['cygwin']:
486 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
487 libs = ['nsl']
488 else:
489 libs = []
490 exts.append( Extension('nis', ['nismodule.c'],
491 libraries = libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23492
493 # Curses support, requring the System V version of curses, often
Fredrik Lundhade711a2001-01-24 08:00:28494 # provided by the ncurses library.
Andrew M. Kuchling34febf52001-01-24 03:31:07495 if platform == 'sunos4':
Andrew M. Kuchlingb69c7582001-02-28 19:49:57496 inc_dirs += ['/usr/5include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23497 lib_dirs += ['/usr/5lib']
498
499 if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
500 curses_libs = ['ncurses']
501 exts.append( Extension('_curses', ['_cursesmodule.c'],
502 libraries = curses_libs) )
Fred Drake38419c02001-12-06 22:24:47503 elif (self.compiler.find_library_file(lib_dirs, 'curses')
504 and platform != 'darwin'):
Michael W. Hudson1e7eb052002-03-01 08:58:32505 # OSX has an old Berkeley curses, not good enough for
506 # the _curses module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23507 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
508 curses_libs = ['curses', 'terminfo']
509 else:
510 curses_libs = ['curses', 'termcap']
Fredrik Lundhade711a2001-01-24 08:00:28511
Andrew M. Kuchling00e0f212001-01-17 15:23:23512 exts.append( Extension('_curses', ['_cursesmodule.c'],
513 libraries = curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28514
Andrew M. Kuchling00e0f212001-01-17 15:23:23515 # If the curses module is enabled, check for the panel module
Andrew M. Kuchlinge7ffbb22001-12-06 15:57:16516 if (module_enabled(exts, '_curses') and
Andrew M. Kuchling00e0f212001-01-17 15:23:23517 self.compiler.find_library_file(lib_dirs, 'panel')):
518 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
519 libraries = ['panel'] + curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28520
521
Andrew M. Kuchling00e0f212001-01-17 15:23:23522
523 # Lee Busby's SIGFPE modules.
524 # The library to link fpectl with is platform specific.
525 # Choose *one* of the options below for fpectl:
526
Guido van Rossum2c3f4432002-09-25 15:00:40527 # Disabled; it's dangerous or useless except in the hands of experts.
528## if platform == 'irix5':
529## # For SGI IRIX (tested on 5.3):
530## exts.append( Extension('fpectl', ['fpectlmodule.c'],
531## libraries=['fpe']) )
532## elif 0: # XXX how to detect SunPro?
533## # For Solaris with SunPro compiler (tested on Solaris 2.5
534## # with SunPro C 4.2): (Without the compiler you don't have
535## # -lsunmath.)
536## #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
537## pass
538## else:
539## # For other systems: see instructions in fpectlmodule.c.
540## #fpectl fpectlmodule.c ...
541## exts.append( Extension('fpectl', ['fpectlmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23542
543
544 # Andrew Kuchling's zlib module.
545 # This require zlib 1.1.3 (or later).
546 # See http://www.cdrom.com/pub/infozip/zlib/
Guido van Rossume6970912001-04-15 15:16:12547 zlib_inc = find_file('zlib.h', [], inc_dirs)
548 if zlib_inc is not None:
549 zlib_h = zlib_inc[0] + '/zlib.h'
550 version = '"0.0.0"'
551 version_req = '"1.1.3"'
552 fp = open(zlib_h)
553 while 1:
554 line = fp.readline()
555 if not line:
556 break
557 if line.find('#define ZLIB_VERSION', 0) == 0:
558 version = line.split()[2]
559 break
560 if version >= version_req:
561 if (self.compiler.find_library_file(lib_dirs, 'z')):
562 exts.append( Extension('zlib', ['zlibmodule.c'],
563 libraries = ['z']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23564
565 # Interface to the Expat XML parser
566 #
Fred Drake108be6a2002-06-17 17:56:10567 # Expat was written by James Clark and is now maintained by a
568 # group of developers on SourceForge. The parser must be
569 # downloaded separately (see below). The pyexpat module was
570 # written by Paul Prescod after a prototype by Jack Jansen.
Andrew M. Kuchling00e0f212001-01-17 15:23:23571 #
Fred Drake108be6a2002-06-17 17:56:10572 # The Expat dist includes Windows .lib and .dll files. The
573 # home page for Expat is at http://www.libexpat.org/. Using
574 # Expat version 1.95.2 or newer is recommended.
Andrew M. Kuchling00e0f212001-01-17 15:23:23575 #
Andrew M. Kuchlingfbe73762001-01-18 18:44:20576 expat_defs = []
577 expat_incs = find_file('expat.h', inc_dirs, [])
578 if expat_incs is not None:
579 # expat.h was found
580 expat_defs = [('HAVE_EXPAT_H', 1)]
581 else:
582 expat_incs = find_file('xmlparse.h', inc_dirs, [])
Fredrik Lundhade711a2001-01-24 08:00:28583
Martin v. Löwis1ab29b22001-01-21 10:54:52584 if (expat_incs is not None and
Andrew M. Kuchlingfbe73762001-01-18 18:44:20585 self.compiler.find_library_file(lib_dirs, 'expat')):
586 exts.append( Extension('pyexpat', ['pyexpat.c'],
587 define_macros = expat_defs,
588 libraries = ['expat']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23589
590 # Platform-specific libraries
Andrew M. Kuchling34febf52001-01-24 03:31:07591 if platform == 'linux2':
Andrew M. Kuchling00e0f212001-01-17 15:23:23592 # Linux-specific modules
593 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
594
Andrew M. Kuchling34febf52001-01-24 03:31:07595 if platform == 'sunos5':
Fredrik Lundhade711a2001-01-24 08:00:28596 # SunOS specific modules
Andrew M. Kuchling00e0f212001-01-17 15:23:23597 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
Michael W. Hudson1e7eb052002-03-01 08:58:32598
Jack Jansen244e7612001-12-05 15:54:29599 if platform == 'darwin':
Jack Jansen144ebcc2001-08-05 22:31:19600 # Mac OS X specific modules. These are ported over from MacPython
601 # and still experimental. Some (such as gestalt or icglue) are
602 # already generally useful, some (the GUI ones) really need to
603 # be used from a framework.
Jack Jansen2f760c32001-09-04 21:33:12604 #
605 # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
606 # available here. This Makefile variable is also what the install
607 # procedure triggers on.
608 frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
Michael W. Hudson6dcabf32002-03-07 10:04:49609 exts.append( Extension('gestalt', ['gestaltmodule.c'],
Michael W. Hudson7ab59232002-03-25 13:59:28610 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48611 exts.append( Extension('MacOS', ['macosmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32612 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48613 exts.append( Extension('icglue', ['icgluemodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32614 extra_link_args=['-framework', 'Carbon']) )
Fred Drake38419c02001-12-06 22:24:47615 exts.append( Extension('macfs',
616 ['macfsmodule.c',
617 '../Python/getapplbycreator.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32618 extra_link_args=['-framework', 'Carbon']) )
Michael W. Hudson6dcabf32002-03-07 10:04:49619 exts.append( Extension('_CF', ['cf/_CFmodule.c'],
620 extra_link_args=['-framework', 'CoreFoundation']) )
621 exts.append( Extension('_Res', ['res/_Resmodule.c'],
622 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48623 exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32624 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12625 if frameworkdir:
Jack Jansen666b1e72001-10-31 12:11:48626 exts.append( Extension('Nav', ['Nav.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32627 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48628 exts.append( Extension('_AE', ['ae/_AEmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32629 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48630 exts.append( Extension('_App', ['app/_Appmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32631 extra_link_args=['-framework', 'Carbon']) )
Jack Jansendd67a8e2001-12-12 23:03:17632 exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32633 extra_link_args=['-framework', 'Carbon']) )
Just van Rossume9039b12001-12-13 13:41:36634 exts.append( Extension('_CG', ['cg/_CGmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32635 extra_link_args=['-framework', 'ApplicationServices',
Just van Rossume9039b12001-12-13 13:41:36636 '-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48637 exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32638 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48639 exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32640 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48641 exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32642 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48643 exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32644 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48645 exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32646 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48647 exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32648 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48649 exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32650 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48651 exts.append( Extension('_List', ['list/_Listmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32652 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48653 exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32654 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48655 exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32656 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48657 exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32658 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48659 exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32660 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12661 exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
Fred Drake38419c02001-12-06 22:24:47662 extra_link_args=['-framework', 'QuickTime',
663 '-framework', 'Carbon']) )
Jack Jansen38d966b2002-03-26 13:43:04664 exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'],
665 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen666b1e72001-10-31 12:11:48666 exts.append( Extension('_TE', ['te/_TEmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32667 extra_link_args=['-framework', 'Carbon']) )
Jack Jansenedeea042001-12-09 23:08:54668 # As there is no standardized place (yet) to put user-installed
669 # Mac libraries on OSX you should put a symlink to your Waste
670 # installation in the same folder as your python source tree.
671 # Or modify the next two lines:-)
672 waste_incs = find_file("WASTE.h", [], ["../waste/C_C++ Headers"])
673 waste_libs = find_library_file(self.compiler, "WASTE", [],
674 ["../waste/Static Libraries"])
675 if waste_incs != None and waste_libs != None:
Michael W. Hudson1e7eb052002-03-01 08:58:32676 exts.append( Extension('waste',
Jack Jansenedeea042001-12-09 23:08:54677 ['waste/wastemodule.c',
678 'Mac/Wastemods/WEObjectHandlers.c',
679 'Mac/Wastemods/WETabHooks.c',
680 'Mac/Wastemods/WETabs.c'
681 ],
682 include_dirs = waste_incs + ['Mac/Wastemods'],
683 library_dirs = waste_libs,
684 libraries = ['WASTE'],
685 extra_link_args = ['-framework', 'Carbon'],
686 ) )
Jack Jansen666b1e72001-10-31 12:11:48687 exts.append( Extension('_Win', ['win/_Winmodule.c'],
Michael W. Hudson1e7eb052002-03-01 08:58:32688 extra_link_args=['-framework', 'Carbon']) )
689
Andrew M. Kuchlingfbe73762001-01-18 18:44:20690 self.extensions.extend(exts)
691
692 # Call the method for detecting whether _tkinter can be compiled
693 self.detect_tkinter(inc_dirs, lib_dirs)
Fredrik Lundhade711a2001-01-24 08:00:28694
Andrew M. Kuchlingfbe73762001-01-18 18:44:20695
696 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:23697 # The _tkinter module.
Michael W. Hudson1e7eb052002-03-01 08:58:32698
Andrew M. Kuchlingfbe73762001-01-18 18:44:20699 # Assume we haven't found any of the libraries or include files
Martin v. Löwis3db5b8c2001-07-24 06:54:01700 # The versions with dots are used on Unix, and the versions without
701 # dots on Windows, for detection by cygwin.
Andrew M. Kuchlingfbe73762001-01-18 18:44:20702 tcllib = tklib = tcl_includes = tk_includes = None
Martin v. Löwis3db5b8c2001-07-24 06:54:01703 for version in ['8.4', '84', '8.3', '83', '8.2',
704 '82', '8.1', '81', '8.0', '80']:
Michael W. Hudson1e7eb052002-03-01 08:58:32705 tklib = self.compiler.find_library_file(lib_dirs,
706 'tk' + version )
707 tcllib = self.compiler.find_library_file(lib_dirs,
708 'tcl' + version )
709 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:23710 # Exit the loop when we've found the Tcl/Tk libraries
711 break
Andrew M. Kuchling00e0f212001-01-17 15:23:23712
Fredrik Lundhade711a2001-01-24 08:00:28713 # Now check for the header files
Andrew M. Kuchlingfbe73762001-01-18 18:44:20714 if tklib and tcllib:
715 # Check for the include files on Debian, where
716 # they're put in /usr/include/{tcl,tk}X.Y
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27717 debian_tcl_include = [ '/usr/include/tcl' + version ]
Fred Drake38419c02001-12-06 22:24:47718 debian_tk_include = [ '/usr/include/tk' + version ] + \
719 debian_tcl_include
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27720 tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
721 tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
Andrew M. Kuchling00e0f212001-01-17 15:23:23722
Martin v. Löwisf1e89b12003-05-18 13:40:03723 if (tcllib is None or tklib is None or
Andrew M. Kuchlingfbe73762001-01-18 18:44:20724 tcl_includes is None or tk_includes is None):
725 # Something's missing, so give up
726 return
Fredrik Lundhade711a2001-01-24 08:00:28727
Andrew M. Kuchlingfbe73762001-01-18 18:44:20728 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:23729
Andrew M. Kuchlingfbe73762001-01-18 18:44:20730 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
731 for dir in tcl_includes + tk_includes:
732 if dir not in include_dirs:
733 include_dirs.append(dir)
Fredrik Lundhade711a2001-01-24 08:00:28734
Andrew M. Kuchlingfbe73762001-01-18 18:44:20735 # Check for various platform-specific directories
Andrew M. Kuchling34febf52001-01-24 03:31:07736 platform = self.get_platform()
737 if platform == 'sunos5':
Andrew M. Kuchlingfbe73762001-01-18 18:44:20738 include_dirs.append('/usr/openwin/include')
739 added_lib_dirs.append('/usr/openwin/lib')
740 elif os.path.exists('/usr/X11R6/include'):
741 include_dirs.append('/usr/X11R6/include')
742 added_lib_dirs.append('/usr/X11R6/lib')
743 elif os.path.exists('/usr/X11R5/include'):
744 include_dirs.append('/usr/X11R5/include')
745 added_lib_dirs.append('/usr/X11R5/lib')
746 else:
Fredrik Lundhade711a2001-01-24 08:00:28747 # Assume default location for X11
Andrew M. Kuchlingfbe73762001-01-18 18:44:20748 include_dirs.append('/usr/X11/include')
749 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:23750
Andrew M. Kuchling89fb72d2001-09-18 20:32:13751 # If Cygwin, then verify that X is installed before proceeding
752 if platform == 'cygwin':
753 x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
754 if x11_inc is None:
755 # X header files missing, so give up
756 return
757
Andrew M. Kuchlingfbe73762001-01-18 18:44:20758 # Check for BLT extension
Fred Drake38419c02001-12-06 22:24:47759 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
760 'BLT8.0'):
Andrew M. Kuchlingfbe73762001-01-18 18:44:20761 defs.append( ('WITH_BLT', 1) )
762 libs.append('BLT8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23763
Andrew M. Kuchlingfbe73762001-01-18 18:44:20764 # Add the Tcl/Tk libraries
Fredrik Lundhade711a2001-01-24 08:00:28765 libs.append('tk'+version)
Andrew M. Kuchlingfbe73762001-01-18 18:44:20766 libs.append('tcl'+version)
Fredrik Lundhade711a2001-01-24 08:00:28767
Andrew M. Kuchling34febf52001-01-24 03:31:07768 if platform in ['aix3', 'aix4']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20769 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:23770
Martin v. Löwis3db5b8c2001-07-24 06:54:01771 # Finally, link with the X11 libraries (not appropriate on cygwin)
772 if platform != "cygwin":
773 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:23774
Andrew M. Kuchlingfbe73762001-01-18 18:44:20775 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
776 define_macros=[('WITH_APPINIT', 1)] + defs,
777 include_dirs = include_dirs,
778 libraries = libs,
779 library_dirs = added_lib_dirs,
780 )
781 self.extensions.append(ext)
Fredrik Lundhade711a2001-01-24 08:00:28782
Andrew M. Kuchlingfbe73762001-01-18 18:44:20783 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:23784 # *** Uncomment and edit for PIL (TkImaging) extension only:
Fredrik Lundhade711a2001-01-24 08:00:28785 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23786 # *** Uncomment and edit for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28787 # -DWITH_TOGL togl.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23788 # *** Uncomment these for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28789 # -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling00e0f212001-01-17 15:23:23790
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27791class PyBuildInstall(install):
792 # Suppress the warning about installation into the lib_dynload
793 # directory, which is not in sys.path when running Python during
794 # installation:
795 def initialize_options (self):
796 install.initialize_options(self)
797 self.warn_dir=0
Michael W. Hudson1e7eb052002-03-01 08:58:32798
Andrew M. Kuchling00e0f212001-01-17 15:23:23799def main():
Andrew M. Kuchling62686692001-05-21 20:48:09800 # turn off warnings when deprecated modules are imported
801 import warnings
802 warnings.filterwarnings("ignore",category=DeprecationWarning)
Andrew M. Kuchling00e0f212001-01-17 15:23:23803 setup(name = 'Python standard library',
Neil Schemenauere7e2ece2001-01-17 21:58:00804 version = '%d.%d' % sys.version_info[:2],
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27805 cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
Andrew M. Kuchling00e0f212001-01-17 15:23:23806 # The struct module is defined here, because build_ext won't be
807 # called unless there's at least one extension module defined.
Andrew M. Kuchlingaece4272001-02-28 20:56:49808 ext_modules=[Extension('struct', ['structmodule.c'])],
809
810 # Scripts to install
811 scripts = ['Tools/scripts/pydoc']
Andrew M. Kuchling00e0f212001-01-17 15:23:23812 )
Fredrik Lundhade711a2001-01-24 08:00:28813
Andrew M. Kuchling00e0f212001-01-17 15:23:23814# --install-platlib
815if __name__ == '__main__':
Andrew M. Kuchling00e0f212001-01-17 15:23:23816 main()