setup.py 44 KB
Newer Older
1 2
# Autodetecting setup.py script for building the Python extensions
#
3

4 5
__version__ = "$Revision$"

Michael W. Hudson's avatar
Fix for  
Michael W. Hudson committed
6
import sys, os, getopt, imp
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
7
from distutils import sysconfig
8
from distutils import text_file
Marc-André Lemburg's avatar
Marc-André Lemburg committed
9
from distutils.errors import *
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
10 11
from distutils.core import Extension, setup
from distutils.command.build_ext import build_ext
12
from distutils.command.install import install
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
13 14 15 16

# This global variable is used to hold the list of modules to be disabled.
disabled_module_list = []

Michael W. Hudson's avatar
Michael W. Hudson committed
17 18 19 20
def add_dir_to_list(dirlist, dir):
    """Add the directory 'dir' to the list 'dirlist' (at the front) if
    1) 'dir' is not already in 'dirlist'
    2) 'dir' actually exists, and is a directory."""
21
    if dir is not None and os.path.isdir(dir) and dir not in dirlist:
Michael W. Hudson's avatar
Michael W. Hudson committed
22 23
        dirlist.insert(0, dir)

24 25 26 27
def find_file(filename, std_dirs, paths):
    """Searches for the directory where a given file is located,
    and returns a possibly-empty list of additional directories, or None
    if the file couldn't be found at all.
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    'filename' is the name of a file, such as readline.h or libcrypto.a.
    'std_dirs' is the list of standard system directories; if the
        file is found in one of them, no additional directives are needed.
    'paths' is a list of additional locations to check; if the file is
        found in one of them, the resulting list will contain the directory.
    """

    # Check the standard locations
    for dir in std_dirs:
        f = os.path.join(dir, filename)
        if os.path.exists(f): return []

    # Check the additional directories
    for dir in paths:
        f = os.path.join(dir, filename)
        if os.path.exists(f):
            return [dir]

    # Not found anywhere
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
48 49
    return None

50 51 52 53
def find_library_file(compiler, libname, std_dirs, paths):
    filename = compiler.library_filename(libname, lib_type='shared')
    result = find_file(filename, std_dirs, paths)
    if result is not None: return result
54

55 56 57 58
    filename = compiler.library_filename(libname, lib_type='static')
    result = find_file(filename, std_dirs, paths)
    return result

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
59 60 61 62 63
def module_enabled(extlist, modname):
    """Returns whether the module 'modname' is present in the list
    of extensions 'extlist'."""
    extlist = [ext for ext in extlist if ext.name == modname]
    return len(extlist)
64

Jack Jansen's avatar
Jack Jansen committed
65 66 67 68 69 70 71 72 73
def find_module_file(module, dirlist):
    """Find a module in a set of possible folders. If it is not found
    return the unadorned filename"""
    list = find_file(module, [], dirlist)
    if not list:
        return module
    if len(list) > 1:
        self.announce("WARNING: multiple copies of %s found"%module)
    return os.path.join(list[0], module)
74

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
75
class PyBuildExt(build_ext):
76

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
77 78 79 80 81 82 83 84
    def build_extensions(self):

        # Detect which modules should be compiled
        self.detect_modules()

        # Remove modules that are present on the disabled list
        self.extensions = [ext for ext in self.extensions
                           if ext.name not in disabled_module_list]
85

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
86 87 88 89
        # Fix up the autodetected modules, prefixing all the source files
        # with Modules/ and adding Python's include directory to the path.
        (srcdir,) = sysconfig.get_config_vars('srcdir')

90 91
        # Figure out the location of the source code for extension modules
        moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
92 93 94 95
        moddir = os.path.normpath(moddir)
        srcdir, tail = os.path.split(moddir)
        srcdir = os.path.normpath(srcdir)
        moddir = os.path.normpath(moddir)
96

Jack Jansen's avatar
Jack Jansen committed
97 98
        moddirlist = [moddir]
        incdirlist = ['./Include']
99

Jack Jansen's avatar
Jack Jansen committed
100 101
        # Platform-dependent module source and include directories
        platform = self.get_platform()
102
        if platform in ('darwin', 'mac'):
Jack Jansen's avatar
Jack Jansen committed
103 104 105 106
            # Mac OS X also includes some mac-specific modules
            macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
            moddirlist.append(macmoddir)
            incdirlist.append('./Mac/Include')
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
107

108 109
        alldirlist = moddirlist + incdirlist

110 111 112 113
        # Fix up the paths for scripts, too
        self.distribution.scripts = [os.path.join(srcdir, filename)
                                     for filename in self.distribution.scripts]

114
        for ext in self.extensions[:]:
Jack Jansen's avatar
Jack Jansen committed
115
            ext.sources = [ find_module_file(filename, moddirlist)
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
116
                            for filename in ext.sources ]
117 118 119
            if ext.depends is not None:
                ext.depends = [find_module_file(filename, alldirlist)
                               for filename in ext.depends]
Jack Jansen's avatar
Jack Jansen committed
120 121 122
            ext.include_dirs.append( '.' ) # to get config.h
            for incdir in incdirlist:
                ext.include_dirs.append( os.path.join(srcdir, incdir) )
123

124
            # If a module has already been built statically,
125
            # don't build it here
126
            if ext.name in sys.builtin_module_names:
