~pythonregexp2.7/python/issue2636-01

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:37:21 UTC
  • mfrom: (39022.1.14 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143721-bj0g1mwta28038da
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
import sys, os, imp, re, optparse
7
7
from glob import glob
 
8
from platform import machine as platform_machine
8
9
 
9
10
from distutils import log
10
11
from distutils import sysconfig
247
248
                'WARNING: skipping import check for Carbon-based "%s"' %
248
249
                ext.name)
249
250
            return
 
251
 
 
252
        if self.get_platform() == 'darwin' and (
 
253
                sys.maxint > 2**32 and '-arch' in ext.extra_link_args):
 
254
            # Don't bother doing an import check when an extension was
 
255
            # build with an explicit '-arch' flag on OSX. That's currently
 
256
            # only used to build 32-bit only extensions in a 4-way
 
257
            # universal build and loading 32-bit code into a 64-bit
 
258
            # process will fail.
 
259
            self.announce(
 
260
                'WARNING: skipping import check for "%s"' %
 
261
                ext.name)
 
262
            return
 
263
 
250
264
        # Workaround for Cygwin: Cygwin currently has fork issues when many
251
265
        # modules have been imported
252
266
        if self.get_platform() == 'cygwin':
540
554
 
541
555
        # readline
542
556
        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
543
 
        if platform == 'darwin':
 
557
        if platform == 'darwin': # and os.uname()[2] < '9.':
544
558
            # MacOSX 10.4 has a broken readline. Don't try to build
545
559
            # the readline module unless the user has installed a fixed
546
560
            # readline package
 
561
            # FIXME: The readline emulation on 10.5 is better, but the
 
562
            # readline module doesn't compile out of the box.
547
563
            if find_file('readline/rlconf.h', inc_dirs, []) is None:
548
564
                do_readline = False
549
565
        if do_readline:
687
703
        # a release.  Most open source OSes come with one or more
688
704
        # versions of BerkeleyDB already installed.
689
705
 
690
 
        max_db_ver = (4, 5)  # XXX(gregory.p.smith): 4.6 "works" but seems to
691
 
                             # have issues on many platforms.  I've temporarily
692
 
                             # disabled 4.6 to see what the odd platform
693
 
                             # buildbots say.
 
706
        max_db_ver = (4, 7)
694
707
        min_db_ver = (3, 3)
695
708
        db_setup_debug = False   # verbose debug prints from this script?
696
709
 
 
710
        def allow_db_ver(db_ver):
 
711
            """Returns a boolean if the given BerkeleyDB version is acceptable.
 
712
 
 
713
            Args:
 
714
              db_ver: A tuple of the version to verify.
 
715
            """
 
716
            if not (min_db_ver <= db_ver <= max_db_ver):
 
717
                return False
 
718
            # Use this function to filter out known bad configurations.
 
719
            if (4, 6) == db_ver[:2]:
 
720
                # BerkeleyDB 4.6.x is not stable on many architectures.
 
721
                arch = platform_machine()
 
722
                if arch not in ('i386', 'i486', 'i586', 'i686',
 
723
                                'x86_64', 'ia64'):
 
724
                    return False
 
725
            return True
 
726
 
 
727
        def gen_db_minor_ver_nums(major):
 
728
            if major == 4:
 
729
                for x in range(max_db_ver[1]+1):
 
730
                    if allow_db_ver((4, x)):
 
731
                        yield x
 
732
            elif major == 3:
 
733
                for x in (3,):
 
734
                    if allow_db_ver((3, x)):
 
735
                        yield x
 
736
            else:
 
737
                raise ValueError("unknown major BerkeleyDB version", major)
 
738
 
697
739
        # construct a list of paths to look for the header file in on
698
740
        # top of the normal inc_dirs.
699
741
        db_inc_paths = [
708
750
            '/sw/include/db3',
709
751
        ]
710
752
        # 4.x minor number specific paths
711
 
        for x in range(max_db_ver[1]+1):
 
753
        for x in gen_db_minor_ver_nums(4):
712
754
            db_inc_paths.append('/usr/include/db4%d' % x)
713
755
            db_inc_paths.append('/usr/include/db4.%d' % x)
714
756
            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
718
760
            # MacPorts default (http://www.macports.org/)
719
761
            db_inc_paths.append('/opt/local/include/db4%d' % x)
720
762
        # 3.x minor number specific paths
721
 
        for x in (3,):
 
763
        for x in gen_db_minor_ver_nums(3):
722
764
            db_inc_paths.append('/usr/include/db3%d' % x)
723
765
            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
724
766
            db_inc_paths.append('/usr/local/include/db3%d' % x)
733
775
        for dn in inc_dirs:
734
776
            std_variants.append(os.path.join(dn, 'db3'))
735
777
            std_variants.append(os.path.join(dn, 'db4'))
736
 
            for x in range(max_db_ver[1]+1):
 
778
            for x in gen_db_minor_ver_nums(4):
737
779
                std_variants.append(os.path.join(dn, "db4%d"%x))
