Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

Location:
python/vendor/current/Mac/BuildScript
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Mac/BuildScript/README.txt

    r2 r388  
    1 Building a MacPython distribution
    2 =================================
     1Building a Python Mac OS X distribution
     2=======================================
    33
    4 The ``build-install.py`` script creates MacPython distributions, including
    5 sleepycat db4, sqlite3 and readline support.  It builds a complete
     4The ``build-install.py`` script creates Python distributions, including
     5certain third-party libraries as necessary.  It builds a complete
    66framework-based Python out-of-tree, installs it in a funny place with
    77$DESTROOT, massages that installation to remove .pyc files and such, creates
     
    99and ``scripts`` and placed that on a ``.dmg`` disk image.
    1010
    11 Prerequisites
    12 -------------
     11For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants
     12for each release.
    1313
    14 * A MacOS X 10.4 (or later)
     141.  32-bit-only, i386 and PPC universal, capable on running on all machines
     15    supported by Mac OS X 10.3.9 through (at least) 10.8::
    1516
    16 * XCode 2.2 (or later), with the universal SDK
     17        /usr/bin/python build-installer.py \
     18            --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
     19            --universal-archs=32-bit \
     20            --dep-target=10.3
    1721
    18 * No Fink (in ``/sw``) or DarwinPorts (in ``/opt/local``), those could
     22    - builds the following third-party libraries
     23
     24        * Bzip2
     25        * NCurses
     26        * GNU Readline (GPL)
     27        * SQLite 3.7.13
     28        * Zlib 1.2.3
     29        * Oracle Sleepycat DB 4.8 (Python 2.x only)
     30
     31    - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
     32
     33    - recommended build environment:
     34       
     35        * Mac OS X 10.5.8 PPC or Intel
     36        * Xcode 3.1.4
     37        * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
     38        * ``MACOSX_DEPLOYMENT_TARGET=10.3``
     39        * Apple ``gcc-4.0``
     40        * system Python 2.5 for documentation build with Sphinx
     41
     42    - alternate build environments:
     43
     44        * Mac OS X 10.6.8 with Xcode 3.2.6
     45            - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
     46        * Note Xcode 4.* does not support building for PPC so cannot be used for this build
     47
     48
     492.  64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
     50
     51        /usr/bin/python build-installer.py \
     52            --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
     53            --universal-archs=intel \
     54            --dep-target=10.6
     55
     56    - builds the following third-party libraries
     57
     58        * NCurses 5.9 (http://bugs.python.org/issue15037)
     59        * SQLite 3.7.13
     60
     61    - uses system-supplied versions of third-party libraries
     62
     63        * readline module links with Apple BSD editline (libedit)
     64        * builds Oracle Sleepycat DB 4.8 (Python 2.x only)
     65
     66    - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building
     67
     68    - recommended build environment:
     69
     70        * Mac OS X 10.6.8 (or later)
     71        * Xcode 3.2.6
     72        * ``MacOSX10.6`` SDK
     73        * ``MACOSX_DEPLOYMENT_TARGET=10.6``
     74        * Apple ``gcc-4.2``
     75        * system Python 2.6 for documentation build with Sphinx
     76
     77    - alternate build environments:
     78
     79        * none.  Xcode 4.x currently supplies two C compilers.
     80          ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and
     81          produce a non-functional Python executable.  As it appears to be
     82          considered a migration aid by Apple and is not likely to be fixed,
     83          its use should be avoided.  The other compiler, ``clang``, has been
     84          undergoing rapid development.  While it appears to have become
     85          production-ready in the most recent Xcode 4 releases (Xcode 4.5.x
     86          as of this writing), there are still some open issues when
     87          building Python and there has not yet been the level of exposure in
     88          production environments that the Xcode 3 gcc-4.2 compiler has had.
     89
     90
     91General Prerequisites
     92---------------------
     93
     94* No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local
     95  libraries or utilities (in ``/usr/local``) as they could
    1996  interfere with the build.
    2097
    21 * The documentation for the release must be available on python.org
     98* The documentation for the release is built using Sphinx
    2299  because it is included in the installer.
     100
     101* It is safest to start each variant build with an empty source directory
     102  populated with a fresh copy of the untarred source.
     103
     104* It is recommended that you remove any existing installed version of the
     105  Python being built::
     106
     107      sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n
    23108
    24109
     
    26111----------
    27112
    28 Here are the steps you need to follow to build a MacPython installer:
     113Here are the steps you need to follow to build a Python installer:
    29114
    30 *  Run ``./build-installer.py``. Optionally you can pass a number of arguments
    31    to specify locations of various files. Please see the top of
     115* Run ``build-installer.py``. Optionally you can pass a number of arguments
     116  to specify locations of various files. Please see the top of
    32117  ``build-installer.py`` for its usage.
    33118
    34   Running this script takes some time, I will not only build Python itself
     119  Running this script takes some time, it will not only build Python itself
    35120  but also some 3th-party libraries that are needed for extensions.
    36121
     
    38123  somewhere in ``/tmp/_py``).
    39124
    40 Building a 4-way universal installer
    41 ....................................
     125Building other universal installers
     126...................................
    42127
    43128It is also possible to build a 4-way universal installer that runs on
    44 OSX Leopard or later::
     129OS X 10.5 Leopard or later::
    45130
    46   $ ./build-installer.py --dep-target=10.5 --universal-archs=all --sdk=/
     131    /usr/bin/python /build-installer.py \
     132        --dep-target=10.5
     133        --universal-archs=all
     134        --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
    47135
    48 This requires that the deployment target is 10.5 (or later), and hence
    49 also that your building on at least OSX 10.5.
     136This requires that the deployment target is 10.5, and hence
     137also that you are building on at least OS X 10.5.  4-way includes
     138``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5).  ``ppc64`` executable
     139variants can only be run on G5 machines running 10.5.  Note that,
     140while OS X 10.6 is only supported on Intel-based machines, it is possible
     141to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
     142emulation in OS X 10.5 and 10.6.  The 4-way installer variant must be
     143built with Xcode 3.  It is not regularly built or tested.
     144
     145Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
     146and ``3-way`` (``ppc``, ``i386``, ``x86_64``).  None of these options
     147are regularly exercised; use at your own risk.
     148
    50149
    51150Testing
    52151-------
    53152
    54 The resulting binaries should work on MacOSX 10.3.9 or later. I usually run
    55 the installer on a 10.3.9, a 10.4.x PPC and a 10.4.x Intel system and then
    56 run the testsuite to make sure.
     153Ideally, the resulting binaries should be installed and the test suite run
     154on all supported OS X releases and architectures.  As a practical matter,
     155that is generally not possible.  At a minimum, variant 1 should be run on
     156a PPC G4 system with OS X 10.5 and at least one Intel system running OS X
     15710.8, 10.7, 10.6, or 10.5.  Variant 2 should be run on 10.8, 10.7, and 10.6
     158systems in both 32-bit and 64-bit modes.::
    57159
     160    /usr/local/bin/pythonn.n -m test -w -u all,-largefile
     161    /usr/local/bin/pythonn.n-32 -m test -w -u all
     162   
     163Certain tests will be skipped and some cause the interpreter to fail
     164which will likely generate ``Python quit unexpectedly`` alert messages
     165to be generated at several points during a test run.  These are normal
     166during testing and can be ignored.
    58167
    59 Announcements
    60 -------------
     168It is also recommend to launch IDLE and verify that it is at least
     169functional.  Double-click on the IDLE app icon in ``/Applications/Pythonn.n``.
     170It should also be tested from the command line::
    61171
    62 (This is mostly of historic interest)
     172    /usr/local/bin/idlen.n
    63173
    64 When all is done, announcements can be posted to at least the following
    65 places:
    66 -   pythonmac-sig@python.org
    67 -   python-dev@python.org
    68 -   python-announce@python.org
    69 -   archivist@info-mac.org
    70 -   adcnews@apple.com
    71 -   news@macnn.com
    72 -   http://www.macupdate.com
    73 -   http://guide.apple.com/usindex.lasso
    74 -   http://www.apple.com/downloads/macosx/submit
    75 -   http://www.versiontracker.com/ (userid Jack.Jansen@oratrix.com)
    76 -   http://www.macshareware.net (userid jackjansen)
    77 
    78 Also, check out Stephan Deibels http://pythonology.org/market contact list
  • python/vendor/current/Mac/BuildScript/build-installer.py

    r2 r388  
    1 #!/usr/bin/python
     1#!/usr/bin/env python
    22"""
    3 This script is used to build the "official unofficial" universal build on
    4 Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its
    5 work.  64-bit or four-way universal builds require at least OS X 10.5 and
    6 the 10.5 SDK.
    7 
    8 Please ensure that this script keeps working with Python 2.3, to avoid
    9 bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4)
     3This script is used to build "official" universal installers on Mac OS X.
     4It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for
     532-bit builds.  64-bit or four-way universal builds require at least
     6OS X 10.5 and the 10.5 SDK.
     7
     8Please ensure that this script keeps working with Python 2.5, to avoid
     9bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5).  Sphinx,
     10which is used to build the documentation, currently requires at least
     11Python 2.4.
     12
     13In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script
     14requires an installed version of hg and a third-party version of
     15Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5
     16(for 10.6 or later) installed in /Library/Frameworks.  When installed,
     17the Python built by this script will attempt to dynamically link first to
     18Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall
     19back to the ones in /System/Library/Framework.  For the build, we recommend
     20installing the most recent ActiveTcl 8.4 or 8.5 version.
     21
     2232-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5
     23and the installation of additional components, such as a newer Python
     24(2.5 is needed for Python parser updates), hg, and svn (for the documentation
     25build).
    1026
    1127Usage: see USAGE variable in the script.
    1228"""
    13 import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd
    14 import grp
     29import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp
     30try:
     31    import urllib2 as urllib_request
     32except ImportError:
     33    import urllib.request as urllib_request
     34
     35STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
     36             | stat.S_IRGRP |                stat.S_IXGRP
     37             | stat.S_IROTH |                stat.S_IXOTH )
     38
     39STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
     40             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
     41             | stat.S_IROTH |                stat.S_IXOTH )
    1542
    1643INCLUDE_TIMESTAMP = 1
     
    1845
    1946from plistlib import Plist
    20 
    21 import MacOS
    2247
    2348try:
     
    4166            value = ln[len(variable):].strip()
    4267            return value[1:-1]
     68    raise RuntimeError("Cannot find variable %s" % variable[:-1])
     69
     70_cache_getVersion = None
    4371
    4472def getVersion():
    45     return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION')
     73    global _cache_getVersion
     74    if _cache_getVersion is None:
     75        _cache_getVersion = grepValue(
     76            os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION')
     77    return _cache_getVersion
     78
     79def getVersionTuple():
     80    return tuple([int(n) for n in getVersion().split('.')])
     81
     82def getVersionMajorMinor():
     83    return tuple([int(n) for n in getVersion().split('.', 2)])
     84
     85_cache_getFullVersion = None
    4686
    4787def getFullVersion():
     88    global _cache_getFullVersion
     89    if _cache_getFullVersion is not None:
     90        return _cache_getFullVersion
    4891    fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h')
    4992    for ln in open(fn):
    5093        if 'PY_VERSION' in ln:
    51             return ln.split()[-1][1:-1]
    52 
    53     raise RuntimeError, "Cannot find full version??"
     94            _cache_getFullVersion = ln.split()[-1][1:-1]
     95            return _cache_getFullVersion
     96    raise RuntimeError("Cannot find full version??")
    5497
    5598# The directory we'll use to create the build (will be erased and recreated)
     
    66109### The resulting binary doesn't work on all platforms that
    67110### it should. Always default to the 10.4u SDK until that
    68 ### isue is resolved.
     111### issue is resolved.
    69112###
    70113##if int(os.uname()[2].split('.')[0]) == 8:
     
    96139ARCHLIST = universal_opts_map[UNIVERSALARCHS]
    97140
    98 # Source directory (asume we're in Mac/BuildScript)
     141# Source directory (assume we're in Mac/BuildScript)
    99142SRCDIR = os.path.dirname(
    100143        os.path.dirname(
     
    107150
    108151target_cc_map = {
    109         '10.3': 'gcc-4.0',
    110         '10.4': 'gcc-4.0',
    111         '10.5': 'gcc-4.0',
    112         '10.6': 'gcc-4.2',
     152        '10.3': ('gcc-4.0', 'g++-4.0'),
     153        '10.4': ('gcc-4.0', 'g++-4.0'),
     154        '10.5': ('gcc-4.2', 'g++-4.2'),
     155        '10.6': ('gcc-4.2', 'g++-4.2'),
     156        '10.7': ('clang', 'clang++'),
     157        '10.8': ('clang', 'clang++'),
     158        '10.9': ('clang', 'clang++'),
    113159}
    114160
    115 CC = target_cc_map[DEPTARGET]
     161CC, CXX = target_cc_map[DEPTARGET]
     162
     163PYTHON_3 = getVersionTuple() >= (3, 0)
    116164
    117165USAGE = textwrap.dedent("""\
     
    129177""")% globals()
    130178
     179# Dict of object file names with shared library names to check after building.
     180# This is to ensure that we ended up dynamically linking with the shared
     181# library paths and versions we expected.  For example:
     182#   EXPECTED_SHARED_LIBS['_tkinter.so'] = [
     183#                       '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl',
     184#                       '/Library/Frameworks/Tk.framework/Versions/8.5/Tk']
     185EXPECTED_SHARED_LIBS = {}
    131186
    132187# Instructions for building libraries that are necessary for building a
     
    137192    result = []
    138193
     194    LT_10_5 = bool(DEPTARGET < '10.5')
     195
     196    if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 4)):
     197        result.extend([
     198          dict(
     199              name="Tcl 8.5.15",
     200              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz",
     201              checksum='f3df162f92c69b254079c4d0af7a690f',
     202              buildDir="unix",
     203              configure_pre=[
     204                    '--enable-shared',
     205                    '--enable-threads',
     206                    '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
     207              ],
     208              useLDFlags=False,
     209              install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
     210                  "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
     211                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
     212                  },
     213              ),
     214          dict(
     215              name="Tk 8.5.15",
     216              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz",
     217              checksum='55b8e33f903210a4e1c8bce0f820657f',
     218              patches=[
     219                  "issue19373_tk_8_5_15_source.patch",
     220                   ],
     221              buildDir="unix",
     222              configure_pre=[
     223                    '--enable-aqua',
     224                    '--enable-shared',
     225                    '--enable-threads',
     226                    '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
     227              ],
     228              useLDFlags=False,
     229              install='make TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
     230                  "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
     231                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
     232                  "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())),
     233                  },
     234                ),
     235        ])
     236
     237    if getVersionTuple() >= (3, 3):
     238        result.extend([
     239          dict(
     240              name="XZ 5.0.3",
     241              url="http://tukaani.org/xz/xz-5.0.3.tar.gz",
     242              checksum='fefe52f9ecd521de2a8ce38c21a27574',
     243              configure_pre=[
     244                    '--disable-dependency-tracking',
     245              ]
     246              ),
     247        ])
     248
     249    result.extend([
     250          dict(
     251              name="NCurses 5.9",
     252              url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz",
     253              checksum='8cb9c412e5f2d96bc6f459aa8c6282a1',
     254              configure_pre=[
     255                  "--enable-widec",
     256                  "--without-cxx",
     257                  "--without-cxx-binding",
     258                  "--without-ada",
     259                  "--without-curses-h",
     260                  "--enable-shared",
     261                  "--with-shared",
     262                  "--without-debug",
     263                  "--without-normal",
     264                  "--without-tests",
     265                  "--without-manpages",
     266                  "--datadir=/usr/share",
     267                  "--sysconfdir=/etc",
     268                  "--sharedstatedir=/usr/com",
     269                  "--with-terminfo-dirs=/usr/share/terminfo",
     270                  "--with-default-terminfo-dir=/usr/share/terminfo",
     271                  "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),),
     272              ],
     273              patchscripts=[
     274                  ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2",
     275                   "f54bf02a349f96a7c4f0d00922f3a0d4"),
     276                   ],
     277              useLDFlags=False,
     278              install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%(
     279                  shellQuote(os.path.join(WORKDIR, 'libraries')),
     280                  shellQuote(os.path.join(WORKDIR, 'libraries')),
     281                  getVersion(),
     282                  ),
     283          ),
     284          dict(
     285              name="SQLite 3.7.13",
     286              url="http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz",
     287              checksum='c97df403e8a3d5b67bb408fcd6aabd8e',
     288              extra_cflags=('-Os '
     289                            '-DSQLITE_ENABLE_FTS4 '
     290                            '-DSQLITE_ENABLE_FTS3_PARENTHESIS '
     291                            '-DSQLITE_ENABLE_RTREE '
     292                            '-DSQLITE_TCL=0 '
     293                 '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]),
     294              configure_pre=[
     295                  '--enable-threadsafe',
     296                  '--enable-shared=no',
     297                  '--enable-static=yes',
     298                  '--disable-readline',
     299                  '--disable-dependency-tracking',
     300              ]
     301          ),
     302        ])
     303
    139304    if DEPTARGET < '10.5':
    140305        result.extend([
    141306          dict(
    142               name="Bzip2 1.0.5",
    143               url="http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz",
    144               checksum='3c15a0c8d1d3ee1c46a1634d00617b1a',
     307              name="Bzip2 1.0.6",
     308              url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz",
     309              checksum='00b516f4704d4a7cb50a1d97e6e8e15b',
    145310              configure=None,
    146               install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
    147                   CC,
     311              install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
     312                  CC, CXX,
    148313                  shellQuote(os.path.join(WORKDIR, 'libraries')),
    149314                  ' -arch '.join(ARCHLIST),
     
    156321              checksum='debc62758716a169df9f62e6ab2bc634',
    157322              configure=None,
    158               install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
    159                   CC,
     323              install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
     324                  CC, CXX,
    160325                  shellQuote(os.path.join(WORKDIR, 'libraries')),
    161326                  ' -arch '.join(ARCHLIST),
     
    165330          dict(
    166331              # Note that GNU readline is GPL'd software
    167               name="GNU Readline 5.1.4",
    168               url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" ,
    169               checksum='7ee5a692db88b30ca48927a13fd60e46',
     332              name="GNU Readline 6.1.2",
     333              url="http://ftp.gnu.org/pub/gnu/readline/readline-6.1.tar.gz" ,
     334              checksum='fc2f7e714fe792db1ce6ddc4c9fb4ef3',
    170335              patchlevel='0',
    171336              patches=[
    172337                  # The readline maintainers don't do actual micro releases, but
    173338                  # just ship a set of patches.
    174                   'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001',
    175                   'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002',
    176                   'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003',
    177                   'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004',
     339                  ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001',
     340                   'c642f2e84d820884b0bf9fd176bc6c3f'),
     341                  ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002',
     342                   '1a76781a1ea734e831588285db7ec9b1'),
    178343              ]
    179344          ),
     345        ])
     346
     347    if not PYTHON_3:
     348        result.extend([
    180349          dict(
    181               name="SQLite 3.6.11",
    182               url="http://www.sqlite.org/sqlite-3.6.11.tar.gz",
    183               checksum='7ebb099696ab76cc6ff65dd496d17858',
     350              name="Sleepycat DB 4.7.25",
     351              url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
     352              checksum='ec2b87e833779681a0c3a814aa71359e',
     353              buildDir="build_unix",
     354              configure="../dist/configure",
    184355              configure_pre=[
    185                   '--enable-threadsafe',
    186                   '--enable-tempstore',
    187                   '--enable-shared=no',
    188                   '--enable-static=yes',
    189                   '--disable-tcl',
     356                  '--includedir=/usr/local/include/db4',
    190357              ]
    191358          ),
    192           dict(
    193               name="NCurses 5.5",
    194               url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz",
    195               checksum='e73c1ac10b4bfc46db43b2ddfd6244ef',
    196               configure_pre=[
    197                   "--without-cxx",
    198                   "--without-ada",
    199                   "--without-progs",
    200                   "--without-curses-h",
    201                   "--enable-shared",
    202                   "--with-shared",
    203                   "--datadir=/usr/share",
    204                   "--sysconfdir=/etc",
    205                   "--sharedstatedir=/usr/com",
    206                   "--with-terminfo-dirs=/usr/share/terminfo",
    207                   "--with-default-terminfo-dir=/usr/share/terminfo",
    208                   "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),),
    209                   "--enable-termcap",
    210               ],
    211               patches=[
    212                   "ncurses-5.5.patch",
    213               ],
    214               useLDFlags=False,
    215               install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%(
    216                   shellQuote(os.path.join(WORKDIR, 'libraries')),
    217                   shellQuote(os.path.join(WORKDIR, 'libraries')),
    218                   getVersion(),
    219                   ),
    220           ),
    221359        ])
    222 
    223     result.extend([
    224       dict(
    225           name="Sleepycat DB 4.7.25",
    226           url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
    227           checksum='ec2b87e833779681a0c3a814aa71359e',
    228           buildDir="build_unix",
    229           configure="../dist/configure",
    230           configure_pre=[
    231               '--includedir=/usr/local/include/db4',
    232           ]
    233       ),
    234     ])
    235360
    236361    return result
     
    239364# Instructions for building packages inside the .mpkg.
    240365def pkg_recipes():
     366    unselected_for_python3 = ('selected', 'unselected')[PYTHON_3]
    241367    result = [
    242368        dict(
     
    250376            """,
    251377            postflight="scripts/postflight.framework",
     378            selected='selected',
    252379        ),
    253380        dict(
     
    263390                """,
    264391            required=False,
     392            selected='selected',
    265393        ),
    266394        dict(
     
    274402                """,
    275403            required=False,
     404            selected='selected',
    276405        ),
    277406        dict(
     
    282411            readme="""\
    283412                This package installs the python documentation at a location
    284                 that is useable for pydoc and IDLE. If you have installed Xcode
    285                 it will also install a link to the documentation in
    286                 /Developer/Documentation/Python
     413                that is useable for pydoc and IDLE.
    287414                """,
    288415            postflight="scripts/postflight.documentation",
    289416            required=False,
     417            selected='selected',
    290418        ),
    291419        dict(
     
    305433            source="/empty-dir",
    306434            required=False,
     435            selected=unselected_for_python3,
    307436        ),
    308437    ]
    309438
    310     if DEPTARGET < '10.4':
     439    if DEPTARGET < '10.4' and not PYTHON_3:
    311440        result.append(
    312441            dict(
     
    322451                source="/empty-dir",
    323452                required=False,
     453                selected=unselected_for_python3,
    324454            )
    325455        )
     
    339469    Return the contents of the named file
    340470    """
    341     return open(fn, 'rb').read()
     471    return open(fn, 'r').read()
    342472
    343473def runCommand(commandline):
    344474    """
    345     Run a command and raise RuntimeError if it fails. Output is surpressed
     475    Run a command and raise RuntimeError if it fails. Output is suppressed
    346476    unless the command fails.
    347477    """
     
    351481    if xit is not None:
    352482        sys.stdout.write(data)
    353         raise RuntimeError, "command failed: %s"%(commandline,)
     483        raise RuntimeError("command failed: %s"%(commandline,))
    354484
    355485    if VERBOSE:
     
    362492    if xit is not None:
    363493        sys.stdout.write(data)
    364         raise RuntimeError, "command failed: %s"%(commandline,)
     494        raise RuntimeError("command failed: %s"%(commandline,))
    365495
    366496    return data
    367497
     498def getTclTkVersion(configfile, versionline):
     499    """
     500    search Tcl or Tk configuration file for version line
     501    """
     502    try:
     503        f = open(configfile, "r")
     504    except:
     505        fatal("Framework configuration file not found: %s" % configfile)
     506
     507    for l in f:
     508        if l.startswith(versionline):
     509            f.close()
     510            return l
     511
     512    fatal("Version variable %s not found in framework configuration file: %s"
     513            % (versionline, configfile))
     514
    368515def checkEnvironment():
    369516    """
    370517    Check that we're running on a supported system.
    371518    """
     519
     520    if sys.version_info[0:2] < (2, 4):
     521        fatal("This script must be run with Python 2.4 or later")
    372522
    373523    if platform.system() != 'Darwin':
     
    381531            os.path.basename(SDKPATH[:-4])))
    382532
     533    # Because we only support dynamic load of only one major/minor version of
     534    # Tcl/Tk, ensure:
     535    # 1. there are no user-installed frameworks of Tcl/Tk with version
     536    #       higher than the Apple-supplied system version in
     537    #       SDKROOT/System/Library/Frameworks
     538    # 2. there is a user-installed framework (usually ActiveTcl) in (or linked
     539    #       in) SDKROOT/Library/Frameworks with the same version as the system
     540    #       version. This allows users to choose to install a newer patch level.
     541
     542    frameworks = {}
     543    for framework in ['Tcl', 'Tk']:
     544        fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
     545        sysfw = os.path.join(SDKPATH, 'System', fwpth)
     546        libfw = os.path.join(SDKPATH, fwpth)
     547        usrfw = os.path.join(os.getenv('HOME'), fwpth)
     548        frameworks[framework] = os.readlink(sysfw)
     549        if not os.path.exists(libfw):
     550            fatal("Please install a link to a current %s %s as %s so "
     551                    "the user can override the system framework."
     552                    % (framework, frameworks[framework], libfw))
     553        if os.readlink(libfw) != os.readlink(sysfw):
     554            fatal("Version of %s must match %s" % (libfw, sysfw) )
     555        if os.path.exists(usrfw):
     556            fatal("Please rename %s to avoid possible dynamic load issues."
     557                    % usrfw)
     558
     559    if frameworks['Tcl'] != frameworks['Tk']:
     560        fatal("The Tcl and Tk frameworks are not the same version.")
     561
     562    # add files to check after build
     563    EXPECTED_SHARED_LIBS['_tkinter.so'] = [
     564            "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
     565                % frameworks['Tcl'],
     566            "/Library/Frameworks/Tk.framework/Versions/%s/Tk"
     567                % frameworks['Tk'],
     568            ]
     569
     570    # For 10.6+ builds, we build two versions of _tkinter:
     571    #    - the traditional version (renamed to _tkinter_library.so) linked
     572    #       with /Library/Frameworks/{Tcl,Tk}.framework
     573    #    - the default version linked with our builtin copies of Tcl and Tk
     574    if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 4)):
     575        EXPECTED_SHARED_LIBS['_tkinter_library.so'] = \
     576            EXPECTED_SHARED_LIBS['_tkinter.so']
     577        EXPECTED_SHARED_LIBS['_tkinter.so'] = [
     578                "/Library/Frameworks/Python.framework/Versions/%s/lib/libtcl%s.dylib"
     579                    % (getVersion(), frameworks['Tcl']),
     580                "/Library/Frameworks/Python.framework/Versions/%s/lib/libtk%s.dylib"
     581                    % (getVersion(), frameworks['Tk']),
     582                ]
     583
     584    # Remove inherited environment variables which might influence build
     585    environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
     586                            'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
     587    for ev in list(os.environ):
     588        for prefix in environ_var_prefixes:
     589            if ev.startswith(prefix) :
     590                print("INFO: deleting environment variable %s=%s" % (
     591                                                    ev, os.environ[ev]))
     592                del os.environ[ev]
     593
     594    base_path = '/bin:/sbin:/usr/bin:/usr/sbin'
     595    if 'SDK_TOOLS_BIN' in os.environ:
     596        base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path
     597    # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin;
     598    # add its fixed location here if it exists
     599    OLD_DEVELOPER_TOOLS = '/Developer/Tools'
     600    if os.path.isdir(OLD_DEVELOPER_TOOLS):
     601        base_path = base_path + ':' + OLD_DEVELOPER_TOOLS
     602    os.environ['PATH'] = base_path
     603    print("Setting default PATH: %s"%(os.environ['PATH']))
    383604
    384605
     
    388609    """
    389610    global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET
    390     global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC
     611    global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX
    391612
    392613    if args is None:
     
    397618                [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=',
    398619                  'dep-target=', 'universal-archs=', 'help' ])
    399     except getopt.error, msg:
    400         print msg
     620    except getopt.GetoptError:
     621        print(sys.exc_info()[1])
    401622        sys.exit(1)
    402623
    403624    if args:
    404         print "Additional arguments"
     625        print("Additional arguments")
    405626        sys.exit(1)
    406627
     
    408629    for k, v in options:
    409630        if k in ('-h', '-?', '--help'):
    410             print USAGE
     631            print(USAGE)
    411632            sys.exit(0)
    412633
     
    436657                    DEPTARGET = default_target_map.get(v, '10.3')
    437658            else:
    438                 raise NotImplementedError, v
     659                raise NotImplementedError(v)
    439660
    440661        else:
    441             raise NotImplementedError, k
     662            raise NotImplementedError(k)
    442663
    443664    SRCDIR=os.path.abspath(SRCDIR)
     
    446667    DEPSRC=os.path.abspath(DEPSRC)
    447668
    448     CC=target_cc_map[DEPTARGET]
    449 
    450     print "Settings:"
    451     print " * Source directory:", SRCDIR
    452     print " * Build directory: ", WORKDIR
    453     print " * SDK location:    ", SDKPATH
    454     print " * Third-party source:", DEPSRC
    455     print " * Deployment target:", DEPTARGET
    456     print " * Universal architectures:", ARCHLIST
    457     print " * C compiler:", CC
    458     print ""
     669    CC, CXX=target_cc_map[DEPTARGET]
     670
     671    print("Settings:")
     672    print(" * Source directory:", SRCDIR)
     673    print(" * Build directory: ", WORKDIR)
     674    print(" * SDK location:    ", SDKPATH)
     675    print(" * Third-party source:", DEPSRC)
     676    print(" * Deployment target:", DEPTARGET)
     677    print(" * Universal architectures:", ARCHLIST)
     678    print(" * C compiler:", CC)
     679    print(" * C++ compiler:", CXX)
     680    print("")
    459681
    460682
     
    468690    XXX: This function assumes that archives contain a toplevel directory
    469691    that is has the same name as the basename of the archive. This is
    470     save enough for anything we use.
     692    safe enough for almost anything we use.  Unfortunately, it does not
     693    work for current Tcl and Tk source releases where the basename of
     694    the archive ends with "-src" but the uncompressed directory does not.
     695    For now, just special case Tcl and Tk tar.gz downloads.
    471696    """
    472697    curdir = os.getcwd()
     
    475700        if archiveName.endswith('.tar.gz'):
    476701            retval = os.path.basename(archiveName[:-7])
     702            if ((retval.startswith('tcl') or retval.startswith('tk'))
     703                    and retval.endswith('-src')):
     704                retval = retval[:-4]
    477705            if os.path.exists(retval):
    478706                shutil.rmtree(retval)
     
    501729        if xit is not None:
    502730            sys.stdout.write(data)
    503             raise RuntimeError, "Cannot extract %s"%(archiveName,)
     731            raise RuntimeError("Cannot extract %s"%(archiveName,))
    504732
    505733        return os.path.join(builddir, retval)
     
    508736        os.chdir(curdir)
    509737
    510 KNOWNSIZES = {
    511     "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742,
    512     "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276,
    513 }
    514 
    515738def downloadURL(url, fname):
    516739    """
    517740    Download the contents of the url into the file.
    518741    """
    519     try:
    520         size = os.path.getsize(fname)
    521     except OSError:
    522         pass
    523     else:
    524         if KNOWNSIZES.get(url) == size:
    525             print "Using existing file for", url
    526             return
    527     fpIn = urllib2.urlopen(url)
     742    fpIn = urllib_request.urlopen(url)
    528743    fpOut = open(fname, 'wb')
    529744    block = fpIn.read(10240)
     
    540755            pass
    541756
     757def verifyThirdPartyFile(url, checksum, fname):
     758    """
     759    Download file from url to filename fname if it does not already exist.
     760    Abort if file contents does not match supplied md5 checksum.
     761    """
     762    name = os.path.basename(fname)
     763    if os.path.exists(fname):
     764        print("Using local copy of %s"%(name,))
     765    else:
     766        print("Did not find local copy of %s"%(name,))
     767        print("Downloading %s"%(name,))
     768        downloadURL(url, fname)
     769        print("Archive for %s stored as %s"%(name, fname))
     770    if os.system(
     771            'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"'
     772                % (shellQuote(fname), checksum) ):
     773        fatal('MD5 checksum mismatch for file %s' % fname)
     774
    542775def buildRecipe(recipe, basedir, archList):
    543776    """
     
    560793        os.mkdir(DEPSRC)
    561794
    562 
    563     if os.path.exists(sourceArchive):
    564         print "Using local copy of %s"%(name,)
    565 
    566     else:
    567         print "Did not find local copy of %s"%(name,)
    568         print "Downloading %s"%(name,)
    569         downloadURL(url, sourceArchive)
    570         print "Archive for %s stored as %s"%(name, sourceArchive)
    571 
    572     print "Extracting archive for %s"%(name,)
     795    verifyThirdPartyFile(url, recipe['checksum'], sourceArchive)
     796    print("Extracting archive for %s"%(name,))
    573797    buildDir=os.path.join(WORKDIR, '_bld')
    574798    if not os.path.exists(buildDir):
     
    577801    workDir = extractArchive(buildDir, sourceArchive)
    578802    os.chdir(workDir)
     803
     804    for patch in recipe.get('patches', ()):
     805        if isinstance(patch, tuple):
     806            url, checksum = patch
     807            fn = os.path.join(DEPSRC, os.path.basename(url))
     808            verifyThirdPartyFile(url, checksum, fn)
     809        else:
     810            # patch is a file in the source directory
     811            fn = os.path.join(curdir, patch)
     812        runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
     813            shellQuote(fn),))
     814
     815    for patchscript in recipe.get('patchscripts', ()):
     816        if isinstance(patchscript, tuple):
     817            url, checksum = patchscript
     818            fn = os.path.join(DEPSRC, os.path.basename(url))
     819            verifyThirdPartyFile(url, checksum, fn)
     820        else:
     821            # patch is a file in the source directory
     822            fn = os.path.join(curdir, patchscript)
     823        if fn.endswith('.bz2'):
     824            runCommand('bunzip2 -fk %s' % shellQuote(fn))
     825            fn = fn[:-4]
     826        runCommand('sh %s' % shellQuote(fn))
     827        os.unlink(fn)
     828
    579829    if 'buildDir' in recipe:
    580830        os.chdir(recipe['buildDir'])
    581 
    582 
    583     for fn in recipe.get('patches', ()):
    584         if fn.startswith('http://'):
    585             # Download the patch before applying it.
    586             path = os.path.join(DEPSRC, os.path.basename(fn))
    587             downloadURL(fn, path)
    588             fn = path
    589 
    590         fn = os.path.join(curdir, fn)
    591         runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
    592             shellQuote(fn),))
    593831
    594832    if configure is not None:
     
    610848        if recipe.get('useLDFlags', 1):
    611849            configure_args.extend([
    612                 "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
     850                "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
     851                            "-I%s/usr/local/include"%(
     852                        recipe.get('extra_cflags', ''),
     853                        DEPTARGET,
    613854                        ' -arch '.join(archList),
    614855                        shellQuote(SDKPATH)[1:-1],
    615856                        shellQuote(basedir)[1:-1],),
    616                 "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
     857                "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%(
     858                    DEPTARGET,
    617859                    shellQuote(SDKPATH)[1:-1],
    618860                    shellQuote(basedir)[1:-1],
     
    621863        else:
    622864            configure_args.extend([
    623                 "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
     865                "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
     866                            "-I%s/usr/local/include"%(
     867                        recipe.get('extra_cflags', ''),
     868                        DEPTARGET,
    624869                        ' -arch '.join(archList),
    625870                        shellQuote(SDKPATH)[1:-1],
     
    628873
    629874        if 'configure_post' in recipe:
    630             configure_args = configure_args = list(recipe['configure_post'])
     875            configure_args = configure_args + list(recipe['configure_post'])
    631876
    632877        configure_args.insert(0, configure)
    633878        configure_args = [ shellQuote(a) for a in configure_args ]
    634879
    635         print "Running configure for %s"%(name,)
     880        print("Running configure for %s"%(name,))
    636881        runCommand(' '.join(configure_args) + ' 2>&1')
    637882
    638     print "Running install for %s"%(name,)
     883    print("Running install for %s"%(name,))
    639884    runCommand('{ ' + install + ' ;} 2>&1')
    640885
    641     print "Done %s"%(name,)
    642     print ""
     886    print("Done %s"%(name,))
     887    print("")
    643888
    644889    os.chdir(curdir)
     
    648893    Build our dependencies into $WORKDIR/libraries/usr/local
    649894    """
    650     print ""
    651     print "Building required libraries"
    652     print ""
     895    print("")
     896    print("Building required libraries")
     897    print("")
    653898    universal = os.path.join(WORKDIR, 'libraries')
    654899    os.mkdir(universal)
     
    664909    # This stores the documentation as Resources/English.lproj/Documentation
    665910    # inside the framwork. pydoc and IDLE will pick it up there.
    666     print "Install python documentation"
     911    print("Install python documentation")
    667912    rootDir = os.path.join(WORKDIR, '_root')
    668913    buildDir = os.path.join('../../Doc')
     
    671916    os.chdir(buildDir)
    672917    runCommand('make update')
    673     runCommand('make html')
     918    runCommand("make html PYTHON='%s'" % os.path.abspath(sys.executable))
    674919    os.chdir(curDir)
    675920    if not os.path.exists(docdir):
     
    679924
    680925def buildPython():
    681     print "Building a universal python for %s architectures" % UNIVERSALARCHS
     926    print("Building a universal python for %s architectures" % UNIVERSALARCHS)
    682927
    683928    buildDir = os.path.join(WORKDIR, '_bld', 'python')
     
    688933    if os.path.exists(rootDir):
    689934        shutil.rmtree(rootDir)
    690     os.mkdir(buildDir)
    691     os.mkdir(rootDir)
    692     os.mkdir(os.path.join(rootDir, 'empty-dir'))
     935    os.makedirs(buildDir)
     936    os.makedirs(rootDir)
     937    os.makedirs(os.path.join(rootDir, 'empty-dir'))
    693938    curdir = os.getcwd()
    694939    os.chdir(buildDir)
     
    707952    os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR,
    708953                                        'libraries', 'usr', 'local', 'lib')
    709     print "Running configure..."
     954    print("Running configure...")
    710955    runCommand("%s -C --enable-framework --enable-universalsdk=%s "
    711956               "--with-universal-archs=%s "
     957               "%s "
    712958               "LDFLAGS='-g -L%s/libraries/usr/local/lib' "
    713                "OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%(
     959               "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%(
    714960        shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH),
    715961        UNIVERSALARCHS,
     962        (' ', '--with-computed-gotos ')[PYTHON_3],
    716963        shellQuote(WORKDIR)[1:-1],
    717964        shellQuote(WORKDIR)[1:-1]))
    718965
    719     print "Running make"
     966    print("Running make")
    720967    runCommand("make")
    721968
    722     print "Running make frameworkinstall"
    723     runCommand("make frameworkinstall DESTDIR=%s"%(
     969    # For deployment targets of 10.6 and higher, we build our own version
     970    # of Tcl and Cocoa Aqua Tk libs because the Apple-supplied Tk 8.5 is
     971    # out-of-date and has critical bugs.  Save the _tkinter.so that was
     972    # linked with /Library/Frameworks/{Tck,Tk}.framework and build
     973    # another _tkinter.so linked with our builtin Tcl and Tk libs.
     974    if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 4)):
     975        runCommand("find build -name '_tkinter.so' "
     976                        " -execdir mv '{}' _tkinter_library.so \;")
     977        print("Running make to build builtin _tkinter")
     978        runCommand("make TCLTK_INCLUDES='-I%s/libraries/usr/local/include' "
     979                "TCLTK_LIBS='-L%s/libraries/usr/local/lib -ltcl8.5 -ltk8.5'"%(
     980            shellQuote(WORKDIR)[1:-1],
     981            shellQuote(WORKDIR)[1:-1]))
     982        # make a copy which will be moved to lib-tkinter later
     983        runCommand("find build -name '_tkinter.so' "
     984                        " -execdir cp -p '{}' _tkinter_builtin.so \;")
     985
     986    print("Running make install")
     987    runCommand("make install DESTDIR=%s"%(
    724988        shellQuote(rootDir)))
    725989
    726     print "Running make frameworkinstallextras"
     990    print("Running make frameworkinstallextras")
    727991    runCommand("make frameworkinstallextras DESTDIR=%s"%(
    728992        shellQuote(rootDir)))
    729993
    730994    del os.environ['DYLD_LIBRARY_PATH']
    731     print "Copying required shared libraries"
     995    print("Copying required shared libraries")
    732996    if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
    733997        runCommand("mv %s/* %s"%(
     
    7401004                'lib'))))
    7411005
    742     print "Fix file modes"
     1006    path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks',
     1007                                'Python.framework', 'Versions',
     1008                                version, 'lib', 'python%s'%(version,))
     1009
     1010    # If we made multiple versions of _tkinter, move them to
     1011    # their own directories under python lib.  This allows
     1012    # users to select which to import by manipulating sys.path
     1013    # directly or with PYTHONPATH.
     1014
     1015    if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 4)):
     1016        TKINTERS = ['builtin', 'library']
     1017        tkinter_moves = [('_tkinter_' + tkn + '.so',
     1018                             os.path.join(path_to_lib, 'lib-tkinter', tkn))
     1019                         for tkn in TKINTERS]
     1020        # Create the destination directories under lib-tkinter.
     1021        # The permissions and uid/gid will be fixed up next.
     1022        for tkm in tkinter_moves:
     1023            os.makedirs(tkm[1])
     1024
     1025    print("Fix file modes")
    7431026    frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
    7441027    gid = grp.getgrnam('admin').gr_gid
    7451028
     1029    shared_lib_error = False
     1030    moves_list = []
    7461031    for dirpath, dirnames, filenames in os.walk(frmDir):
    7471032        for dn in dirnames:
    748             os.chmod(os.path.join(dirpath, dn), 0775)
     1033            os.chmod(os.path.join(dirpath, dn), STAT_0o775)
    7491034            os.chown(os.path.join(dirpath, dn), -1, gid)
    750 
    7511035
    7521036        for fn in filenames:
     
    7601044            os.chown(p, -1, gid)
    7611045
     1046            if fn in EXPECTED_SHARED_LIBS:
     1047                # check to see that this file was linked with the
     1048                # expected library path and version
     1049                data = captureCommand("otool -L %s" % shellQuote(p))
     1050                for sl in EXPECTED_SHARED_LIBS[fn]:
     1051                    if ("\t%s " % sl) not in data:
     1052                        print("Expected shared lib %s was not linked with %s"
     1053                                % (sl, p))
     1054                        shared_lib_error = True
     1055
     1056            # If this is a _tkinter variant, move it to its own directory
     1057            # now that we have fixed its permissions and checked that it
     1058            # was linked properly.  The directory was created earlier.
     1059            # The files are moved after the entire tree has been walked
     1060            # since the shared library checking depends on the files
     1061            # having unique names.
     1062            if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 4)):
     1063                for tkm in tkinter_moves:
     1064                    if fn == tkm[0]:
     1065                        moves_list.append(
     1066                            (p, os.path.join(tkm[1], '_tkinter.so')))
     1067
     1068    if shared_lib_error:
     1069        fatal("Unexpected shared library errors.")
     1070
     1071    # Now do the moves.
     1072    for ml in moves_list:
     1073        shutil.move(ml[0], ml[1])
     1074
     1075    if PYTHON_3:
     1076        LDVERSION=None
     1077        VERSION=None
     1078        ABIFLAGS=None
     1079
     1080        fp = open(os.path.join(buildDir, 'Makefile'), 'r')
     1081        for ln in fp:
     1082            if ln.startswith('VERSION='):
     1083                VERSION=ln.split()[1]
     1084            if ln.startswith('ABIFLAGS='):
     1085                ABIFLAGS=ln.split()[1]
     1086            if ln.startswith('LDVERSION='):
     1087                LDVERSION=ln.split()[1]
     1088        fp.close()
     1089
     1090        LDVERSION = LDVERSION.replace('$(VERSION)', VERSION)
     1091        LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS)
     1092        config_suffix = '-' + LDVERSION
     1093    else:
     1094        config_suffix = ''      # Python 2.x
     1095
    7621096    # We added some directories to the search path during the configure
    7631097    # phase. Remove those because those directories won't be there on
    764     # the end-users system.
    765     path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework',
    766                 'Versions', version, 'lib', 'python%s'%(version,),
    767                 'config', 'Makefile')
     1098    # the end-users system. Also remove the directories from _sysconfigdata.py
     1099    # (added in 3.3) if it exists.
     1100
     1101    include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,)
     1102    lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,)
     1103
     1104    # fix Makefile
     1105    path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile')
    7681106    fp = open(path, 'r')
    7691107    data = fp.read()
    7701108    fp.close()
    7711109
    772     data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '')
    773     data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '')
     1110    for p in (include_path, lib_path):
     1111        data = data.replace(" " + p, '')
     1112        data = data.replace(p + " ", '')
     1113
    7741114    fp = open(path, 'w')
    7751115    fp.write(data)
    7761116    fp.close()
     1117
     1118    # fix _sysconfigdata if it exists
     1119    #
     1120    # TODO: make this more robust!  test_sysconfig_module of
     1121    # distutils.tests.test_sysconfig.SysconfigTestCase tests that
     1122    # the output from get_config_var in both sysconfig and
     1123    # distutils.sysconfig is exactly the same for both CFLAGS and
     1124    # LDFLAGS.  The fixing up is now complicated by the pretty
     1125    # printing in _sysconfigdata.py.  Also, we are using the
     1126    # pprint from the Python running the installer build which
     1127    # may not cosmetically format the same as the pprint in the Python
     1128    # being built (and which is used to originally generate
     1129    # _sysconfigdata.py).
     1130
     1131    import pprint
     1132    path = os.path.join(path_to_lib, '_sysconfigdata.py')
     1133    if os.path.exists(path):
     1134        fp = open(path, 'r')
     1135        data = fp.read()
     1136        fp.close()
     1137        # create build_time_vars dict
     1138        exec(data)
     1139        vars = {}
     1140        for k, v in build_time_vars.items():
     1141            if type(v) == type(''):
     1142                for p in (include_path, lib_path):
     1143                    v = v.replace(' ' + p, '')
     1144                    v = v.replace(p + ' ', '')
     1145            vars[k] = v
     1146
     1147        fp = open(path, 'w')
     1148        # duplicated from sysconfig._generate_posix_vars()
     1149        fp.write('# system configuration generated and used by'
     1150                    ' the sysconfig module\n')
     1151        fp.write('build_time_vars = ')
     1152        pprint.pprint(vars, stream=fp)
     1153        fp.close()
    7771154
    7781155    # Add symlinks in /usr/local/bin, using relative links
     
    7901167    os.chdir(curdir)
    7911168
    792 
     1169    if PYTHON_3:
     1170        # Remove the 'Current' link, that way we don't accidentally mess
     1171        # with an already installed version of python 2
     1172        os.unlink(os.path.join(rootDir, 'Library', 'Frameworks',
     1173                            'Python.framework', 'Versions', 'Current'))
    7931174
    7941175def patchFile(inPath, outPath):
     
    7971178    data = data.replace('$VERSION', getVersion())
    7981179    data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later')))
    799     data = data.replace('$ARCHITECTURES', "i386, ppc")
     1180    data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSALARCHS]))
    8001181    data = data.replace('$INSTALL_SIZE', installSize())
    8011182
    8021183    # This one is not handy as a template variable
    8031184    data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework')
    804     fp = open(outPath, 'wb')
     1185    fp = open(outPath, 'w')
    8051186    fp.write(data)
    8061187    fp.close()
     
    8091190    data = fileContents(inPath)
    8101191    data = data.replace('@PYVER@', getVersion())
    811     fp = open(outPath, 'wb')
     1192    fp = open(outPath, 'w')
    8121193    fp.write(data)
    8131194    fp.close()
    814     os.chmod(outPath, 0755)
     1195    os.chmod(outPath, STAT_0o755)
    8151196
    8161197
     
    8291210        isRequired = recipe.get('required', True)
    8301211
    831         print "- building package %s"%(pkgname,)
     1212        print("- building package %s"%(pkgname,))
    8321213
    8331214        # Substitute some variables
     
    8741255
    8751256        vers = getFullVersion()
    876         major, minor = map(int, getVersion().split('.', 2))
     1257        major, minor = getVersionMajorMinor()
    8771258        pl = Plist(
    8781259                CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,),
     
    9111292
    9121293    vers = getFullVersion()
    913     major, minor = map(int, getVersion().split('.', 2))
     1294    major, minor = getVersionMajorMinor()
    9141295
    9151296    pl = Plist(
     
    9241305                dict(
    9251306                    IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
    926                     IFPkgFlagPackageSelection='selected'
     1307                    IFPkgFlagPackageSelection=item.get('selected', 'selected'),
    9271308                )
    9281309                for item in pkg_recipes()
     
    10221403    shutil.copy("../Icons/Disk Image.icns",
    10231404            os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns"))
    1024     runCommand("/Developer/Tools/SetFile -a C %s/"%(
     1405    runCommand("SetFile -a C %s/"%(
    10251406            shellQuote(os.path.join(WORKDIR, "mnt", volname)),))
    10261407
     
    10421423    """
    10431424
    1044     toolPath = os.path.join(os.path.dirname(__file__), "seticon.app/Contents/MacOS/seticon")
    1045     dirPath = os.path.dirname(__file__)
     1425    dirPath = os.path.normpath(os.path.dirname(__file__))
     1426    toolPath = os.path.join(dirPath, "seticon.app/Contents/MacOS/seticon")
    10461427    if not os.path.exists(toolPath) or os.stat(toolPath).st_mtime < os.stat(dirPath + '/seticon.m').st_mtime:
    10471428        # NOTE: The tool is created inside an .app bundle, otherwise it won't work due
    10481429        # to connections to the window server.
    1049         if not os.path.exists('seticon.app/Contents/MacOS'):
    1050             os.makedirs('seticon.app/Contents/MacOS')
     1430        appPath = os.path.join(dirPath, "seticon.app/Contents/MacOS")
     1431        if not os.path.exists(appPath):
     1432            os.makedirs(appPath)
    10511433        runCommand("cc -o %s %s/seticon.m -framework Cocoa"%(
    10521434            shellQuote(toolPath), shellQuote(dirPath)))
     
    10621444    os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET
    10631445    os.environ['CC'] = CC
     1446    os.environ['CXX'] = CXX
    10641447
    10651448    if os.path.exists(WORKDIR):
    10661449        shutil.rmtree(WORKDIR)
    10671450    os.mkdir(WORKDIR)
     1451
     1452    os.environ['LC_ALL'] = 'C'
    10681453
    10691454    # Then build third-party libraries such as sleepycat DB4.
     
    10901475    folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%(
    10911476        getVersion(),))
    1092     os.chmod(folder, 0755)
     1477    os.chmod(folder, STAT_0o755)
    10931478    setIcon(folder, "../Icons/Python Folder.icns")
    10941479
     
    11031488
    11041489    fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
    1105     print >> fp, "# BUILD INFO"
    1106     print >> fp, "# Date:", time.ctime()
    1107     print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos
     1490    fp.write("# BUILD INFO\n")
     1491    fp.write("# Date: %s\n" % time.ctime())
     1492    fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos)
    11081493    fp.close()
    11091494
  • python/vendor/current/Mac/BuildScript/resources/ReadMe.txt

    r2 r388  
    1 This package will install MacPython $FULL_VERSION for Mac OS X
    2 $MACOSX_DEPLOYMENT_TARGET for the following
    3 architecture(s): $ARCHITECTURES.
     1This package will install Python $FULL_VERSION for Mac OS X
     2$MACOSX_DEPLOYMENT_TARGET for the following architecture(s):
     3$ARCHITECTURES.
    44
    5 Separate installers are available for older versions
    6 of Mac OS X, see the homepage, below.
     5               **** IMPORTANT ****
    76
    8 Installation requires approximately $INSTALL_SIZE MB of disk
    9 space, ignore the message that it will take zero bytes.
     7Installing on OS X 10.8 (Mountain Lion) or later systems
     8========================================================
    109
    11 You must install onto your current boot disk, even
    12 though the installer does not enforce this, otherwise
    13 things will not work.
     10If you are attempting to install on an OS X 10.8+ system, you may
     11see a message that Python can't be installed because it is from an
     12unidentified developer.  This is because this Python installer
     13package is not yet compatible with the Gatekeeper security feature
     14introduced in OS X 10.8.  To allow Python to be installed, you
     15can override the Gatekeeper policy for this install.  In the Finder,
     16instead of double-clicking, control-click or right click the "Python"
     17installer package icon.  Then select "Open using ... Installer" from
     18the contextual menu that appears.
    1419
    15 MacPython consists of the Python programming language
    16 interpreter, plus a set of programs to allow easy
    17 access to it for Mac users including an integrated development
    18 environment, IDLE, plus a set of pre-built extension modules
    19 that open up specific Macintosh technologies to Python programs.
     20               **** IMPORTANT ****
    2021
    21 The installer puts the applications in "Python $VERSION"
    22 in your Applications folder, command-line tools in
    23 /usr/local/bin and the underlying machinery in
    24 $PYTHONFRAMEWORKINSTALLDIR.
     22Update your version of Tcl/Tk to use IDLE or other Tk applications
     23==================================================================
    2524
    26 More information on MacPython can be found at
    27 http://www.python.org/download/mac/.
     25To use IDLE or other programs that use the Tkinter graphical user
     26interface toolkit, you may need to install a newer third-party version
     27of the Tcl/Tk frameworks.  Visit http://www.python.org/download/mac/tcltk/
     28for current information about supported and recommended versions of
     29Tcl/Tk for this version of Python and of Mac OS X.
     30
     31
     32Using this version of Python on OS X
     33====================================
     34
     35Python consists of the Python programming language interpreter, plus
     36a set of programs to allow easy access to it for Mac users including
     37an integrated development environment, IDLE, plus a set of pre-built
     38extension modules that open up specific Macintosh technologies to
     39Python programs.
     40
     41The installer puts applications, an "Update Shell Profile" command,
     42and a link to the optionally installed Python Documentation into the
     43"Python $VERSION" subfolder of the system Applications folder,
     44and puts the underlying machinery into the folder
     45$PYTHONFRAMEWORKINSTALLDIR. It can
     46optionally place links to the command-line tools in /usr/local/bin as
     47well. Double-click on the "Update Shell Profile" command to add the
     48"bin" directory inside the framework to your shell's search path.
     49
     50You must install onto your current boot disk, even though the
     51installer may not enforce this, otherwise things will not work.
     52
     53You can verify the integrity of the disk image file containing the
     54installer package and this ReadMe file by comparing its md5 checksum
     55and size with the values published on the release page linked at
     56http://www.python.org/download/
     57
     58Installation requires approximately $INSTALL_SIZE MB of disk space,
     59ignore the message that it will take zero bytes.
    2860
    2961More information on Python in general can be found at
  • python/vendor/current/Mac/BuildScript/scripts/postflight.documentation

    r2 r388  
    22
    33PYVER="@PYVER@"
     4FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}"
     5FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation"
     6FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}"
     7APPDIR="/Applications/Python ${PYVER}"
     8SHARE_DIR="${FWK}/share"
     9SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}"
     10SHARE_DOCDIR_TO_FWK="../../.."
    411
    5 if [ -d /Developer/Documentation ]; then
    6         if [ ! -d /Developer/Documentation/Python ]; then
    7                 mkdir -p /Developer/Documentation/Python
    8         fi
     12# make link in /Applications/Python m.n/ for Finder users
     13if [ -d "${APPDIR}" ]; then
     14    ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html"
     15fi
    916
    10         ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation @PYVER@"
     17# make share/doc link in framework for command line users
     18if [ -d "${SHARE_DIR}" ]; then
     19    mkdir -m 775 -p "${SHARE_DOCDIR}"
     20    # make relative link to html doc directory
     21    ln -fhs "${SHARE_DOCDIR_TO_FWK}/${FWK_DOCDIR_SUBPATH}" "${SHARE_DOCDIR}/html"
    1122fi
     23
  • python/vendor/current/Mac/BuildScript/scripts/postflight.framework

    r2 r388  
    99"${FWK}/bin/python@PYVER@" -Wi -tt \
    1010    "${FWK}/lib/python${PYVER}/compileall.py" \
    11     -x badsyntax -x site-packages \
     11    -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
    1212    "${FWK}/lib/python${PYVER}"
    1313
    1414"${FWK}/bin/python@PYVER@" -Wi -tt -O \
    1515    "${FWK}/lib/python${PYVER}/compileall.py" \
    16     -x badsyntax -x site-packages \
     16    -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
    1717    "${FWK}/lib/python${PYVER}"
     18
     19"${FWK}/bin/python@PYVER@" -Wi \
     20    "${FWK}/lib/python${PYVER}/compileall.py" \
     21    -f -x badsyntax \
     22    "${FWK}/lib/python${PYVER}/site-packages"
     23
     24"${FWK}/bin/python@PYVER@" -Wi -O \
     25    "${FWK}/lib/python${PYVER}/compileall.py" \
     26    -f -x badsyntax \
     27    "${FWK}/lib/python${PYVER}/site-packages"
    1828
    1929chgrp -R admin "${FWK}"
  • python/vendor/current/Mac/BuildScript/scripts/postflight.patch-profile

    r2 r388  
    2121BSH="`basename "${theShell}"`"
    2222case "${BSH}" in
    23 bash|ksh|sh|*csh)
     23bash|ksh|sh|*csh|zsh)
    2424        if [ `id -ur` = 0 ]; then
    2525                P=`su - ${USER} -c 'echo A-X-4-X@@$PATH@@X-4-X-A' | grep 'A-X-4-X@@.*@@X-4-X-A' | sed -e 's/^A-X-4-X@@//g' -e 's/@@X-4-X-A$//g'`
     
    5858        fi
    5959        echo "" >> "${RC}"
    60         echo "# Setting PATH for MacPython ${PYVER}" >> "${RC}"
     60        echo "# Setting PATH for Python ${PYVER}" >> "${RC}"
    6161        echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}"
    6262        echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}"
     
    7777        fi
    7878        ;;
     79zsh)
     80        PR="${HOME}/.zprofile"
     81        ;;
    7982*sh)
    8083        PR="${HOME}/.profile"
     
    8790fi
    8891echo "" >> "${PR}"
    89 echo "# Setting PATH for MacPython ${PYVER}" >> "${PR}"
     92echo "# Setting PATH for Python ${PYVER}" >> "${PR}"
    9093echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}"
    9194echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}"
Note: See TracChangeset for help on using the changeset viewer.