127
                self.extensions.remove(ext)
128

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
        if platform != 'mac':
            # Parse Modules/Setup to figure out which modules are turned
            # on in the file.
            input = text_file.TextFile('Modules/Setup', join_lines=1)
            remove_modules = []
            while 1:
                line = input.readline()
                if not line: break
                line = line.split()
                remove_modules.append( line[0] )
            input.close()
    
            for ext in self.extensions[:]:
                if ext.name in remove_modules:
                    self.extensions.remove(ext)
144

145 146 147 148 149 150 151 152 153
        # When you run "make CC=altcc" or something similar, you really want
        # those environment variables passed into the setup.py phase.  Here's
        # a small set of useful ones.
        compiler = os.environ.get('CC')
        linker_so = os.environ.get('LDSHARED')
        args = {}
        # unfortunately, distutils doesn't let us provide separate C and C++
        # compilers
        if compiler is not None:
154 155
            (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT')
            args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared
156
        if linker_so is not None:
157
            args['linker_so'] = linker_so
158 159
        self.compiler.set_executables(**args)

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
160 161
        build_ext.build_extensions(self)

Marc-André Lemburg's avatar
Marc-André Lemburg committed
162 163 164 165 166 167 168
    def build_extension(self, ext):

        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsError), why:
            self.announce('WARNING: building of extension "%s" failed: %s' %
                          (ext.name, sys.exc_info()[1]))
169
            return
170 171 172
        # Workaround for Mac OS X: The Carbon-based modules cannot be
        # reliably imported into a command-line Python
        if 'Carbon' in ext.extra_link_args:
173 174 175 176
            self.announce(
                'WARNING: skipping import check for Carbon-based "%s"' %
                ext.name)
            return
177 178 179 180 181 182
        # Workaround for Cygwin: Cygwin currently has fork issues when many
        # modules have been imported
        if self.get_platform() == 'cygwin':
            self.announce('WARNING: skipping import check for Cygwin-based "%s"'
                % ext.name)
            return
Michael W. Hudson's avatar
Fix for  
Michael W. Hudson committed
183 184 185
        ext_filename = os.path.join(
            self.build_lib,
            self.get_ext_filename(self.get_ext_fullname(ext.name)))
186
        try:
Michael W. Hudson's avatar
Fix for  
Michael W. Hudson committed
187
            imp.load_dynamic(ext.name, ext_filename)
188 189 190
        except ImportError, why:

            if 1:
191
                self.announce('*** WARNING: renaming "%s" since importing it'
192 193
                              ' failed: %s' % (ext.name, why))
                assert not self.inplace
194 195 196 197
                basename, tail = os.path.splitext(ext_filename)
                newname = basename + "_failed" + tail
                if os.path.exists(newname): os.remove(newname)
                os.rename(ext_filename, newname)
198 199 200 201 202

                # XXX -- This relies on a Vile HACK in
                # distutils.command.build_ext.build_extension().  The
                # _built_objects attribute is stored there strictly for
                # use here.
203 204 205 206 207 208 209
                # If there is a failure, _built_objects may not be there,
                # so catch the AttributeError and move on.
                try:
                    for filename in self._built_objects:
                        os.remove(filename)
                except AttributeError:
                    self.announce('unable to remove files (ignored)')
210 211 212
            else:
                self.announce('*** WARNING: importing extension "%s" '
                              'failed: %s' % (ext.name, why))
213

214
    def get_platform (self):
215 216 217 218
        # Get value of sys.platform
        platform = sys.platform
        if platform[:6] =='cygwin':
            platform = 'cygwin'
219 220
        elif platform[:4] =='beos':
            platform = 'beos'
221 222
        elif platform[:6] == 'darwin':
            platform = 'darwin'
Martin v. Löwis's avatar
Martin v. Löwis committed
223 224
        elif platform[:6] == 'atheos':
            platform = 'atheos'
225

226
        return platform
227

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
228
    def detect_modules(self):
229
        # Ensure that /usr/local is always used
Michael W. Hudson's avatar
Michael W. Hudson committed
230 231 232 233 234 235 236
        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

        add_dir_to_list(self.compiler.library_dirs,
                        sysconfig.get_config_var("LIBDIR"))
        add_dir_to_list(self.compiler.include_dirs,
                        sysconfig.get_config_var("INCLUDEDIR"))
237

238 239 240 241 242
        try:
            have_unicode = unicode
        except NameError:
            have_unicode = 0

243 244 245 246
        # lib_dirs and inc_dirs are used to search for files;
        # if a file is found in one of those directories, it can
        # be assumed that no additional -I,-L directives are needed.
        lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
247
        inc_dirs = self.compiler.include_dirs + ['/usr/include']
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
248 249
        exts = []

250
        platform = self.get_platform()
251
        (srcdir,) = sysconfig.get_config_vars('srcdir')
252

Martin v. Löwis's avatar
Martin v. Löwis committed
253 254 255 256 257 258 259
        # Check for AtheOS which has libraries in non-standard locations
        if platform == 'atheos':
            lib_dirs += ['/system/libs', '/atheos/autolnk/lib']
            lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
            inc_dirs += ['/system/include', '/atheos/autolnk/include']
            inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)

260 261
        # Check for MacOS X, which doesn't need libm.a at all
        math_libs = ['m']
262
        if platform in ['darwin', 'beos', 'mac']:
263
            math_libs = []
264

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
265 266 267 268 269 270
        # XXX Omitted modules: gl, pure, dl, SGI-specific modules

        #
        # The following modules are all pretty straightforward, and compile
        # on pretty much any POSIXish platform.
        #
271

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
272 273 274
        # Some modules that are normally always on:
        exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
        exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
275

Fred Drake's avatar
Fred Drake committed
276
        exts.append( Extension('_hotshot', ['_hotshot.c']) )
277
        exts.append( Extension('_weakref', ['_weakref.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
278
        exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
279 280 281 282

        # array objects
        exts.append( Extension('array', ['arraymodule.c']) )
        # complex math library functions
283 284
        exts.append( Extension('cmath', ['cmathmodule.c'],
                               libraries=math_libs) )
285

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
286
        # math library functions, e.g. sin()
287 288
        exts.append( Extension('math',  ['mathmodule.c'],
                               libraries=math_libs) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
289 290 291
        # fast string operations implemented in C
        exts.append( Extension('strop', ['stropmodule.c']) )
        # time operations and variables
292 293
        exts.append( Extension('time', ['timemodule.c'],
                               libraries=math_libs) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
294 295 296 297
        # operator.add() and similar goodies
        exts.append( Extension('operator', ['operator.c']) )
        # access to the builtin codecs and codec registry
        exts.append( Extension('_codecs', ['_codecsmodule.c']) )
Marc-André Lemburg's avatar
Marc-André Lemburg committed
298
        # Python C API test module
299
        exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
300
        # static Unicode character database
301 302
        if have_unicode:
            exts.append( Extension('unicodedata', ['unicodedata.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
        # access to ISO C locale support
        exts.append( Extension('_locale', ['_localemodule.c']) )

        # Modules with some UNIX dependencies -- on by default:
        # (If you have a really backward UNIX, select and socket may not be
        # supported...)

        # fcntl(2) and ioctl(2)
        exts.append( Extension('fcntl', ['fcntlmodule.c']) )
        # pwd(3)
        exts.append( Extension('pwd', ['pwdmodule.c']) )
        # grp(3)
        exts.append( Extension('grp', ['grpmodule.c']) )
        # posix (UNIX) errno values
        exts.append( Extension('errno', ['errnomodule.c']) )
        # select(2); not on ancient System V
        exts.append( Extension('select', ['selectmodule.c']) )

        # The md5 module implements the RSA Data Security, Inc. MD5
Fred Drake's avatar
Fred Drake committed
322 323
        # Message-Digest Algorithm, described in RFC 1321.  The
        # necessary files md5c.c and md5.h are included here.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
324 325 326 327 328 329 330 331 332 333 334 335
        exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )

        # The sha module implements the SHA checksum algorithm.
        # (NIST's Secure Hash Algorithm.)
        exts.append( Extension('sha', ['shamodule.c']) )

        # Helper module for various ascii-encoders
        exts.append( Extension('binascii', ['binascii.c']) )

        # Fred Drake's interface to the Python parser
        exts.append( Extension('parser', ['parsermodule.c']) )

336
        # cStringIO and cPickle
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
337 338 339 340
        exts.append( Extension('cStringIO', ['cStringIO.c']) )
        exts.append( Extension('cPickle', ['cPickle.c']) )

        # Memory-mapped files (also works on Win32).
Martin v. Löwis's avatar
Martin v. Löwis committed
341 342
        if platform not in ['atheos']:
            exts.append( Extension('mmap', ['mmapmodule.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
343 344 345 346 347 348 349 350 351 352 353

        # Lance Ellinghaus's modules:
        # enigma-inspired encryption
        exts.append( Extension('rotor', ['rotormodule.c']) )
        # syslog daemon interface
        exts.append( Extension('syslog', ['syslogmodule.c']) )

        # George Neville-Neil's timing module:
        exts.append( Extension('timing', ['timingmodule.c']) )

        #
354 355
        # Here ends the simple stuff.  From here on, modules need certain
        # libraries, are platform-specific, or present other surprises.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
356 357 358 359 360 361
        #

        # Multimedia modules
        # These don't work for 64-bit platforms!!!
        # These represent audio samples or images as strings:

362
        # Disabled on 64-bit platforms
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
363 364 365 366 367 368 369 370 371
        if sys.maxint != 9223372036854775807L:
            # Operations on audio samples
            exts.append( Extension('audioop', ['audioop.c']) )
            # Operations on images
            exts.append( Extension('imageop', ['imageop.c']) )
            # Read SGI RGB image files (but coded portably)
            exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )

        # readline
372 373
        if self.compiler.find_library_file(lib_dirs, 'readline'):
            readline_libs = ['readline']
374 375 376 377
            if self.compiler.find_library_file(lib_dirs,
                                                 'ncurses'):
                readline_libs.append('ncurses')
            elif self.compiler.find_library_file(lib_dirs +
378 379 380
                                               ['/usr/lib/termcap'],
                                               'termcap'):
                readline_libs.append('termcap')
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
381
            exts.append( Extension('readline', ['readline.c'],
Marc-André Lemburg's avatar
Marc-André Lemburg committed
382
                                   library_dirs=['/usr/lib/termcap'],
383
                                   libraries=readline_libs) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
384

385
        # crypt module.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
386 387 388 389 390 391 392 393

        if self.compiler.find_library_file(lib_dirs, 'crypt'):
            libs = ['crypt']
        else:
            libs = []
        exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )

        # socket(2)
394
        exts.append( Extension('_socket', ['socketmodule.c'],
395
                               depends = ['socketmodule.h']) )
396
        # Detect SSL support for the socket module (via _ssl)
397
        ssl_incs = find_file('openssl/ssl.h', inc_dirs,
398 399 400
                             ['/usr/local/ssl/include',
                              '/usr/contrib/ssl/include/'
                             ]
401 402
                             )
        ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
403 404 405
                                     ['/usr/local/ssl/lib',
                                      '/usr/contrib/ssl/lib/'
                                     ] )
406

407 408
        if (ssl_incs is not None and
            ssl_libs is not None):
409
            exts.append( Extension('_ssl', ['_ssl.c'],
410
                                   include_dirs = ssl_incs,
411
                                   library_dirs = ssl_libs,
412
                                   libraries = ['ssl', 'crypto'],
413
                                   depends = ['socketmodule.h']), )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
414 415 416 417 418 419 420 421

        # Modules that provide persistent dictionary-like semantics.  You will
        # probably want to arrange for at least one of them to be available on
        # your machine, though none are defined by default because of library
        # dependencies.  The Python module anydbm.py provides an
        # implementation independent wrapper for these; dumbdbm.py provides
        # similar functionality (but slower of course) implemented in Python.

422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
        # Berkeley DB interface.
        #
        # This requires the Berkeley DB code, see
        # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
        #
        # (See http://pybsddb.sourceforge.net/ for an interface to
        # Berkeley DB 3.x.)

        # when sorted in reverse order, keys for this dict must appear in the
        # order you wish to search - e.g., search for db3 before db2, db2
        # before db1
        db_try_this = {
            'db4': {'libs': ('db-4.3', 'db-4.2', 'db-4.1', 'db-4.0'),
                    'libdirs': ('/usr/local/BerkeleyDB.4.3/lib',
                                '/usr/local/BerkeleyDB.4.2/lib',
                                '/usr/local/BerkeleyDB.4.1/lib',
                                '/usr/local/BerkeleyDB.4.0/lib',
                                '/usr/lib',
                                '/opt/sfw',
                                '/sw/lib',
                                '/lib',
                                ),
                    'incdirs': ('/usr/local/BerkeleyDB.4.3/include',
                                '/usr/local/BerkeleyDB.4.2/include',
                                '/usr/local/BerkeleyDB.4.1/include',
                                '/usr/local/BerkeleyDB.4.0/include',
                                '/usr/include/db3',
                                '/opt/sfw/include/db3',
                                '/sw/include/db3',
                                '/usr/local/include/db3',
                                ),
                    'incs': ('db_185.h',)},
            'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db-3.0'),
                    'libdirs': ('/usr/local/BerkeleyDB.3.3/lib',
                                '/usr/local/BerkeleyDB.3.2/lib',
                                '/usr/local/BerkeleyDB.3.1/lib',
                                '/usr/local/BerkeleyDB.3.0/lib',
                                '/usr/lib',
                                '/opt/sfw',
                                '/sw/lib',
                                '/lib',
                                ),
                    'incdirs': ('/usr/local/BerkeleyDB.3.3/include',
                                '/usr/local/BerkeleyDB.3.2/include',
                                '/usr/local/BerkeleyDB.3.1/include',
                                '/usr/local/BerkeleyDB.3.0/include',
                                '/usr/include/db3',
                                '/opt/sfw/include/db3',
                                '/sw/include/db3',
                                '/usr/local/include/db3',
                                ),
                    'incs': ('db_185.h',)},
            'db2': {'libs': ('db2',),
                    'libdirs': ('/usr/lib', '/sw/lib', '/lib'),
                    'incdirs': ('/usr/include/db2',
                                '/usr/local/include/db2', '/sw/include/db2'),
                    'incs': ('db_185.h',)},
            # if you are willing to risk hash db file corruption you can
            # uncomment the lines below for db1.  Note that this will affect
            # not only the bsddb module, but the dbhash and anydbm modules
            # as well.  you have been warned!!!
            ##'db1': {'libs': ('db1', 'db'),
            ##        'libdirs': ('/usr/lib', '/sw/lib', '/lib'),
            ##        'incdirs': ('/usr/include/db1', '/usr/local/include/db1',
            ##                    '/usr/include', '/usr/local/include'),
            ##        'incs': ('db.h',)},
            }

        # override this list to affect the library version search order
        # for example, if you want to force version 2 to be used:
        #   db_search_order = ["db2"]
        db_search_order = db_try_this.keys()
        db_search_order.sort()
        db_search_order.reverse()
        
        find_lib_file = self.compiler.find_library_file
        class found(Exception): pass
        try:
            for dbkey in db_search_order:
                dbd = db_try_this[dbkey]
                for dblib in dbd['libs']:
                    for dbinc in dbd['incs']:
                        db_incs = find_file(dbinc, [], dbd['incdirs'])
                        dblib_dir = find_lib_file(dbd['libdirs'], dblib)
                        if db_incs and dblib_dir:
                            dblib_dir = os.path.dirname(dblib_dir)
                            dblibs = [dblib]
                            raise found
        except found:
511 512 513 514 515 516 517 518
            # A default source build puts Berkeley DB in something like
            # /usr/local/Berkeley.3.3 and the lib dir under that isn't
            # normally on ld.so's search path, unless the sysadmin has hacked
            # /etc/ld.so.conf.  We add the directory to runtime_library_dirs
            # so the proper -R/--rpath flags get passed to the linker.  This
            # is usually correct and most trouble free, but may cause problems
            # in some unusual system configurations (e.g. the directory is on
            # an NFS server that goes away).
519 520 521
            if dbinc == 'db_185.h':
                exts.append(Extension('bsddb', ['bsddbmodule.c'],
                                      library_dirs=[dblib_dir],
522
                                      runtime_library_dirs=[dblib_dir],
523 524 525 526 527 528
                                      include_dirs=db_incs,
                                      define_macros=[('HAVE_DB_185_H',1)],
                                      libraries=[dblib]))
            else:
                exts.append(Extension('bsddb', ['bsddbmodule.c'],
                                      library_dirs=[dblib_dir],
529
                                      runtime_library_dirs=[dblib_dir],
530 531 532 533 534 535 536
                                      include_dirs=db_incs,
                                      libraries=[dblib]))
        else:
            db_incs = None
            dblibs = []
            dblib_dir = None

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
537
        # The standard Unix dbm module:
538 539 540 541
        if platform not in ['cygwin']:
            if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
                exts.append( Extension('dbm', ['dbmmodule.c'],
                                       libraries = ['ndbm'] ) )
542
            elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
543
                exts.append( Extension('dbm', ['dbmmodule.c'],
544 545 546 547 548 549
                                       libraries = ['gdbm'] ) )
            elif db_incs is not None:
                exts.append( Extension('dbm', ['dbmmodule.c'],
                                       library_dirs=dblib_dir,
                                       include_dirs=db_incs,
                                       libraries=dblibs))
550 551
            else:
                exts.append( Extension('dbm', ['dbmmodule.c']) )
552

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
553 554 555 556 557 558
        # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
        if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
            exts.append( Extension('gdbm', ['gdbmmodule.c'],
                                   libraries = ['gdbm'] ) )

        # The mpz module interfaces to the GNU Multiple Precision library.
559
        # You need to ftp the GNU MP library.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
560 561
        # This was originally written and tested against GMP 1.2 and 1.3.2.
        # It has been modified by Rob Hooft to work with 2.0.2 as well, but I
562 563 564 565
        # haven't tested it recently, and it definitely doesn't work with
        # GMP 4.0.  For more complete modules, refer to
        # http://gmpy.sourceforge.net and
        # http://www.egenix.com/files/python/mxNumber.html
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
566

567
        # A compatible MP library unencumbered by the GPL also exists.  It was
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
568 569 570 571 572 573 574 575 576 577
        # posted to comp.sources.misc in volume 40 and is widely available from
        # FTP archive sites. One URL for it is:
        # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z

        if (self.compiler.find_library_file(lib_dirs, 'gmp')):
            exts.append( Extension('mpz', ['mpzmodule.c'],
                                   libraries = ['gmp'] ) )


        # Unix-only modules
578
        if platform not in ['mac', 'win32']:
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
579 580 581
            # Steen Lumholt's termios module
            exts.append( Extension('termios', ['termios.c']) )
            # Jeremy Hylton's rlimit interface
Martin v. Löwis's avatar
Martin v. Löwis committed
582 583
	    if platform not in ['atheos']:
                exts.append( Extension('resource', ['resource.c']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
584

585
            # Sun yellow pages. Some systems have the functions in libc.
Martin v. Löwis's avatar
Martin v. Löwis committed
586
            if platform not in ['cygwin', 'atheos']:
587 588 589 590 591 592
                if (self.compiler.find_library_file(lib_dirs, 'nsl')):
                    libs = ['nsl']
                else:
                    libs = []
                exts.append( Extension('nis', ['nismodule.c'],
                                       libraries = libs) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
593 594

        # Curses support, requring the System V version of curses, often
595
        # provided by the ncurses library.
596
        if platform == 'sunos4':
597
            inc_dirs += ['/usr/5include']
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
598 599 600 601 602 603
            lib_dirs += ['/usr/5lib']

        if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
            curses_libs = ['ncurses']
            exts.append( Extension('_curses', ['_cursesmodule.c'],
                                   libraries = curses_libs) )
Fred Drake's avatar
Fred Drake committed
604 605
        elif (self.compiler.find_library_file(lib_dirs, 'curses')
              and platform != 'darwin'):
606 607
                # OSX has an old Berkeley curses, not good enough for
                # the _curses module.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
608 609 610 611
            if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
                curses_libs = ['curses', 'terminfo']
            else:
                curses_libs = ['curses', 'termcap']
612

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
613 614
            exts.append( Extension('_curses', ['_cursesmodule.c'],
                                   libraries = curses_libs) )
615

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
616
        # If the curses module is enabled, check for the panel module
617
        if (module_enabled(exts, '_curses') and
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
618 619 620
            self.compiler.find_library_file(lib_dirs, 'panel')):
            exts.append( Extension('_curses_panel', ['_curses_panel.c'],
                                   libraries = ['panel'] + curses_libs) )
621 622


Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
623 624 625 626 627

        # Lee Busby's SIGFPE modules.
        # The library to link fpectl with is platform specific.
        # Choose *one* of the options below for fpectl:

628
        if platform == 'irix5':
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
629 630 631
            # For SGI IRIX (tested on 5.3):
            exts.append( Extension('fpectl', ['fpectlmodule.c'],
                                   libraries=['fpe']) )
632
        elif 0: # XXX how to detect SunPro?
Fred Drake's avatar
Fred Drake committed
633 634 635
            # For Solaris with SunPro compiler (tested on Solaris 2.5
            # with SunPro C 4.2): (Without the compiler you don't have
            # -lsunmath.)
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
636 637 638 639 640 641 642 643 644 645 646
            #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
            pass
        else:
            # For other systems: see instructions in fpectlmodule.c.
            #fpectl fpectlmodule.c ...
            exts.append( Extension('fpectl', ['fpectlmodule.c']) )


        # Andrew Kuchling's zlib module.
        # This require zlib 1.1.3 (or later).
        # See http://www.cdrom.com/pub/infozip/zlib/
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
        zlib_inc = find_file('zlib.h', [], inc_dirs)
        if zlib_inc is not None:
            zlib_h = zlib_inc[0] + '/zlib.h'
            version = '"0.0.0"'
            version_req = '"1.1.3"'
            fp = open(zlib_h)
            while 1:
                line = fp.readline()
                if not line:
                    break
                if line.find('#define ZLIB_VERSION', 0) == 0:
                    version = line.split()[2]
                    break
            if version >= version_req:
                if (self.compiler.find_library_file(lib_dirs, 'z')):
                    exts.append( Extension('zlib', ['zlibmodule.c'],
                                           libraries = ['z']) )
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
664 665 666

        # Interface to the Expat XML parser
        #
667 668 669 670 671 672 673 674 675
        # Expat was written by James Clark and is now maintained by a
        # group of developers on SourceForge; see www.libexpat.org for
        # more information.  The pyexpat module was written by Paul
        # Prescod after a prototype by Jack Jansen.  Source of Expat
        # 1.95.2 is included in Modules/expat/.  Usage of a system
        # shared libexpat.so/expat.dll is not advised.
        #
        # More information on Expat can be found at www.libexpat.org.
        #
676 677
        if sys.byteorder == "little":
            xmlbo = "12"
678
        else:
679
            xmlbo = "21"
680
        expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
681 682 683 684 685 686 687 688 689 690 691 692 693 694
        exts.append(Extension('pyexpat',
                              sources = [
            'pyexpat.c',
            'expat/xmlparse.c',
            'expat/xmlrole.c',
            'expat/xmltok.c',
            ],
                              define_macros = [
            ('HAVE_EXPAT_H',None),
            ('XML_NS', '1'),
            ('XML_DTD', '1'),
            ('XML_BYTE_ORDER', xmlbo),
            ('XML_CONTEXT_BYTES','1024'),
            ],
695
                              include_dirs = [expatinc]
696
                               ))                        
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
697

698
        # Dynamic loading module
699
        dl_inc = find_file('dlfcn.h', [], inc_dirs)
Martin v. Löwis's avatar
Martin v. Löwis committed
700
        if (dl_inc is not None) and (platform not in ['atheos']):
701 702
            exts.append( Extension('dl', ['dlmodule.c']) )

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
703
        # Platform-specific libraries
704
        if platform == 'linux2':
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
705 706 707
            # Linux-specific modules
            exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )

708
        if platform == 'sunos5':
709
            # SunOS specific modules
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
710
            exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
711

712
        if platform == 'darwin':
Jack Jansen's avatar
Jack Jansen committed
713 714 715 716
            # Mac OS X specific modules. These are ported over from MacPython
            # and still experimental. Some (such as gestalt or icglue) are
            # already generally useful, some (the GUI ones) really need to
            # be used from a framework.
717 718 719 720 721
            #
            # I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
            # available here. This Makefile variable is also what the install
            # procedure triggers on.
            frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
722
            exts.append( Extension('gestalt', ['gestaltmodule.c'],
723
                    	extra_link_args=['-framework', 'Carbon']) )
724
            exts.append( Extension('MacOS', ['macosmodule.c'],
725
                        extra_link_args=['-framework', 'Carbon']) )
726
            exts.append( Extension('icglue', ['icgluemodule.c'],
727
                        extra_link_args=['-framework', 'Carbon']) )
Fred Drake's avatar
Fred Drake committed
728 729 730
            exts.append( Extension('macfs',
                                   ['macfsmodule.c',
                                    '../Python/getapplbycreator.c'],
731
                        extra_link_args=['-framework', 'Carbon']) )
732
            exts.append( Extension('_CF', ['cf/_CFmodule.c', 'cf/pycfbridge.c'],
733 734 735
                        extra_link_args=['-framework', 'CoreFoundation']) )
            exts.append( Extension('_Res', ['res/_Resmodule.c'],
                        extra_link_args=['-framework', 'Carbon']) )
736
            exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
737
                        extra_link_args=['-framework', 'Carbon']) )
738
            if frameworkdir:
739
                exts.append( Extension('Nav', ['Nav.c'],
740
                        extra_link_args=['-framework', 'Carbon']) )
741
                exts.append( Extension('_AE', ['ae/_AEmodule.c'],
742
                        extra_link_args=['-framework', 'Carbon']) )
743
                exts.append( Extension('_App', ['app/_Appmodule.c'],
744
                        extra_link_args=['-framework', 'Carbon']) )
745
                exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'],
746
                        extra_link_args=['-framework', 'Carbon']) )
747
                exts.append( Extension('_CG', ['cg/_CGmodule.c'],
748
                        extra_link_args=['-framework', 'ApplicationServices',
749
                                         '-framework', 'Carbon']) )
750
                exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
751
                        extra_link_args=['-framework', 'Carbon']) )
752
                exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
753
                        extra_link_args=['-framework', 'Carbon']) )