738
780
                std_variants.append(os.path.join(dn, "db4.%d"%x))
739
 
            for x in (3,):
 
781
            for x in gen_db_minor_ver_nums(3):
740
782
                std_variants.append(os.path.join(dn, "db3%d"%x))
741
783
                std_variants.append(os.path.join(dn, "db3.%d"%x))
742
784
 
771
813
                                continue
772
814
 
773
815
                        if ( (not db_ver_inc_map.has_key(db_ver)) and
774
 
                           (db_ver <= max_db_ver and db_ver >= min_db_ver) ):
 
816
                            allow_db_ver(db_ver) ):
775
817
                            # save the include directory with the db.h version
776
818
                            # (first occurrence only)
777
819
                            db_ver_inc_map[db_ver] = d
816
858
 
817
859
        except db_found:
818
860
            if db_setup_debug:
819
 
                print "db lib: using", db_ver, dblib
820
 
                print "db: lib dir", dblib_dir, "inc dir", db_incdir
 
861
                print "bsddb using BerkeleyDB lib:", db_ver, dblib
 
862
                print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
821
863
            db_incs = [db_incdir]
822
864
            dblibs = [dblib]
823
865
            # We add the runtime_library_dirs argument because the
1277
1319
                           '_Dlg', '_Drag', '_Evt', '_File', '_Folder', '_Fm',
1278
1320
                           '_Help', '_Icn', '_IBCarbon', '_List',
1279
1321
                           '_Menu', '_Mlte', '_OSA', '_Res', '_Qd', '_Qdoffs',
1280
 
                           '_Scrap', '_Snd', '_TE', '_Win',
 
1322
                           '_Scrap', '_Snd', '_TE',
1281
1323
                          ]
1282
1324
            for name in CARBON_EXTS:
1283
1325
                addMacExtension(name, carbon_kwds)
1284
1326
 
 
1327
            # Workaround for a bug in the version of gcc shipped with Xcode 3.
 
1328
            # The _Win extension should build just like the other Carbon extensions, but
 
1329
            # this actually results in a hard crash of the linker.
 
1330
            #
 
1331
            if '-arch ppc64' in cflags and '-arch ppc' in cflags:
 
1332
                win_kwds = {'extra_compile_args': carbon_extra_compile_args + ['-arch', 'i386', '-arch', 'ppc'],
 
1333
                               'extra_link_args': ['-framework', 'Carbon', '-arch', 'i386', '-arch', 'ppc'],
 
1334
                           }
 
1335
                addMacExtension('_Win', win_kwds)
 
1336
            else:
 
1337
                addMacExtension('_Win', carbon_kwds)
 
1338
 
 
1339
 
1285
1340
            # Application Services & QuickTime
1286
1341
            app_kwds = {'extra_compile_args': carbon_extra_compile_args,
1287
1342
                        'extra_link_args': ['-framework','ApplicationServices'],
1348
1403
        include_dirs.append('/usr/X11R6/include')
1349
1404
        frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
1350
1405
 
 
1406
        # All existing framework builds of Tcl/Tk don't support 64-bit
 
1407
        # architectures.
 
1408
        cflags = sysconfig.get_config_vars('CFLAGS')[0]
 
1409
        archs = re.findall('-arch\s+(\w+)', cflags)
 
1410
        if 'x86_64' in archs or 'ppc64' in archs:
 
1411
            try:
 
1412
                archs.remove('x86_64')
 
1413
            except ValueError:
 
1414
                pass
 
1415
            try:
 
1416
                archs.remove('ppc64')
 
1417
            except ValueError:
 
1418
                pass
 
1419
 
 
1420
            for a in archs:
 
1421
                frameworks.append('-arch')
 
1422
                frameworks.append(a)
 
1423
 
1351
1424
        ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1352
1425
                        define_macros=[('WITH_APPINIT', 1)],
1353
1426
                        include_dirs = include_dirs,
1354
1427
                        libraries = [],
1355
 
                        extra_compile_args = frameworks,
 
1428
                        extra_compile_args = frameworks[2:],
1356
1429
                        extra_link_args = frameworks,
1357
1430
                        )
1358
1431
        self.extensions.append(ext)
1483
1556
                                                  '_ctypes', 'libffi_osx'))
1484
1557
        sources = [os.path.join(ffi_srcdir, p)
1485
1558
                   for p in ['ffi.c',
 
1559
                             'x86/darwin64.S',
1486
1560
                             'x86/x86-darwin.S',
1487
1561
                             'x86/x86-ffi_darwin.c',
1488
1562
                             'x86/x86-ffi64.c',
1580
1654
            # finding some -z option for the Sun compiler.
1581
1655
            extra_link_args.append('-mimpure-text')
1582
1656
 
1583
 
        elif sys.platform.startswith('hpux'):
 
1657
        elif sys.platform.startswith('hp-ux'):
1584
1658
            extra_link_args.append('-fPIC')
1585
1659
 
1586
1660
        ext = Extension('_ctypes',