summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
Diffstat (limited to 'Mac')
-rw-r--r--Mac/BuildScript/README.txt157
-rwxr-xr-xMac/BuildScript/build-installer.py126
-rw-r--r--Mac/BuildScript/resources/ReadMe.txt47
-rw-r--r--Mac/BuildScript/resources/Welcome.rtf28
-rwxr-xr-xMac/BuildScript/scripts/postflight.documentation31
-rw-r--r--Mac/Extras.ReadMe.txt5
-rw-r--r--Mac/Makefile.in108
-rw-r--r--Mac/PythonLauncher/Makefile.in2
-rw-r--r--Mac/README93
-rw-r--r--Mac/Tools/pythonw.c173
10 files changed, 512 insertions, 258 deletions
diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt
index 0f1aeb5..de2f5cb 100644
--- a/Mac/BuildScript/README.txt
+++ b/Mac/BuildScript/README.txt
@@ -1,78 +1,147 @@
-Building a MacPython distribution
-=================================
+Building a Python Mac OS X distribution
+=======================================
-The ``build-install.py`` script creates MacPython distributions, including
-sleepycat db4, sqlite3 and readline support. It builds a complete
+The ``build-install.py`` script creates Python distributions, including
+certain third-party libraries as necessary. It builds a complete
framework-based Python out-of-tree, installs it in a funny place with
$DESTROOT, massages that installation to remove .pyc files and such, creates
an Installer package from the installation plus other files in ``resources``
and ``scripts`` and placed that on a ``.dmg`` disk image.
-Prerequisites
--------------
+As of Python 2.7.x and 3.2, PSF practice is to build two installer variants
+for each release:
-* A MacOS X 10.4 (or later)
+1. 32-bit-only, i386 and PPC universal, capable on running on all machines
+ supported by Mac OS X 10.3.9 through (at least) 10.6::
-* XCode 2.2 (or later), with the universal SDK
+ python build-installer.py \
+ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
+ --universal-archs=32-bit \
+ --dep-target=10.3
+ # These are the current default options
-* No Fink (in ``/sw``) or DarwinPorts (in ``/opt/local``), those could
+ - builds the following third-party libraries
+
+ * Bzip2
+ * Zlib 1.2.3
+ * GNU Readline (GPL)
+ * SQLite 3
+ * NCurses
+ * Oracle Sleepycat DB 4.8 (Python 2.x only)
+
+ - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
+
+ - current target build environment:
+
+ * Mac OS X 10.5.8 PPC or Intel
+ * Xcode 3.1.4 (or later)
+ * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
+ * ``MACOSX_DEPLOYMENT_TARGET=10.3``
+ * Apple ``gcc-4.0``
+ * Python 2.n (n >= 4) for documentation build with Sphinx
+
+ - alternate build environments:
+
+ * Mac OS X 10.4.11 with Xcode 2.5
+ * Mac OS X 10.6.6 with Xcode 3.2.5
+ - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
+
+2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
+
+ python build-installer.py \
+ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
+ --universal-archs=intel \
+ --dep-target=10.6
+
+ - uses system-supplied versions of third-party libraries
+
+ * readline module links with Apple BSD editline (libedit)
+ * builds Oracle Sleepycat DB 4.8 (Python 2.x only)
+
+ - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building
+
+ - current target build environment:
+
+ * Mac OS X 10.6.6 (or later)
+ * Xcode 3.2.5 (or later)
+ * ``MacOSX10.6`` SDK
+ * ``MACOSX_DEPLOYMENT_TARGET=10.6``
+ * Apple ``gcc-4.2``
+ * Python 2.n (n >= 4) for documentation build with Sphinx
+
+ - alternate build environments:
+
+ * none
+
+
+General Prerequisites
+---------------------
+
+* No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local
+ libraries or utilities (in ``/usr/local``) as they could
interfere with the build.
-* The documentation for the release must be available on python.org
+* The documentation for the release is built using Sphinx
because it is included in the installer.
+* It is safest to start each variant build with an empty source directory
+ populated with a fresh copy of the untarred source.
+
The Recipe
----------
-Here are the steps you need to follow to build a MacPython installer:
+Here are the steps you need to follow to build a Python installer:
-* Run ``./build-installer.py``. Optionally you can pass a number of arguments
- to specify locations of various files. Please see the top of
+* Run ``build-installer.py``. Optionally you can pass a number of arguments
+ to specify locations of various files. Please see the top of
``build-installer.py`` for its usage.
- Running this script takes some time, I will not only build Python itself
+ Running this script takes some time, it will not only build Python itself
but also some 3th-party libraries that are needed for extensions.
* When done the script will tell you where the DMG image is (by default
somewhere in ``/tmp/_py``).
-Building a 4-way universal installer
-....................................
+Building other universal installers
+...................................
It is also possible to build a 4-way universal installer that runs on
-OSX Leopard or later::
+OS X Leopard or later::
- $ ./build-installer.py --dep-target=10.5 --universal-archs=all --sdk=/
+ python 2.6 /build-installer.py \
+ --dep-target=10.5
+ --universal-archs=all
+ --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
-This requires that the deployment target is 10.5 (or later), and hence
-also that your building on at least OSX 10.5.
-
-Testing
--------
-
-The resulting binaries should work on MacOSX 10.3.9 or later. I usually run
-the installer on a 10.3.9, a 10.4.x PPC and a 10.4.x Intel system and then
-run the testsuite to make sure.
+This requires that the deployment target is 10.5, and hence
+also that you are building on at least OS X 10.5. 4-way includes
+``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable
+variants can only be run on G5 machines running 10.5. Note that,
+while OS X 10.6 is only supported on Intel-based machines, it is possible
+to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
+emulation in OS X 10.5 and 10.6.
+Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
+and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options
+are regularly exercised; use at your own risk.
-Announcements
--------------
-(This is mostly of historic interest)
+Testing
+-------
-When all is done, announcements can be posted to at least the following
-places:
-- pythonmac-sig@python.org
-- python-dev@python.org
-- python-announce@python.org
-- archivist@info-mac.org
-- adcnews@apple.com
-- news@macnn.com
-- http://www.macupdate.com
-- http://guide.apple.com/usindex.lasso
-- http://www.apple.com/downloads/macosx/submit
-- http://www.versiontracker.com/ (userid Jack.Jansen@oratrix.com)
-- http://www.macshareware.net (userid jackjansen)
+Ideally, the resulting binaries should be installed and the test suite run
+on all supported OS X releases and architectures. As a practical matter,
+that is generally not possible. At a minimum, variant 1 should be run on
+at least one Intel, one PPC G4, and one PPC G3 system and one each of
+OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9.
+Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.::
+
+ arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all
+ arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all
+
+Certain tests will be skipped and some cause the interpreter to fail
+which will likely generate ``Python quit unexpectedly`` alert messages
+to be generated at several points during a test run. These can
+be ignored.
-Also, check out Stephan Deibels http://pythonology.org/market contact list
diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py
index 08e64d9..0a0c0d6 100755
--- a/Mac/BuildScript/build-installer.py
+++ b/Mac/BuildScript/build-installer.py
@@ -1,12 +1,14 @@
#!/usr/bin/python
"""
-This script is used to build the "official unofficial" universal build on
-Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its
-work. 64-bit or four-way universal builds require at least OS X 10.5 and
-the 10.5 SDK.
+This script is used to build "official" universal installers on Mac OS X.
+It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for
+32-bit builds. 64-bit or four-way universal builds require at least
+OS X 10.5 and the 10.5 SDK.
-Please ensure that this script keeps working with Python 2.3, to avoid
-bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4)
+Please ensure that this script keeps working with Python 2.5, to avoid
+bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5). Sphinx,
+which is used to build the documentation, currently requires at least
+Python 2.4.
Usage: see USAGE variable in the script.
"""
@@ -144,9 +146,9 @@ def library_recipes():
if DEPTARGET < '10.5':
result.extend([
dict(
- name="Bzip2 1.0.5",
- url="http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz",
- checksum='3c15a0c8d1d3ee1c46a1634d00617b1a',
+ name="Bzip2 1.0.6",
+ url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz",
+ checksum='00b516f4704d4a7cb50a1d97e6e8e15b',
configure=None,
install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
CC,
@@ -169,29 +171,33 @@ def library_recipes():
),
dict(
# Note that GNU readline is GPL'd software
- name="GNU Readline 5.1.4",
- url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" ,
- checksum='7ee5a692db88b30ca48927a13fd60e46',
+ name="GNU Readline 6.1.2",
+ url="http://ftp.gnu.org/pub/gnu/readline/readline-6.1.tar.gz" ,
+ checksum='fc2f7e714fe792db1ce6ddc4c9fb4ef3',
patchlevel='0',
patches=[
# The readline maintainers don't do actual micro releases, but
# just ship a set of patches.
- 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001',
- 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002',
- 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003',
- 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004',
+ 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001',
+ 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002',
]
),
dict(
- name="SQLite 3.6.11",
- url="http://www.sqlite.org/sqlite-3.6.11.tar.gz",
- checksum='7ebb099696ab76cc6ff65dd496d17858',
+ name="SQLite 3.7.4",
+ url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz",
+ checksum='8f0c690bfb33c3cbbc2471c3d9ba0158',
+ configure_env=('CFLAGS="-Os'
+ ' -DSQLITE_ENABLE_FTS3'
+ ' -DSQLITE_ENABLE_FTS3_PARENTHESIS'
+ ' -DSQLITE_ENABLE_RTREE'
+ ' -DSQLITE_TCL=0'
+ '"'),
configure_pre=[
'--enable-threadsafe',
- '--enable-tempstore',
'--enable-shared=no',
'--enable-static=yes',
- '--disable-tcl',
+ '--disable-readline',
+ '--disable-dependency-tracking',
]
),
dict(
@@ -199,6 +205,7 @@ def library_recipes():
url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz",
checksum='e73c1ac10b4bfc46db43b2ddfd6244ef',
configure_pre=[
+ "--enable-widec",
"--without-cxx",
"--without-ada",
"--without-progs",
@@ -225,18 +232,19 @@ def library_recipes():
),
])
- result.extend([
- dict(
- name="Sleepycat DB 4.7.25",
- url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
- checksum='ec2b87e833779681a0c3a814aa71359e',
- buildDir="build_unix",
- configure="../dist/configure",
- configure_pre=[
- '--includedir=/usr/local/include/db4',
- ]
- ),
- ])
+ if not PYTHON_3:
+ result.extend([
+ dict(
+ name="Sleepycat DB 4.7.25",
+ url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
+ checksum='ec2b87e833779681a0c3a814aa71359e',
+ buildDir="build_unix",
+ configure="../dist/configure",
+ configure_pre=[
+ '--includedir=/usr/local/include/db4',
+ ]
+ ),
+ ])
return result
@@ -399,6 +407,9 @@ def checkEnvironment():
Check that we're running on a supported system.
"""
+ if sys.version_info[0:2] < (2, 4):
+ fatal("This script must be run with Python 2.4 or later")
+
if platform.system() != 'Darwin':
fatal("This script should be run on a Mac OS X 10.4 (or later) system")
@@ -418,15 +429,16 @@ def checkEnvironment():
# to install a newer patch level.
for framework in ['Tcl', 'Tk']:
- fw = dict(lower=framework.lower(),
- upper=framework.upper(),
- cap=framework.capitalize())
- fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw
- sysfw = os.path.join('/System', fwpth)
+ #fw = dict(lower=framework.lower(),
+ # upper=framework.upper(),
+ # cap=framework.capitalize())
+ #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw
+ fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current'
+ sysfw = os.path.join(SDKPATH, 'System', fwpth)
libfw = os.path.join('/', fwpth)
usrfw = os.path.join(os.getenv('HOME'), fwpth)
- version = "%(upper)s_VERSION" % fw
- if getTclTkVersion(libfw, version) != getTclTkVersion(sysfw, version):
+ #version = "%(upper)s_VERSION" % fw
+ if os.readlink(libfw) != os.readlink(sysfw):
fatal("Version of %s must match %s" % (libfw, sysfw) )
if os.path.exists(usrfw):
fatal("Please rename %s to avoid possible dynamic load issues."
@@ -696,6 +708,9 @@ def buildRecipe(recipe, basedir, archList):
configure_args.insert(0, configure)
configure_args = [ shellQuote(a) for a in configure_args ]
+ if 'configure_env' in recipe:
+ configure_args.insert(0, recipe['configure_env'])
+
print "Running configure for %s"%(name,)
runCommand(' '.join(configure_args) + ' 2>&1')
@@ -751,9 +766,9 @@ def buildPython():
shutil.rmtree(buildDir)
if os.path.exists(rootDir):
shutil.rmtree(rootDir)
- os.mkdir(buildDir)
- os.mkdir(rootDir)
- os.mkdir(os.path.join(rootDir, 'empty-dir'))
+ os.makedirs(buildDir)
+ os.makedirs(rootDir)
+ os.makedirs(os.path.join(rootDir, 'empty-dir'))
curdir = os.getcwd()
os.chdir(buildDir)
@@ -825,12 +840,33 @@ def buildPython():
os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP)
os.chown(p, -1, gid)
+ if PYTHON_3:
+ LDVERSION=None
+ VERSION=None
+ ABIFLAGS=None
+
+ fp = open(os.path.join(buildDir, 'Makefile'), 'r')
+ for ln in fp:
+ if ln.startswith('VERSION='):
+ VERSION=ln.split()[1]
+ if ln.startswith('ABIFLAGS='):
+ ABIFLAGS=ln.split()[1]
+ if ln.startswith('LDVERSION='):
+ LDVERSION=ln.split()[1]
+ fp.close()
+
+ LDVERSION = LDVERSION.replace('$(VERSION)', VERSION)
+ LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS)
+ config_suffix = '-' + LDVERSION
+ else:
+ config_suffix = '' # Python 2.x
+
# We added some directories to the search path during the configure
# phase. Remove those because those directories won't be there on
# the end-users system.
path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework',
'Versions', version, 'lib', 'python%s'%(version,),
- 'config', 'Makefile')
+ 'config' + config_suffix, 'Makefile')
fp = open(path, 'r')
data = fp.read()
fp.close()
@@ -866,7 +902,7 @@ def patchFile(inPath, outPath):
data = data.replace('$FULL_VERSION', getFullVersion())
data = data.replace('$VERSION', getVersion())
data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later')))
- data = data.replace('$ARCHITECTURES', "i386, ppc")
+ data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSALARCHS]))
data = data.replace('$INSTALL_SIZE', installSize())
# This one is not handy as a template variable
diff --git a/Mac/BuildScript/resources/ReadMe.txt b/Mac/BuildScript/resources/ReadMe.txt
index 67d4525..f1beda0 100644
--- a/Mac/BuildScript/resources/ReadMe.txt
+++ b/Mac/BuildScript/resources/ReadMe.txt
@@ -1,29 +1,36 @@
This package will install Python $FULL_VERSION for Mac OS X
-$MACOSX_DEPLOYMENT_TARGET for the following
-architecture(s): $ARCHITECTURES.
+$MACOSX_DEPLOYMENT_TARGET for the following architecture(s):
+$ARCHITECTURES.
-Separate installers are available for older versions
-of Mac OS X, see the homepage, below.
+Installation requires approximately $INSTALL_SIZE MB of disk space,
+ignore the message that it will take zero bytes.
-Installation requires approximately $INSTALL_SIZE MB of disk
-space, ignore the message that it will take zero bytes.
+You must install onto your current boot disk, even though the
+installer does not enforce this, otherwise things will not work.
-You must install onto your current boot disk, even
-though the installer does not enforce this, otherwise
-things will not work.
+Python consists of the Python programming language interpreter, plus
+a set of programs to allow easy access to it for Mac users including
+an integrated development environment, IDLE, plus a set of pre-built
+extension modules that open up specific Macintosh technologies to
+Python programs.
-Python consists of the Python programming language
-interpreter, plus a set of programs to allow easy
-access to it for Mac users including an integrated development
-environment, IDLE, plus a set of pre-built extension modules
-that open up specific Macintosh technologies to Python programs.
+ **** IMPORTANT ****
+
+Before using IDLE or other programs using the tkinter graphical user
+interface toolkit, visit http://www.python.org/download/mac/tcltk/
+for current information about supported and recommended versions
+of Tcl/Tk for this version of Python and Mac OS X.
-The installer puts the applications in "Python $VERSION"
-in your Applications folder, and the underlying machinery in
-$PYTHONFRAMEWORKINSTALLDIR. It can optionally place
-links to the command-line tools in /usr/local as well,
-by default you have to add the "bin" directory inside
-the framework to you shell's search path.
+ *******************
+
+The installer puts applications, an "Update Shell Profile" command,
+and a link to the optionally installed Python Documentation into the
+"Python $VERSION" subfolder of the system Applications folder,
+and puts the underlying machinery into the folder
+$PYTHONFRAMEWORKINSTALLDIR. It can
+optionally place links to the command-line tools in /usr/local/bin as
+well. Double-click on the "Update Shell Profile" command to add the
+"bin" directory inside the framework to your shell's search path.
More information on Python in general can be found at
http://www.python.org.
diff --git a/Mac/BuildScript/resources/Welcome.rtf b/Mac/BuildScript/resources/Welcome.rtf
index ed4643b..d209b10 100644
--- a/Mac/BuildScript/resources/Welcome.rtf
+++ b/Mac/BuildScript/resources/Welcome.rtf
@@ -1,19 +1,35 @@
-{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
+{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
-\paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0
+\paperw11904\paperh16836\margl1440\margr1440\vieww9640\viewh10620\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\fs24 \cf0 This package will install
-\b MacPython $FULL_VERSION
+\b Python $FULL_VERSION
\b0 for
\b Mac OS X $MACOSX_DEPLOYMENT_TARGET
\b0 .\
\
-MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including an integrated development environment \b IDLE\b0 plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs.\
+
+\b Python for Mac OS X
+\b0 consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac OS X users including an integrated development environment
+\b IDLE
+\b0 and a set of pre-built extension modules that open up specific Macintosh technologies to Python programs.\
\
-See the ReadMe file for more information.\
+See the ReadMe file and the Python documentation for more information.\
\
\b NOTE:
-\b0 This package will by default not update your shell profile and will also not install files in /usr/local. Double-click \b Update Shell Profile\b0 at any time to make $FULL_VERSION the default Python.}
+\b0 This package will by default not update your shell profile and will also not install files in /usr/local. Double-click
+\b Update Shell Profile
+\b0 at any time to make $FULL_VERSION the default Python.\
+\
+
+\b IMPORTANT:
+\b0
+\b IDLE
+\b0 and other programs using the
+\b tkinter
+\b0 graphical user interface toolkit require specific versions of the
+\b Tcl/Tk
+\b0 platform independent windowing toolkit. Visit {\field{\*\fldinst{HYPERLINK "http://www.python.org/download/mac/tcltk/"}}{\fldrslt http://www.python.org/download/mac/tcltk/}} for current information on supported and recommended versions of Tcl/Tk for this version of Python and Mac OS X.} \ No newline at end of file
diff --git a/Mac/BuildScript/scripts/postflight.documentation b/Mac/BuildScript/scripts/postflight.documentation
index 9f5918e..31fbf2f 100755
--- a/Mac/BuildScript/scripts/postflight.documentation
+++ b/Mac/BuildScript/scripts/postflight.documentation
@@ -1,11 +1,32 @@
#!/bin/sh
PYVER="@PYVER@"
+FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}"
+FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation"
+FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}"
+APPDIR="/Applications/Python ${PYVER}"
+DEV_DOCDIR="/Developer/Documentation"
+SHARE_DIR="${FWK}/share"
+SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}"
+SHARE_DOCDIR_TO_FWK="../../.."
-if [ -d /Developer/Documentation ]; then
- if [ ! -d /Developer/Documentation/Python ]; then
- mkdir -p /Developer/Documentation/Python
- fi
+# make link in /Developer/Documentation/ for Xcode users
+if [ -d "${DEV_DOCDIR}" ]; then
+ if [ ! -d "${DEV_DOCDIR}/Python" ]; then
+ mkdir -p "${DEV_DOCDIR}/Python"
+ fi
+ ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}"
+fi
+
+# make link in /Applications/Python m.n/ for Finder users
+if [ -d "${APPDIR}" ]; then
+ ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html"
+fi
- ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation @PYVER@"
+# make share/doc link in framework for command line users
+if [ -d "${SHARE_DIR}" ]; then
+ mkdir -p "${SHARE_DOCDIR}"
+ # make relative link to html doc directory
+ ln -fhs "${SHARE_DOCDIR_TO_FWK}/${FWK_DOCDIR_SUBPATH}" "${SHARE_DOCDIR}/html"
fi
+
diff --git a/Mac/Extras.ReadMe.txt b/Mac/Extras.ReadMe.txt
deleted file mode 100644
index 2d7fd42..0000000
--- a/Mac/Extras.ReadMe.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-This folder contains examples of Python usage and useful scripts and tools.
-
-You should be aware that these are not Macintosh-specific but are shared
-among Python on all platforms, so there are some that only run on Windows
-or Unix or another platform, and/or make little sense on a Macintosh.
diff --git a/Mac/Makefile.in b/Mac/Makefile.in
index 18db641..5e57b57 100644
--- a/Mac/Makefile.in
+++ b/Mac/Makefile.in
@@ -15,6 +15,8 @@ LDFLAGS=@LDFLAGS@
FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
+LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
+CC=@CC@
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
export MACOSX_DEPLOYMENT_TARGET
@@ -22,7 +24,7 @@ export MACOSX_DEPLOYMENT_TARGET
# These are normally glimpsed from the previous set
bindir=$(prefix)/bin
-PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
+PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
APPINSTALLDIR=$(prefix)/Resources/Python.app
# Variables for installing the "normal" unix binaries
@@ -44,45 +46,20 @@ APPTEMPLATE=$(srcdir)/Resources/app
APPSUBDIRS=MacOS Resources
compileall=$(srcdir)/../Lib/compileall.py
-installapps: install_Python install_PythonLauncher install_IDLE \
- checkapplepython install_pythonw install_versionedtools
-
-installapps4way: install_Python4way install_PythonLauncher \
- install_IDLE4way install_pythonw4way install_versionedtools
-
+installapps: install_Python install_pythonw install_PythonLauncher install_IDLE \
+ checkapplepython
install_pythonw: pythonw
$(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
$(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python3"
ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw3"
-
-
-# Install 3 variants of python/pythonw:
-# - 32-bit (i386 and ppc)
-# - 64-bit (x86_64 and ppc64)
-# - all (all four architectures)
-# - Make 'python' and 'pythonw' aliases for the 32-bit variant
-install_pythonw4way: pythonw-32 pythonw-64 pythonw
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-64"
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-64"
- ln -sf python$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/python3-64"
- ln -sf pythonw$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/pythonw3-64"
-
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32"
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-32"
- ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python3-32"
- ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw3-32"
-
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-all"
- $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)-all"
- ln -sf python$(VERSION)-all "$(DESTDIR)$(prefix)/bin/python3-all"
- ln -sf pythonw$(VERSION)-all "$(DESTDIR)$(prefix)/bin/pythonw3-all"
-
- ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
- ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
- ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw3"
- ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python3"
+ifneq ($(LIPO_32BIT_FLAGS),)
+ lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/python$(VERSION)-32 pythonw
+ lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32 pythonw
+ ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw3-32"
+ ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python3-32"
+endif
#
# Install unix tools in /usr/local/bin. These are just aliases for the
@@ -101,10 +78,6 @@ installunixtools:
done
-# TODO: install symlinks for -32, -64 and -all as well
-installunixtools4way: installunixtools
-
-
#
# Like installunixtools, but only install links to the versioned binaries.
#
@@ -118,43 +91,8 @@ altinstallunixtools:
ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
done
-# TODO: -32, -64 and -all variants
-altinstallunixtools4way: altinstallunixtools
-
-# By default most tools are installed without a version in their basename, to
-# make it easier to install (and use) several python versions side-by-side move
-# the tools to a version-specific name and add the non-versioned name as an
-# alias.
-install_versionedtools:
- for fn in idle pydoc ;\
- do \
- if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}3" ]; then \
- continue ;\
- fi ;\
- mv "$(DESTDIR)$(prefix)/bin/$${fn}3" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
- ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}3" ;\
- done
- mv "$(DESTDIR)$(prefix)/bin/2to3" "$(DESTDIR)$(prefix)/bin/2to3-$(VERSION)"
- ln -sf "2to3-$(VERSION)" "$(DESTDIR)$(prefix)/bin/2to3"
- if [ ! -h "$(DESTDIR)$(prefix)/bin/python3-config" ]; then \
- mv "$(DESTDIR)$(prefix)/bin/python3-config" "$(DESTDIR)$(prefix)/bin/python$(VERSION)-config" ;\
- ln -sf "python$(VERSION)-config" "$(DESTDIR)$(prefix)/bin/python3-config" ; \
- fi
-
-
pythonw: $(srcdir)/Tools/pythonw.c Makefile
- $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \
- -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"'
-
-pythonw-32: $(srcdir)/Tools/pythonw.c Makefile
- $(CC) $(LDFLAGS) -o pythonw-tmp.o $(srcdir)/Tools/pythonw.c \
- -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32"' ;\
- lipo @LIPO_32BIT_FLAGS@ -output $@ pythonw-tmp.o ; rm pythonw-tmp.o
-
-pythonw-64: $(srcdir)/Tools/pythonw.c Makefile
- $(CC) $(LDFLAGS) -o pythonw-tmp.o $(srcdir)/Tools/pythonw.c \
- -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64"' ;\
- lipo @LIPO_64BIT_FLAGS@ -output $@ pythonw-tmp.o ; rm pythonw-tmp.o
+ $(CC) $(LDFLAGS) -DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' -o $@ $(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include ../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
install_PythonLauncher:
cd PythonLauncher && make install DESTDIR=$(DESTDIR)
@@ -210,11 +148,6 @@ install_Python:
> "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
-install_Python4way: install_Python
- lipo @LIPO_32BIT_FLAGS@ -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
- lipo @LIPO_64BIT_FLAGS@ -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
-
-
install_IDLE:
test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
@@ -242,20 +175,13 @@ install_IDLE:
fi
touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
-install_IDLE4way: install_IDLE
- ln -sf "$(INSTALLED_PYTHONAPP)-32" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
- sed -e "s!%prefix%!$(prefix)!g" -e 's!%exe%!$(PYTHONFRAMEWORK)-32!g' < "$(srcdir)/IDLE/IDLE.app/Contents/MacOS/IDLE" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/IDLE"
- touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
-
$(INSTALLED_PYTHONAPP): install_Python
-installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
- $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
- $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
- $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
- "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
- $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
- "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
+installextras: $(srcdir)/Extras.install.py
+ $(INSTALL) -d "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples"
+ $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Tools \
+ "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" ; \
+ chmod -R ugo+rX,go-w "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools"
checkapplepython: $(srcdir)/Tools/fixapplepython23.py
diff --git a/Mac/PythonLauncher/Makefile.in b/Mac/PythonLauncher/Makefile.in
index 539ed1a..970b83f 100644
--- a/Mac/PythonLauncher/Makefile.in
+++ b/Mac/PythonLauncher/Makefile.in
@@ -21,7 +21,7 @@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
BUNDLEBULDER=$(srcdir)/../Tools/bundlebuilder.py
-PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
+PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
install: Python\ Launcher.app
diff --git a/Mac/README b/Mac/README
index f84e134..0261127 100644
--- a/Mac/README
+++ b/Mac/README
@@ -5,16 +5,24 @@ MacOSX Notes
This document provides a quick overview of some Mac OS X specific features in
the Python distribution.
-Mac-specific arguments to configure
-===================================
-
-* ``--enable-framework``
+* ``--enable-framework[=DIR]``
If this argument is specified the build will create a Python.framework rather
than a traditional Unix install. See the section
_`Building and using a framework-based Python on Mac OS X` for more
information on frameworks.
+ If the optional directory argument is specified the framework it installed
+ into that directory. This can be used to install a python framework into
+ your home directory::
+
+ $ configure --enable-framework=/Users/ronald/Library/Frameworks
+ $ make && make install
+
+ This will install the framework itself in ``/Users/ronald/Library/Frameworks``,
+ the applications in a subdirectory of ``/Users/ronald/Applications`` and the
+ command-line tools in ``/Users/ronald/bin``.
+
* ``--with-framework-name=NAME``
Specify the name for the python framework, defaults to ``Python``. This option
@@ -25,19 +33,18 @@ Mac-specific arguments to configure
Create a universal binary build of of Python. This can be used with both
regular and framework builds.
- The optional argument specifies with OSX SDK should be used to perform the
+ The optional argument specifies which OSX SDK should be used to perform the
build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``, specify
``/`` when building on a 10.5 system, especially when building 64-bit code.
See the section _`Building and using a universal binary of Python on Mac OS X`
for more information.
-* ``--with-universal-archs=VALUE``
+* ``--with-univeral-archs=VALUE``
Specify the kind of universal binary that should be created. This option is
only valid when ``--enable-universalsdk`` is specified.
-
Building and using a universal binary of Python on Mac OS X
===========================================================
@@ -64,12 +71,6 @@ unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
installing Xcode.
-The option ``--enable-universalsdk`` has an optional argument to specify an
-SDK, which defaults to the 10.4u SDK. When you build on OSX 10.5 or later
-you can use the system headers instead of an SDK::
-
- $ ./configure --enable-universalsdk=/
-
2.1 Flavours of universal binaries
..................................
@@ -88,10 +89,29 @@ values are available:
* ``intel``: ``i386``, ``x86_64``
-To build a universal binary that includes a 64-bit architecture you must build
-on a system running OSX 10.5 or later. The ``all`` flavour can only be build on
+To build a universal binary that includes a 64-bit architecture, you must build
+on a system running OSX 10.5 or later. The ``all`` flavour can only be built on
OSX 10.5.
+The makefile for a framework build will install ``python32`` and ``pythonw32``
+binaries when the universal architecures includes at least one 32-bit architecture
+(that is, for all flavours but ``64-bit``).
+
+Running a specific archicture
+.............................
+
+You can run code using a specific architecture using the ``arch`` command::
+
+ $ arch -i386 python
+
+Or to explicitly run in 32-bit mode, regardless of the machine hardware::
+
+ $ arch -i386 -ppc python
+
+NOTE: When you're using a framework install of Python this requires at least
+Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
+wrapper tools that execute the real interpreter without ensuring that the
+real interpreter runs with the same architecture.
Building and using a framework-based Python on Mac OS X.
========================================================
@@ -109,7 +129,8 @@ will have to do the work yourself if you really want this.
A second reason for using frameworks is that they put Python-related items in
only two places: "/Library/Framework/Python.framework" and
-"/Applications/MacPython m.n". This simplifies matters for users installing
+"/Applications/MacPython <VERSION>" where ``<VERSION>`` can be e.g. "2.6",
+"3.1", etc.. This simplifies matters for users installing
Python from a binary distribution if they want to get rid of it again. Moreover,
due to the way frameworks work a user without admin privileges can install a
binary distribution in his or her home directory without recompilation.
@@ -136,33 +157,40 @@ PyObjC.
This directory contains a Makefile that will create a couple of python-related
applications (fullblown OSX .app applications, that is) in
-"/Applications/MacPython m.n", and a hidden helper application Python.app
+"/Applications/MacPython <VERSION>", and a hidden helper application Python.app
inside the Python.framework, and unix tools "python" and "pythonw" into
/usr/local/bin. In addition it has a target "installmacsubtree" that installs
the relevant portions of the Mac subtree into the Python.framework.
It is normally invoked indirectly through the main Makefile, as the last step
-in the sequence::
+in the sequence
+
+ 1. ./configure --enable-framework
- $ ./configure --enable-framework
- $ make
- $ make install
+ 2. make
+
+ 3. make install
This sequence will put the framework in /Library/Framework/Python.framework,
-the applications in "/Applications/MacPython m.n" and the unix tools in
+the applications in "/Applications/MacPython <VERSION>" and the unix tools in
/usr/local/bin.
-It is possible to select a different name for the framework using the configure
-option ``--with-framework-name=NAME``. This makes it possible to have several
-parallel installs of a Python framework.
-
Installing in another place, for instance $HOME/Library/Frameworks if you have
no admin privileges on your machine, has only been tested very lightly. This
can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
-The other two directories, "/Applications/MacPython-m.n" and /usr/local/bin,
-will then also be deposited in $HOME. This is sub-optimal for the unix tools,
-which you would want in $HOME/bin, but there is no easy way to fix this right
-now.
+The other two directories, "/Applications/MacPython-<VERSION>" and
+/usr/local/bin, will then also be deposited in $HOME. This is sub-optimal for
+the unix tools, which you would want in $HOME/bin, but there is no easy way to
+fix this right now.
+
+If you want to install some part, but not all, read the main Makefile. The
+frameworkinstall is composed of a couple of sub-targets that install the
+framework itself, the Mac subtree, the applications and the unix tools.
+
+There is an extra target frameworkinstallextras that is not part of the
+normal frameworkinstall which installs the Tools directory into
+"/Applications/MacPython <VERSION>", this is useful for binary
+distributions.
What do all these programs do?
===============================
@@ -178,11 +206,6 @@ GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
script to set runtime options. These options can be set once and for all
through PythonLauncher's preferences dialog.
-"BuildApplet.app" creates an applet from a Python script. Drop the script on it
-and out comes a full-featured MacOS application. There is much more to this,
-to be supplied later. Some useful (but outdated) info can be found in
-Mac/Demo.
-
The commandline scripts /usr/local/bin/python and pythonw can be used to run
non-GUI and GUI python scripts from the command line, respectively.
diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c
index e70a76f..30c82ac 100644
--- a/Mac/Tools/pythonw.c
+++ b/Mac/Tools/pythonw.c
@@ -3,15 +3,176 @@
* application bundle inside the Python framework. This is needed to run
* GUI code: some GUI API's don't work unless the program is inside an
* application bundle.
+ *
+ * This program uses posix_spawn rather than plain execv because we need
+ * slightly more control over how the "real" interpreter is executed.
+ *
+ * On OSX 10.4 (and earlier) this falls back to using exec because the
+ * posix_spawnv functions aren't available there.
*/
+
+#pragma weak_import posix_spawnattr_init
+#pragma weak_import posix_spawnattr_setbinpref_np
+#pragma weak_import posix_spawnattr_setflags
+#pragma weak_import posix_spawn
+
+#include <Python.h>
#include <unistd.h>
+#ifdef HAVE_SPAWN_H
+#include <spawn.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include <err.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <Python.h>
+
+
+extern char** environ;
+
+/*
+ * Locate the python framework by looking for the
+ * library that contains Py_Initialize.
+ *
+ * In a regular framework the structure is:
+ *
+ * Python.framework/Versions/2.7
+ * /Python
+ * /Resources/Python.app/Contents/MacOS/Python
+ *
+ * In a virtualenv style structure the expected
+ * structure is:
+ *
+ * ROOT
+ * /bin/pythonw
+ * /.Python <- the dylib
+ * /.Resources/Python.app/Contents/MacOS/Python
+ *
+ * NOTE: virtualenv's are not an officially supported
+ * feature, support for that structure is provided as
+ * a convenience.
+ */
+static char* get_python_path(void)
+{
+ size_t len;
+ Dl_info info;
+ char* end;
+ char* g_path;
+
+ if (dladdr(Py_Initialize, &info) == 0) {
+ return NULL;
+ }
+
+ len = strlen(info.dli_fname);
+
+ g_path = malloc(len+60);
+ if (g_path == NULL) {
+ return NULL;
+ }
+
+ strcpy(g_path, info.dli_fname);
+ end = g_path + len - 1;
+ while (end != g_path && *end != '/') {
+ end --;
+ }
+ end++;
+ if (*end == '.') {
+ end++;
+ }
+ strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK);
+
+ return g_path;
+}
+
+#ifdef HAVE_SPAWN_H
+static void
+setup_spawnattr(posix_spawnattr_t* spawnattr)
+{
+ size_t ocount;
+ size_t count;
+ cpu_type_t cpu_types[1];
+ short flags = 0;
+#ifdef __LP64__
+ int ch;
+#endif
+
+ if ((errno = posix_spawnattr_init(spawnattr)) != 0) {
+ err(2, "posix_spawnattr_int");
+ /* NOTREACHTED */
+ }
+
+ count = 1;
+
+ /* Run the real python executable using the same architecture as this
+ * executable, this allows users to control the architecture using
+ * "arch -ppc python"
+ */
+
+#if defined(__ppc64__)
+ cpu_types[0] = CPU_TYPE_POWERPC64;
+
+#elif defined(__x86_64__)
+ cpu_types[0] = CPU_TYPE_X86_64;
+
+#elif defined(__ppc__)
+ cpu_types[0] = CPU_TYPE_POWERPC;
+#elif defined(__i386__)
+ cpu_types[0] = CPU_TYPE_X86;
+#else
+# error "Unknown CPU"
+#endif
+
+ if (posix_spawnattr_setbinpref_np(spawnattr, count,
+ cpu_types, &ocount) == -1) {
+ err(1, "posix_spawnattr_setbinpref");
+ /* NOTREACHTED */
+ }
+ if (count != ocount) {
+ fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n");
+ exit(1);
+ /* NOTREACHTED */
+ }
+
+
+ /*
+ * Set flag that causes posix_spawn to behave like execv
+ */
+ flags |= POSIX_SPAWN_SETEXEC;
+ if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) {
+ err(1, "posix_spawnattr_setflags");
+ /* NOTREACHTED */
+ }
+}
+#endif
+
+int
+main(int argc, char **argv) {
+ char* exec_path = get_python_path();
+
+ /*
+ * Let argv[0] refer to the new interpreter. This is needed to
+ * get the effect we want on OSX 10.5 or earlier. That is, without
+ * changing argv[0] the real interpreter won't have access to
+ * the Window Server.
+ */
+ argv[0] = exec_path;
-static char Python[] = PYTHONWEXECUTABLE;
+#ifdef HAVE_SPAWN_H
+ /* We're weak-linking to posix-spawnv to ensure that
+ * an executable build on 10.5 can work on 10.4.
+ */
+ if (posix_spawn != NULL) {
+ posix_spawnattr_t spawnattr = NULL;
-int main(int argc, char **argv) {
- argv[0] = Python;
- execv(Python, argv);
- err(1, "execv: %s", Python);
- /* NOTREACHED */
+ setup_spawnattr(&spawnattr);
+ posix_spawn(NULL, exec_path, NULL,
+ &spawnattr, argv, environ);
+ err(1, "posix_spawn: %s", exec_path);
+ }
+#endif
+ execve(exec_path, argv, environ);
+ err(1, "execve: %s", argv[0]);
+ /* NOTREACHED */
}