754
                exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
755
                        extra_link_args=['-framework', 'Carbon']) )
756
                exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
757
                        extra_link_args=['-framework', 'Carbon']) )
758
                exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
759
                        extra_link_args=['-framework', 'Carbon']) )
760
                exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
761
                        extra_link_args=['-framework', 'Carbon']) )
762
                exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
763
                        extra_link_args=['-framework', 'Carbon']) )
764
                exts.append( Extension('_List', ['list/_Listmodule.c'],
765
                        extra_link_args=['-framework', 'Carbon']) )
766
                exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
767
                        extra_link_args=['-framework', 'Carbon']) )
768
                exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
769
                        extra_link_args=['-framework', 'Carbon']) )
770
                exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
771
                        extra_link_args=['-framework', 'Carbon']) )
772
                exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
773
                        extra_link_args=['-framework', 'Carbon']) )
774
                exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
Fred Drake's avatar
Fred Drake committed
775 776
                        extra_link_args=['-framework', 'QuickTime',
                                         '-framework', 'Carbon']) )
777
                exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'],
778
                        extra_link_args=['-framework', 'Carbon']) )
779
                exts.append( Extension('_TE', ['te/_TEmodule.c'],
780
                        extra_link_args=['-framework', 'Carbon']) )
