blob: c15bd7cf90f7c8fe697042ba4f845581b48321b0 [file] [log] [blame]
Andrew M. Kuchling66012fe2001-01-26 21:56:58 +00001# Autodetecting setup.py script for building the Python extensions
2#
Fredrik Lundhade711a2001-01-24 08:00:28 +00003
Andrew M. Kuchling66012fe2001-01-26 21:56:58 +00004__version__ = "$Revision$"
5
6import sys, os, getopt
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +00007from distutils import sysconfig
Andrew M. Kuchling8d7f0862001-02-23 16:32:32 +00008from distutils import text_file
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +00009from distutils.errors import *
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000010from distutils.core import Extension, setup
11from distutils.command.build_ext import build_ext
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +000012from distutils.command.install import install
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000013
14# This global variable is used to hold the list of modules to be disabled.
15disabled_module_list = []
16
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000017def find_file(filename, std_dirs, paths):
18 """Searches for the directory where a given file is located,
19 and returns a possibly-empty list of additional directories, or None
20 if the file couldn't be found at all.
Fredrik Lundhade711a2001-01-24 08:00:28 +000021
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000022 'filename' is the name of a file, such as readline.h or libcrypto.a.
23 'std_dirs' is the list of standard system directories; if the
24 file is found in one of them, no additional directives are needed.
25 'paths' is a list of additional locations to check; if the file is
26 found in one of them, the resulting list will contain the directory.
27 """
28
29 # Check the standard locations
30 for dir in std_dirs:
31 f = os.path.join(dir, filename)
32 if os.path.exists(f): return []
33
34 # Check the additional directories
35 for dir in paths:
36 f = os.path.join(dir, filename)
37 if os.path.exists(f):
38 return [dir]
39
40 # Not found anywhere
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000041 return None
42
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000043def find_library_file(compiler, libname, std_dirs, paths):
44 filename = compiler.library_filename(libname, lib_type='shared')
45 result = find_file(filename, std_dirs, paths)
46 if result is not None: return result
Fredrik Lundhade711a2001-01-24 08:00:28 +000047
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +000048 filename = compiler.library_filename(libname, lib_type='static')
49 result = find_file(filename, std_dirs, paths)
50 return result
51
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000052def module_enabled(extlist, modname):
53 """Returns whether the module 'modname' is present in the list
54 of extensions 'extlist'."""
55 extlist = [ext for ext in extlist if ext.name == modname]
56 return len(extlist)
Fredrik Lundhade711a2001-01-24 08:00:28 +000057
Jack Jansen144ebcc2001-08-05 22:31:19 +000058def find_module_file(module, dirlist):
59 """Find a module in a set of possible folders. If it is not found
60 return the unadorned filename"""
61 list = find_file(module, [], dirlist)
62 if not list:
63 return module
64 if len(list) > 1:
65 self.announce("WARNING: multiple copies of %s found"%module)
66 return os.path.join(list[0], module)
67
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000068class PyBuildExt(build_ext):
Fredrik Lundhade711a2001-01-24 08:00:28 +000069
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000070 def build_extensions(self):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000071
72 # Detect which modules should be compiled
73 self.detect_modules()
74
75 # Remove modules that are present on the disabled list
76 self.extensions = [ext for ext in self.extensions
77 if ext.name not in disabled_module_list]
Fredrik Lundhade711a2001-01-24 08:00:28 +000078
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000079 # Fix up the autodetected modules, prefixing all the source files
80 # with Modules/ and adding Python's include directory to the path.
81 (srcdir,) = sysconfig.get_config_vars('srcdir')
82
Neil Schemenauer726b78e2001-01-24 17:18:21 +000083 # Figure out the location of the source code for extension modules
84 moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +000085 moddir = os.path.normpath(moddir)
86 srcdir, tail = os.path.split(moddir)
87 srcdir = os.path.normpath(srcdir)
88 moddir = os.path.normpath(moddir)
Jack Jansen144ebcc2001-08-05 22:31:19 +000089
90 moddirlist = [moddir]
91 incdirlist = ['./Include']
92
93 # Platform-dependent module source and include directories
94 platform = self.get_platform()
95 if platform == 'darwin1':
96 # Mac OS X also includes some mac-specific modules
97 macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
98 moddirlist.append(macmoddir)
99 incdirlist.append('./Mac/Include')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000100
Andrew M. Kuchling3da989c2001-02-28 22:49:26 +0000101 # Fix up the paths for scripts, too
102 self.distribution.scripts = [os.path.join(srcdir, filename)
103 for filename in self.distribution.scripts]
104
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000105 for ext in self.extensions[:]:
Jack Jansen144ebcc2001-08-05 22:31:19 +0000106 ext.sources = [ find_module_file(filename, moddirlist)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000107 for filename in ext.sources ]
Jack Jansen144ebcc2001-08-05 22:31:19 +0000108 ext.include_dirs.append( '.' ) # to get config.h
109 for incdir in incdirlist:
110 ext.include_dirs.append( os.path.join(srcdir, incdir) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000111
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000112 # If a module has already been built statically,
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000113 # don't build it here
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000114 if ext.name in sys.builtin_module_names:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000115 self.extensions.remove(ext)
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000116
Andrew M. Kuchling8d7f0862001-02-23 16:32:32 +0000117 # Parse Modules/Setup to figure out which modules are turned
118 # on in the file.
119 input = text_file.TextFile('Modules/Setup', join_lines=1)
120 remove_modules = []
121 while 1:
122 line = input.readline()
123 if not line: break
124 line = line.split()
125 remove_modules.append( line[0] )
126 input.close()
127
128 for ext in self.extensions[:]:
129 if ext.name in remove_modules:
130 self.extensions.remove(ext)
131
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000132 # When you run "make CC=altcc" or something similar, you really want
133 # those environment variables passed into the setup.py phase. Here's
134 # a small set of useful ones.
135 compiler = os.environ.get('CC')
136 linker_so = os.environ.get('LDSHARED')
137 args = {}
138 # unfortunately, distutils doesn't let us provide separate C and C++
139 # compilers
140 if compiler is not None:
Martin v. Löwis3e4b0e82001-08-10 08:56:17 +0000141 (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT')
142 args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000143 if linker_so is not None:
Martin v. Löwis2f20dab2001-10-08 13:18:37 +0000144 args['linker_so'] = linker_so
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000145 self.compiler.set_executables(**args)
146
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000147 build_ext.build_extensions(self)
148
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000149 def build_extension(self, ext):
150
151 try:
152 build_ext.build_extension(self, ext)
153 except (CCompilerError, DistutilsError), why:
154 self.announce('WARNING: building of extension "%s" failed: %s' %
155 (ext.name, sys.exc_info()[1]))
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000156 return
Jack Jansenf49c6f92001-11-01 14:44:15 +0000157 # Workaround for Mac OS X: The Carbon-based modules cannot be
158 # reliably imported into a command-line Python
159 if 'Carbon' in ext.extra_link_args:
160 self.announce('WARNING: skipping import check for Carbon-based "%s"' % ext.name)
161 return
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000162 try:
163 __import__(ext.name)
164 except ImportError:
165 self.announce('WARNING: removing "%s" since importing it failed' %
166 ext.name)
167 assert not self.inplace
168 fullname = self.get_ext_fullname(ext.name)
169 ext_filename = os.path.join(self.build_lib,
170 self.get_ext_filename(fullname))
171 os.remove(ext_filename)
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000172
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000173 def get_platform (self):
Fredrik Lundhade711a2001-01-24 08:00:28 +0000174 # Get value of sys.platform
175 platform = sys.platform
176 if platform[:6] =='cygwin':
177 platform = 'cygwin'
Andrew M. Kuchling3c044942001-02-06 23:37:23 +0000178 elif platform[:4] =='beos':
179 platform = 'beos'
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000180
Fredrik Lundhade711a2001-01-24 08:00:28 +0000181 return platform
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000182
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000183 def detect_modules(self):
Fredrik Lundhade711a2001-01-24 08:00:28 +0000184 # Ensure that /usr/local is always used
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000185 if '/usr/local/lib' not in self.compiler.library_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000186 self.compiler.library_dirs.insert(0, '/usr/local/lib')
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000187 if '/usr/local/include' not in self.compiler.include_dirs:
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000188 self.compiler.include_dirs.insert(0, '/usr/local/include' )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000189
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000190 try:
191 have_unicode = unicode
192 except NameError:
193 have_unicode = 0
194
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000195 # lib_dirs and inc_dirs are used to search for files;
196 # if a file is found in one of those directories, it can
197 # be assumed that no additional -I,-L directives are needed.
198 lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000199 inc_dirs = self.compiler.include_dirs + ['/usr/include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000200 exts = []
201
Fredrik Lundhade711a2001-01-24 08:00:28 +0000202 platform = self.get_platform()
Andrew M. Kuchling9b5abcd2001-03-17 16:56:35 +0000203
Fredrik Lundhade711a2001-01-24 08:00:28 +0000204 # Check for MacOS X, which doesn't need libm.a at all
205 math_libs = ['m']
Andrew M. Kuchling3c044942001-02-06 23:37:23 +0000206 if platform in ['Darwin1.2', 'beos']:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000207 math_libs = []
Jack Jansen144ebcc2001-08-05 22:31:19 +0000208
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000209 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
210
211 #
212 # The following modules are all pretty straightforward, and compile
213 # on pretty much any POSIXish platform.
214 #
Fredrik Lundhade711a2001-01-24 08:00:28 +0000215
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000216 # Some modules that are normally always on:
217 exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
218 exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000219
Fred Drake3a40f322001-10-12 21:00:48 +0000220 exts.append( Extension('_hotshot', ['_hotshot.c']) )
Fred Drake2de74712001-02-01 05:26:54 +0000221 exts.append( Extension('_weakref', ['_weakref.c']) )
Andrew M. Kuchlingd5c43062001-01-17 15:59:25 +0000222 exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000223
224 # array objects
225 exts.append( Extension('array', ['arraymodule.c']) )
226 # complex math library functions
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000227 exts.append( Extension('cmath', ['cmathmodule.c'],
228 libraries=math_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000229
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000230 # math library functions, e.g. sin()
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000231 exts.append( Extension('math', ['mathmodule.c'],
232 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000233 # fast string operations implemented in C
234 exts.append( Extension('strop', ['stropmodule.c']) )
235 # time operations and variables
Andrew M. Kuchling5ddb25f2001-01-23 22:21:11 +0000236 exts.append( Extension('time', ['timemodule.c'],
237 libraries=math_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000238 # operator.add() and similar goodies
239 exts.append( Extension('operator', ['operator.c']) )
240 # access to the builtin codecs and codec registry
241 exts.append( Extension('_codecs', ['_codecsmodule.c']) )
Marc-André Lemburg261b8e22001-02-02 12:12:44 +0000242 # Python C API test module
Tim Petersd66595f2001-02-04 03:09:53 +0000243 exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000244 # static Unicode character database
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000245 if have_unicode:
246 exts.append( Extension('unicodedata', ['unicodedata.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000247 # access to ISO C locale support
248 exts.append( Extension('_locale', ['_localemodule.c']) )
249
250 # Modules with some UNIX dependencies -- on by default:
251 # (If you have a really backward UNIX, select and socket may not be
252 # supported...)
253
254 # fcntl(2) and ioctl(2)
255 exts.append( Extension('fcntl', ['fcntlmodule.c']) )
256 # pwd(3)
257 exts.append( Extension('pwd', ['pwdmodule.c']) )
258 # grp(3)
259 exts.append( Extension('grp', ['grpmodule.c']) )
260 # posix (UNIX) errno values
261 exts.append( Extension('errno', ['errnomodule.c']) )
262 # select(2); not on ancient System V
263 exts.append( Extension('select', ['selectmodule.c']) )
264
265 # The md5 module implements the RSA Data Security, Inc. MD5
266 # Message-Digest Algorithm, described in RFC 1321. The necessary files
267 # md5c.c and md5.h are included here.
268 exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
269
270 # The sha module implements the SHA checksum algorithm.
271 # (NIST's Secure Hash Algorithm.)
272 exts.append( Extension('sha', ['shamodule.c']) )
273
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000274 # Helper module for various ascii-encoders
275 exts.append( Extension('binascii', ['binascii.c']) )
276
277 # Fred Drake's interface to the Python parser
278 exts.append( Extension('parser', ['parsermodule.c']) )
279
280 # Digital Creations' cStringIO and cPickle
281 exts.append( Extension('cStringIO', ['cStringIO.c']) )
282 exts.append( Extension('cPickle', ['cPickle.c']) )
283
284 # Memory-mapped files (also works on Win32).
285 exts.append( Extension('mmap', ['mmapmodule.c']) )
286
287 # Lance Ellinghaus's modules:
288 # enigma-inspired encryption
289 exts.append( Extension('rotor', ['rotormodule.c']) )
290 # syslog daemon interface
291 exts.append( Extension('syslog', ['syslogmodule.c']) )
292
293 # George Neville-Neil's timing module:
294 exts.append( Extension('timing', ['timingmodule.c']) )
295
296 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000297 # Here ends the simple stuff. From here on, modules need certain
298 # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000299 #
300
301 # Multimedia modules
302 # These don't work for 64-bit platforms!!!
303 # These represent audio samples or images as strings:
304
Fredrik Lundhade711a2001-01-24 08:00:28 +0000305 # Disabled on 64-bit platforms
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000306 if sys.maxint != 9223372036854775807L:
307 # Operations on audio samples
308 exts.append( Extension('audioop', ['audioop.c']) )
309 # Operations on images
310 exts.append( Extension('imageop', ['imageop.c']) )
311 # Read SGI RGB image files (but coded portably)
312 exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
313
314 # readline
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000315 if self.compiler.find_library_file(lib_dirs, 'readline'):
316 readline_libs = ['readline']
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18 +0000317 if self.compiler.find_library_file(lib_dirs,
318 'ncurses'):
319 readline_libs.append('ncurses')
320 elif self.compiler.find_library_file(lib_dirs +
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000321 ['/usr/lib/termcap'],
322 'termcap'):
323 readline_libs.append('termcap')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000324 exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg7c6fcda2001-01-26 18:03:24 +0000325 library_dirs=['/usr/lib/termcap'],
Marc-André Lemburg2efc3232001-01-26 18:23:02 +0000326 libraries=readline_libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000327
Andrew M. Kuchling5aa3c4a2001-08-16 20:30:18 +0000328 # crypt module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000329
330 if self.compiler.find_library_file(lib_dirs, 'crypt'):
331 libs = ['crypt']
332 else:
333 libs = []
334 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
335
336 # socket(2)
337 # Detect SSL support for the socket module
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000338 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000339 ['/usr/local/ssl/include',
340 '/usr/contrib/ssl/include/'
341 ]
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000342 )
343 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
Andrew M. Kuchlinge7c87322001-01-19 16:58:21 +0000344 ['/usr/local/ssl/lib',
345 '/usr/contrib/ssl/lib/'
346 ] )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000347
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000348 if (ssl_incs is not None and
349 ssl_libs is not None):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000350 exts.append( Extension('_socket', ['socketmodule.c'],
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000351 include_dirs = ssl_incs,
Fredrik Lundhade711a2001-01-24 08:00:28 +0000352 library_dirs = ssl_libs,
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000353 libraries = ['ssl', 'crypto'],
354 define_macros = [('USE_SSL',1)] ) )
355 else:
356 exts.append( Extension('_socket', ['socketmodule.c']) )
357
358 # Modules that provide persistent dictionary-like semantics. You will
359 # probably want to arrange for at least one of them to be available on
360 # your machine, though none are defined by default because of library
361 # dependencies. The Python module anydbm.py provides an
362 # implementation independent wrapper for these; dumbdbm.py provides
363 # similar functionality (but slower of course) implemented in Python.
364
365 # The standard Unix dbm module:
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000366 if platform not in ['cygwin']:
367 if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
368 exts.append( Extension('dbm', ['dbmmodule.c'],
369 libraries = ['ndbm'] ) )
Neil Schemenauerc3ffef62001-10-21 22:14:44 +0000370 elif self.compiler.find_library_file(lib_dirs, 'db1'):
371 exts.append( Extension('dbm', ['dbmmodule.c'],
372 libraries = ['db1'] ) )
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000373 else:
374 exts.append( Extension('dbm', ['dbmmodule.c']) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000375
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000376 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
377 if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
378 exts.append( Extension('gdbm', ['gdbmmodule.c'],
379 libraries = ['gdbm'] ) )
380
381 # Berkeley DB interface.
382 #
383 # This requires the Berkeley DB code, see
384 # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
385 #
386 # Edit the variables DB and DBPORT to point to the db top directory
387 # and the subdirectory of PORT where you built it.
388 #
Greg Ward02fac832001-09-13 15:05:08 +0000389 # (See http://pybsddb.sourceforge.net/ for an interface to
390 # Berkeley DB 3.x.)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000391
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000392 dblib = []
Skip Montanaroe81f4472001-08-21 04:23:21 +0000393 if self.compiler.find_library_file(lib_dirs, 'db-3.1'):
394 dblib = ['db-3.1']
Neil Schemenauerc3ffef62001-10-21 22:14:44 +0000395 elif self.compiler.find_library_file(lib_dirs, 'db3'):
396 dblib = ['db3']
Skip Montanaroe81f4472001-08-21 04:23:21 +0000397 elif self.compiler.find_library_file(lib_dirs, 'db2'):
398 dblib = ['db2']
399 elif self.compiler.find_library_file(lib_dirs, 'db1'):
400 dblib = ['db1']
401 elif self.compiler.find_library_file(lib_dirs, 'db'):
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000402 dblib = ['db']
403
404 db185_incs = find_file('db_185.h', inc_dirs,
405 ['/usr/include/db3', '/usr/include/db2'])
406 db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
407 if db185_incs is not None:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000408 exts.append( Extension('bsddb', ['bsddbmodule.c'],
Andrew M. Kuchlinge06337a2001-02-23 16:27:48 +0000409 include_dirs = db185_incs,
410 define_macros=[('HAVE_DB_185_H',1)],
411 libraries = dblib ) )
412 elif db_inc is not None:
413 exts.append( Extension('bsddb', ['bsddbmodule.c'],
414 include_dirs = db_inc,
415 libraries = dblib) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000416
417 # The mpz module interfaces to the GNU Multiple Precision library.
Fredrik Lundhade711a2001-01-24 08:00:28 +0000418 # You need to ftp the GNU MP library.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000419 # This was originally written and tested against GMP 1.2 and 1.3.2.
420 # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
421 # haven't tested it recently. For a more complete module,
422 # refer to pympz.sourceforge.net.
423
Greg Ward57fc2102001-10-03 19:59:30 +0000424 # A compatible MP library unencumbered by the GPL also exists. It was
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000425 # posted to comp.sources.misc in volume 40 and is widely available from
426 # FTP archive sites. One URL for it is:
427 # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
428
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000429 if (self.compiler.find_library_file(lib_dirs, 'gmp')):
430 exts.append( Extension('mpz', ['mpzmodule.c'],
431 libraries = ['gmp'] ) )
432
433
434 # Unix-only modules
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000435 if platform not in ['mac', 'win32']:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000436 # Steen Lumholt's termios module
437 exts.append( Extension('termios', ['termios.c']) )
438 # Jeremy Hylton's rlimit interface
Andrew M. Kuchlingfda3c3d2001-09-17 16:19:16 +0000439 exts.append( Extension('resource', ['resource.c']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000440
Andrew M. Kuchlingcf393f32001-02-21 02:38:24 +0000441 # Sun yellow pages. Some systems have the functions in libc.
Andrew M. Kuchling6efc6e72001-02-27 20:54:23 +0000442 if platform not in ['cygwin']:
443 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
444 libs = ['nsl']
445 else:
446 libs = []
447 exts.append( Extension('nis', ['nismodule.c'],
448 libraries = libs) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000449
450 # Curses support, requring the System V version of curses, often
Fredrik Lundhade711a2001-01-24 08:00:28 +0000451 # provided by the ncurses library.
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000452 if platform == 'sunos4':
Andrew M. Kuchlingb69c7582001-02-28 19:49:57 +0000453 inc_dirs += ['/usr/5include']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000454 lib_dirs += ['/usr/5lib']
455
456 if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
457 curses_libs = ['ncurses']
458 exts.append( Extension('_curses', ['_cursesmodule.c'],
459 libraries = curses_libs) )
Jack Jansen4ca5f382001-09-04 09:05:11 +0000460 elif (self.compiler.find_library_file(lib_dirs, 'curses')) and platform != 'darwin1':
461 # OSX has an old Berkeley curses, not good enough for the _curses module.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000462 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
463 curses_libs = ['curses', 'terminfo']
464 else:
465 curses_libs = ['curses', 'termcap']
Fredrik Lundhade711a2001-01-24 08:00:28 +0000466
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000467 exts.append( Extension('_curses', ['_cursesmodule.c'],
468 libraries = curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000469
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000470 # If the curses module is enabled, check for the panel module
471 if (os.path.exists('Modules/_curses_panel.c') and
472 module_enabled(exts, '_curses') and
473 self.compiler.find_library_file(lib_dirs, 'panel')):
474 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
475 libraries = ['panel'] + curses_libs) )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000476
477
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000478
479 # Lee Busby's SIGFPE modules.
480 # The library to link fpectl with is platform specific.
481 # Choose *one* of the options below for fpectl:
482
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000483 if platform == 'irix5':
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000484 # For SGI IRIX (tested on 5.3):
485 exts.append( Extension('fpectl', ['fpectlmodule.c'],
486 libraries=['fpe']) )
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000487 elif 0: # XXX how to detect SunPro?
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000488 # For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2):
489 # (Without the compiler you don't have -lsunmath.)
490 #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
491 pass
492 else:
493 # For other systems: see instructions in fpectlmodule.c.
494 #fpectl fpectlmodule.c ...
495 exts.append( Extension('fpectl', ['fpectlmodule.c']) )
496
497
498 # Andrew Kuchling's zlib module.
499 # This require zlib 1.1.3 (or later).
500 # See http://www.cdrom.com/pub/infozip/zlib/
Guido van Rossume6970912001-04-15 15:16:12 +0000501 zlib_inc = find_file('zlib.h', [], inc_dirs)
502 if zlib_inc is not None:
503 zlib_h = zlib_inc[0] + '/zlib.h'
504 version = '"0.0.0"'
505 version_req = '"1.1.3"'
506 fp = open(zlib_h)
507 while 1:
508 line = fp.readline()
509 if not line:
510 break
511 if line.find('#define ZLIB_VERSION', 0) == 0:
512 version = line.split()[2]
513 break
514 if version >= version_req:
515 if (self.compiler.find_library_file(lib_dirs, 'z')):
516 exts.append( Extension('zlib', ['zlibmodule.c'],
517 libraries = ['z']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000518
519 # Interface to the Expat XML parser
520 #
521 # Expat is written by James Clark and must be downloaded separately
522 # (see below). The pyexpat module was written by Paul Prescod after a
523 # prototype by Jack Jansen.
524 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000525 # The Expat dist includes Windows .lib and .dll files. Home page is
526 # at http://www.jclark.com/xml/expat.html, the current production
527 # release is always ftp://ftp.jclark.com/pub/xml/expat.zip.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000528 #
529 # EXPAT_DIR, below, should point to the expat/ directory created by
530 # unpacking the Expat source distribution.
531 #
Andrew M. Kuchling5bbc7b92001-01-18 20:39:34 +0000532 # Note: the expat build process doesn't yet build a libexpat.a; you
533 # can do this manually while we try convince the author to add it. To
534 # do so, cd to EXPAT_DIR, run "make" if you have not done so, then
535 # run:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000536 #
537 # ar cr libexpat.a xmltok/*.o xmlparse/*.o
538 #
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000539 expat_defs = []
540 expat_incs = find_file('expat.h', inc_dirs, [])
541 if expat_incs is not None:
542 # expat.h was found
543 expat_defs = [('HAVE_EXPAT_H', 1)]
544 else:
545 expat_incs = find_file('xmlparse.h', inc_dirs, [])
Fredrik Lundhade711a2001-01-24 08:00:28 +0000546
Martin v. Löwis1ab29b22001-01-21 10:54:52 +0000547 if (expat_incs is not None and
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000548 self.compiler.find_library_file(lib_dirs, 'expat')):
549 exts.append( Extension('pyexpat', ['pyexpat.c'],
550 define_macros = expat_defs,
551 libraries = ['expat']) )
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000552
553 # Platform-specific libraries
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000554 if platform == 'linux2':
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000555 # Linux-specific modules
556 exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
557
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000558 if platform == 'sunos5':
Fredrik Lundhade711a2001-01-24 08:00:28 +0000559 # SunOS specific modules
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000560 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
Jack Jansen144ebcc2001-08-05 22:31:19 +0000561
562 if platform == 'darwin1':
563 # Mac OS X specific modules. These are ported over from MacPython
564 # and still experimental. Some (such as gestalt or icglue) are
565 # already generally useful, some (the GUI ones) really need to
566 # be used from a framework.
Jack Jansen2f760c32001-09-04 21:33:12 +0000567 #
568 # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
569 # available here. This Makefile variable is also what the install
570 # procedure triggers on.
571 frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
Jack Jansen144ebcc2001-08-05 22:31:19 +0000572 exts.append( Extension('gestalt', ['gestaltmodule.c']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000573 exts.append( Extension('MacOS', ['macosmodule.c'],
574 extra_link_args=['-framework', 'Carbon']) )
575 exts.append( Extension('icglue', ['icgluemodule.c'],
576 extra_link_args=['-framework', 'Carbon']) )
577 exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'],
578 extra_link_args=['-framework', 'Carbon']) )
579 exts.append( Extension('_CF', ['cf/_CFmodule.c']) )
580 exts.append( Extension('_Res', ['res/_Resmodule.c']) )
581 exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
582 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000583 if frameworkdir:
Jack Jansen666b1e72001-10-31 12:11:48 +0000584 exts.append( Extension('Nav', ['Nav.c'],
585 extra_link_args=['-framework', 'Carbon']) )
586 exts.append( Extension('_AE', ['ae/_AEmodule.c'],
587 extra_link_args=['-framework', 'Carbon']) )
588 exts.append( Extension('_App', ['app/_Appmodule.c'],
589 extra_link_args=['-framework', 'Carbon']) )
590 exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
591 extra_link_args=['-framework', 'Carbon']) )
592 exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
593 extra_link_args=['-framework', 'Carbon']) )
594 exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
595 extra_link_args=['-framework', 'Carbon']) )
596 exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
597 extra_link_args=['-framework', 'Carbon']) )
598 exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
599 extra_link_args=['-framework', 'Carbon']) )
600 exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
601 extra_link_args=['-framework', 'Carbon']) )
602 exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
603 extra_link_args=['-framework', 'Carbon']) )
604 exts.append( Extension('_List', ['list/_Listmodule.c'],
605 extra_link_args=['-framework', 'Carbon']) )
606 exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
607 extra_link_args=['-framework', 'Carbon']) )
608 exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
609 extra_link_args=['-framework', 'Carbon']) )
610 exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
611 extra_link_args=['-framework', 'Carbon']) )
612 exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
613 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000614 exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
Jack Jansen666b1e72001-10-31 12:11:48 +0000615 extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000616## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000617 exts.append( Extension('_TE', ['te/_TEmodule.c'],
618 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen2f760c32001-09-04 21:33:12 +0000619## exts.append( Extension('waste', ['waste/wastemodule.c']) )
Jack Jansen666b1e72001-10-31 12:11:48 +0000620 exts.append( Extension('_Win', ['win/_Winmodule.c'],
621 extra_link_args=['-framework', 'Carbon']) )
Jack Jansen144ebcc2001-08-05 22:31:19 +0000622
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000623 self.extensions.extend(exts)
624
625 # Call the method for detecting whether _tkinter can be compiled
626 self.detect_tkinter(inc_dirs, lib_dirs)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000627
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000628
629 def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000630 # The _tkinter module.
Martin v. Löwisb1d19692001-03-21 07:44:53 +0000631
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000632 # Assume we haven't found any of the libraries or include files
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000633 # The versions with dots are used on Unix, and the versions without
634 # dots on Windows, for detection by cygwin.
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000635 tcllib = tklib = tcl_includes = tk_includes = None
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000636 for version in ['8.4', '84', '8.3', '83', '8.2',
637 '82', '8.1', '81', '8.0', '80']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000638 tklib = self.compiler.find_library_file(lib_dirs,
639 'tk' + version )
640 tcllib = self.compiler.find_library_file(lib_dirs,
641 'tcl' + version )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000642 if tklib and tcllib:
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000643 # Exit the loop when we've found the Tcl/Tk libraries
644 break
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000645
Fredrik Lundhade711a2001-01-24 08:00:28 +0000646 # Now check for the header files
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000647 if tklib and tcllib:
648 # Check for the include files on Debian, where
649 # they're put in /usr/include/{tcl,tk}X.Y
Andrew M. Kuchling9a3fd8c2001-02-06 22:15:27 +0000650 debian_tcl_include = [ '/usr/include/tcl' + version ]
651 debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include
652 tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
653 tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000654
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000655 if (tcllib is None or tklib is None and
656 tcl_includes is None or tk_includes is None):
657 # Something's missing, so give up
658 return
Fredrik Lundhade711a2001-01-24 08:00:28 +0000659
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000660 # OK... everything seems to be present for Tcl/Tk.
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000661
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000662 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
663 for dir in tcl_includes + tk_includes:
664 if dir not in include_dirs:
665 include_dirs.append(dir)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000666
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000667 # Check for various platform-specific directories
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000668 platform = self.get_platform()
669 if platform == 'sunos5':
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000670 include_dirs.append('/usr/openwin/include')
671 added_lib_dirs.append('/usr/openwin/lib')
672 elif os.path.exists('/usr/X11R6/include'):
673 include_dirs.append('/usr/X11R6/include')
674 added_lib_dirs.append('/usr/X11R6/lib')
675 elif os.path.exists('/usr/X11R5/include'):
676 include_dirs.append('/usr/X11R5/include')
677 added_lib_dirs.append('/usr/X11R5/lib')
678 else:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000679 # Assume default location for X11
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000680 include_dirs.append('/usr/X11/include')
681 added_lib_dirs.append('/usr/X11/lib')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000682
Andrew M. Kuchling89fb72d2001-09-18 20:32:13 +0000683 # If Cygwin, then verify that X is installed before proceeding
684 if platform == 'cygwin':
685 x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
686 if x11_inc is None:
687 # X header files missing, so give up
688 return
689
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000690 # Check for BLT extension
691 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'BLT8.0'):
692 defs.append( ('WITH_BLT', 1) )
693 libs.append('BLT8.0')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000694
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000695 # Add the Tcl/Tk libraries
Fredrik Lundhade711a2001-01-24 08:00:28 +0000696 libs.append('tk'+version)
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000697 libs.append('tcl'+version)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000698
Andrew M. Kuchling34febf52001-01-24 03:31:07 +0000699 if platform in ['aix3', 'aix4']:
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000700 libs.append('ld')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000701
Martin v. Löwis3db5b8c2001-07-24 06:54:01 +0000702 # Finally, link with the X11 libraries (not appropriate on cygwin)
703 if platform != "cygwin":
704 libs.append('X11')
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000705
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000706 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
707 define_macros=[('WITH_APPINIT', 1)] + defs,
708 include_dirs = include_dirs,
709 libraries = libs,
710 library_dirs = added_lib_dirs,
711 )
712 self.extensions.append(ext)
Fredrik Lundhade711a2001-01-24 08:00:28 +0000713
Andrew M. Kuchlingfbe73762001-01-18 18:44:20 +0000714 # XXX handle these, but how to detect?
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000715 # *** Uncomment and edit for PIL (TkImaging) extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000716 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000717 # *** Uncomment and edit for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000718 # -DWITH_TOGL togl.c \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000719 # *** Uncomment these for TOGL extension only:
Fredrik Lundhade711a2001-01-24 08:00:28 +0000720 # -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000721
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +0000722class PyBuildInstall(install):
723 # Suppress the warning about installation into the lib_dynload
724 # directory, which is not in sys.path when running Python during
725 # installation:
726 def initialize_options (self):
727 install.initialize_options(self)
728 self.warn_dir=0
729
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000730def main():
Andrew M. Kuchling62686692001-05-21 20:48:09 +0000731 # turn off warnings when deprecated modules are imported
732 import warnings
733 warnings.filterwarnings("ignore",category=DeprecationWarning)
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000734 setup(name = 'Python standard library',
Neil Schemenauere7e2ece2001-01-17 21:58:00 +0000735 version = '%d.%d' % sys.version_info[:2],
Andrew M. Kuchlingf52d27e2001-05-21 20:29:27 +0000736 cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000737 # The struct module is defined here, because build_ext won't be
738 # called unless there's at least one extension module defined.
Andrew M. Kuchlingaece4272001-02-28 20:56:49 +0000739 ext_modules=[Extension('struct', ['structmodule.c'])],
740
741 # Scripts to install
742 scripts = ['Tools/scripts/pydoc']
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000743 )
Fredrik Lundhade711a2001-01-24 08:00:28 +0000744
Andrew M. Kuchling00e0f212001-01-17 15:23:23 +0000745# --install-platlib
746if __name__ == '__main__':
747 sysconfig.set_python_build()
748 main()