781 782 783 784 785 786 787 788
                # As there is no standardized place (yet) to put
                # user-installed Mac libraries on OSX, we search for "waste"
                # in parent directories of the Python source tree. You
                # should put a symlink to your Waste installation in the
                # same folder as your python source tree.  Or modify the
                # next few lines:-)
                waste_incs = find_file("WASTE.h", [], 
                        ['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)])
789
                waste_libs = find_library_file(self.compiler, "WASTE", [],
790
			["../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)])
791
                if waste_incs != None and waste_libs != None:
792
                    (srcdir,) = sysconfig.get_config_vars('srcdir')
793
                    exts.append( Extension('waste',
794 795
                                   ['waste/wastemodule.c'] + [
                                    os.path.join(srcdir, d) for d in 
796 797 798 799
                                    'Mac/Wastemods/WEObjectHandlers.c',
                                    'Mac/Wastemods/WETabHooks.c',
                                    'Mac/Wastemods/WETabs.c'
                                   ],
800
                                   include_dirs = waste_incs + [os.path.join(srcdir, 'Mac/Wastemods')],
801 802 803 804
                                   library_dirs = waste_libs,
                                   libraries = ['WASTE'],
                                   extra_link_args = ['-framework', 'Carbon'],
                    ) )
805
                exts.append( Extension('_Win', ['win/_Winmodule.c'],
806 807
                        extra_link_args=['-framework', 'Carbon']) )

808 809 810 811
        self.extensions.extend(exts)

        # Call the method for detecting whether _tkinter can be compiled
        self.detect_tkinter(inc_dirs, lib_dirs)
812

813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
    def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
        # The _tkinter module, using frameworks. Since frameworks are quite
        # different the UNIX search logic is not sharable.
        from os.path import join, exists
        framework_dirs = [
            '/System/Library/Frameworks/', 
            '/Library/Frameworks', 
            join(os.getenv('HOME'), '/Library/Frameworks')
        ]

        # Find the directory that contains the Tcl.framwork and Tk.framework
        # bundles.
        # XXX distutils should support -F!
        for F in framework_dirs:
            # both Tcl.framework and Tk.framework should be present 
            for fw in 'Tcl', 'Tk':
            	if not exists(join(F, fw + '.framework')):
                    break
            else:
                # ok, F is now directory with both frameworks. Continure
                # building
                break
        else:
            # Tk and Tcl frameworks not found. Normal "unix" tkinter search
            # will now resume.
            return 0
                
        # For 8.4a2, we must add -I options that point inside the Tcl and Tk
        # frameworks. In later release we should hopefully be able to pass
        # the -F option to gcc, which specifies a framework lookup path. 
        #
        include_dirs = [
            join(F, fw + '.framework', H) 
            for fw in 'Tcl', 'Tk'
            for H in 'Headers', 'Versions/Current/PrivateHeaders'
        ]

        # For 8.4a2, the X11 headers are not included. Rather than include a 
        # complicated search, this is a hard-coded path. It could bail out
        # if X11 libs are not found...
        include_dirs.append('/usr/X11R6/include')
        frameworks = ['-framework', 'Tcl', '-framework', 'Tk']

        ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
                        define_macros=[('WITH_APPINIT', 1)],
                        include_dirs = include_dirs,
                        libraries = [],
                        extra_compile_args = frameworks,
                        extra_link_args = frameworks,
                        )
        self.extensions.append(ext)
        return 1

         
867
    def detect_tkinter(self, inc_dirs, lib_dirs):
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
868
        # The _tkinter module.
869

870 871 872 873 874 875 876 877
        # Rather than complicate the code below, detecting and building
        # AquaTk is a separate method. Only one Tkinter will be built on
        # Darwin - either AquaTk, if it is found, or X11 based Tk.
        platform = self.get_platform()
        if platform == 'darwin' and \
           self.detect_tkinter_darwin(inc_dirs, lib_dirs):
          return

878
        # Assume we haven't found any of the libraries or include files
879 880
        # The versions with dots are used on Unix, and the versions without
        # dots on Windows, for detection by cygwin.
881
        tcllib = tklib = tcl_includes = tk_includes = None
882 883
        for version in ['8.4', '84', '8.3', '83', '8.2',
                        '82', '8.1', '81', '8.0', '80']:
884 885 886 887 888
            tklib = self.compiler.find_library_file(lib_dirs,
                                                    'tk' + version )
            tcllib = self.compiler.find_library_file(lib_dirs,
                                                     'tcl' + version )
            if tklib and tcllib:
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
889 890
                # Exit the loop when we've found the Tcl/Tk libraries
                break
891

892
        # Now check for the header files
893 894 895
        if tklib and tcllib:
            # Check for the include files on Debian, where
            # they're put in /usr/include/{tcl,tk}X.Y
896
            debian_tcl_include = [ '/usr/include/tcl' + version ]
Fred Drake's avatar
Fred Drake committed
897 898
            debian_tk_include =  [ '/usr/include/tk'  + version ] + \
                                 debian_tcl_include
899 900
            tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
            tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
901 902 903 904 905

        if (tcllib is None or tklib is None and
            tcl_includes is None or tk_includes is None):
            # Something's missing, so give up
            return
906

907 908 909 910 911 912
        # OK... everything seems to be present for Tcl/Tk.

        include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
        for dir in tcl_includes + tk_includes:
            if dir not in include_dirs:
                include_dirs.append(dir)
913

914
        # Check for various platform-specific directories
915
        if platform == 'sunos5':
916 917 918 919 920 921 922 923 924
            include_dirs.append('/usr/openwin/include')
            added_lib_dirs.append('/usr/openwin/lib')
        elif os.path.exists('/usr/X11R6/include'):
            include_dirs.append('/usr/X11R6/include')
            added_lib_dirs.append('/usr/X11R6/lib')
        elif os.path.exists('/usr/X11R5/include'):
            include_dirs.append('/usr/X11R5/include')
            added_lib_dirs.append('/usr/X11R5/lib')
        else:
925
            # Assume default location for X11
926 927 928
            include_dirs.append('/usr/X11/include')
            added_lib_dirs.append('/usr/X11/lib')

929 930 931 932 933 934 935
        # If Cygwin, then verify that X is installed before proceeding
        if platform == 'cygwin':
            x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
            if x11_inc is None:
                # X header files missing, so give up
                return

936
        # Check for BLT extension
Fred Drake's avatar
Fred Drake committed
937 938
        if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
                                           'BLT8.0'):
939 940 941 942
            defs.append( ('WITH_BLT', 1) )
            libs.append('BLT8.0')

        # Add the Tcl/Tk libraries
943
        libs.append('tk'+version)
944
        libs.append('tcl'+version)
945

946
        if platform in ['aix3', 'aix4']:
947 948
            libs.append('ld')

949 950 951
        # Finally, link with the X11 libraries (not appropriate on cygwin)
        if platform != "cygwin":
            libs.append('X11')
952 953 954 955 956 957 958 959

        ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
                        define_macros=[('WITH_APPINIT', 1)] + defs,
                        include_dirs = include_dirs,
                        libraries = libs,
                        library_dirs = added_lib_dirs,
                        )
        self.extensions.append(ext)
960

961
        # XXX handle these, but how to detect?
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
962
        # *** Uncomment and edit for PIL (TkImaging) extension only:
963
        #       -DWITH_PIL -I../Extensions/Imaging/libImaging  tkImaging.c \
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
964
        # *** Uncomment and edit for TOGL extension only:
965
        #       -DWITH_TOGL togl.c \
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
966
        # *** Uncomment these for TOGL extension only:
967
        #       -lGL -lGLU -lXext -lXmu \
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
968

969 970 971 972 973 974 975
class PyBuildInstall(install):
    # Suppress the warning about installation into the lib_dynload
    # directory, which is not in sys.path when running Python during
    # installation:
    def initialize_options (self):
        install.initialize_options(self)
        self.warn_dir=0
976

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
977
def main():
978 979 980
    # turn off warnings when deprecated modules are imported
    import warnings
    warnings.filterwarnings("ignore",category=DeprecationWarning)
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
981
    setup(name = 'Python standard library',
Neil Schemenauer's avatar
Neil Schemenauer committed
982
          version = '%d.%d' % sys.version_info[:2],
983
          cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
984 985
          # The struct module is defined here, because build_ext won't be
          # called unless there's at least one extension module defined.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
986 987 988 989
          ext_modules=[Extension('struct', ['structmodule.c'])],

          # Scripts to install
          scripts = ['Tools/scripts/pydoc']
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
990
        )
991

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
992 993 994
# --install-platlib
if __name__ == '__main__':
    main()