summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
Diffstat (limited to 'Mac')
-rw-r--r--Mac/BuildScript/README.txt44
-rwxr-xr-xMac/BuildScript/build-installer.py120
-rw-r--r--Mac/BuildScript/resources/Welcome.rtf7
-rwxr-xr-xMac/BuildScript/scripts/postflight.framework2
-rwxr-xr-xMac/BuildScript/scripts/postflight.patch-profile28
-rw-r--r--Mac/Demo/applescript.html6
-rw-r--r--Mac/Demo/calldll/readme48
-rw-r--r--Mac/Demo/calldll/samplecalldll.py24
-rw-r--r--Mac/Demo/calldll/testcalldll.py132
-rw-r--r--Mac/Demo/index.html18
-rw-r--r--Mac/IDLE/config-main.def2
-rw-r--r--Mac/Makefile.in2
-rw-r--r--Mac/Modules/MacOS.c (renamed from Mac/Modules/macosmodule.c)1
-rw-r--r--Mac/Modules/ae/_AEmodule.c39
-rwxr-xr-xMac/PythonLauncher/FileSettings.m21
-rw-r--r--Mac/Tools/fixapplepython23.py10
16 files changed, 204 insertions, 300 deletions
diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt
index c556de83..41df0e4 100644
--- a/Mac/BuildScript/README.txt
+++ b/Mac/BuildScript/README.txt
@@ -8,15 +8,47 @@ $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.
-Here are the steps you ned to follow to build a MacPython installer:
+Prerequisites
+-------------
-- Run ``./build-installer.py``. Optionally you can pass a number of arguments
- to specify locations of various files. Please see the top of
+* A MacOS X 10.4 (or later)
+
+* XCode 2.2 (or later), with the universal SDK
+
+* No Fink (in ``/sw``) or DarwinPorts (in ``/opt/local``), those could
+ interfere with the build.
+
+* The documentation for the release must be available on python.org
+ because it is included in the installer.
+
+
+The Recipe
+----------
+
+Here are the steps you need to follow to build a MacPython installer:
+
+* 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.
-- When done the script will tell you where the DMG image is.
-The script needs to be run on Mac OS X 10.4 with Xcode 2.2 or later and
-the 10.4u SDK.
+ Running this script takes some time, I 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``).
+
+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.
+
+
+Announcements
+-------------
+
+(This is mostly of historic interest)
When all is done, announcements can be posted to at least the following
places:
diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py
index 05afe98..083209b 100755
--- a/Mac/BuildScript/build-installer.py
+++ b/Mac/BuildScript/build-installer.py
@@ -67,6 +67,8 @@ DEPSRC=os.path.expanduser('~/Universal/other-sources')
SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk"
#SDKPATH="/"
+ARCHLIST=('i386', 'ppc',)
+
# Source directory (asume we're in Mac/BuildScript)
SRCDIR=os.path.dirname(
os.path.dirname(
@@ -91,6 +93,26 @@ USAGE=textwrap.dedent("""\
# batteries included python.
LIBRARY_RECIPES=[
dict(
+ name="Bzip2 1.0.3",
+ url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz",
+ configure=None,
+ install='make install PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+ shellQuote(os.path.join(WORKDIR, 'libraries')),
+ ' -arch '.join(ARCHLIST),
+ SDKPATH,
+ ),
+ ),
+ dict(
+ name="ZLib 1.2.3",
+ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz",
+ configure=None,
+ install='make install prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+ shellQuote(os.path.join(WORKDIR, 'libraries')),
+ ' -arch '.join(ARCHLIST),
+ SDKPATH,
+ ),
+ ),
+ 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" ,
@@ -236,7 +258,7 @@ PKG_RECIPES=[
Mac OS X 10.3 to ensure that you can build new python extensions
using that copy of python after installing this version of
python.
- """
+ """,
postflight="../Tools/fixapplepython23.py",
topdir="/Library/Frameworks/Python.framework",
source="/empty-dir",
@@ -486,48 +508,49 @@ def buildRecipe(recipe, basedir, archList):
runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
shellQuote(fn),))
- configure_args = [
- "--prefix=/usr/local",
- "--enable-static",
- "--disable-shared",
- #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
- ]
-
- if 'configure_pre' in recipe:
- args = list(recipe['configure_pre'])
- if '--disable-static' in args:
- configure_args.remove('--enable-static')
- if '--enable-shared' in args:
- configure_args.remove('--disable-shared')
- configure_args.extend(args)
-
- if recipe.get('useLDFlags', 1):
- configure_args.extend([
- "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
- ' -arch '.join(archList),
- shellQuote(SDKPATH)[1:-1],
- shellQuote(basedir)[1:-1],),
- "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
- shellQuote(SDKPATH)[1:-1],
- shellQuote(basedir)[1:-1],
- ' -arch '.join(archList)),
- ])
- else:
- configure_args.extend([
- "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
- ' -arch '.join(archList),
+ if configure is not None:
+ configure_args = [
+ "--prefix=/usr/local",
+ "--enable-static",
+ "--disable-shared",
+ #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
+ ]
+
+ if 'configure_pre' in recipe:
+ args = list(recipe['configure_pre'])
+ if '--disable-static' in args:
+ configure_args.remove('--enable-static')
+ if '--enable-shared' in args:
+ configure_args.remove('--disable-shared')
+ configure_args.extend(args)
+
+ if recipe.get('useLDFlags', 1):
+ configure_args.extend([
+ "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
+ ' -arch '.join(archList),
+ shellQuote(SDKPATH)[1:-1],
+ shellQuote(basedir)[1:-1],),
+ "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
shellQuote(SDKPATH)[1:-1],
- shellQuote(basedir)[1:-1],),
- ])
+ shellQuote(basedir)[1:-1],
+ ' -arch '.join(archList)),
+ ])
+ else:
+ configure_args.extend([
+ "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
+ ' -arch '.join(archList),
+ shellQuote(SDKPATH)[1:-1],
+ shellQuote(basedir)[1:-1],),
+ ])
- if 'configure_post' in recipe:
- configure_args = configure_args = list(recipe['configure_post'])
+ if 'configure_post' in recipe:
+ configure_args = configure_args = list(recipe['configure_post'])
- configure_args.insert(0, configure)
- configure_args = [ shellQuote(a) for a in configure_args ]
+ configure_args.insert(0, configure)
+ configure_args = [ shellQuote(a) for a in configure_args ]
- print "Running configure for %s"%(name,)
- runCommand(' '.join(configure_args) + ' 2>&1')
+ print "Running configure for %s"%(name,)
+ runCommand(' '.join(configure_args) + ' 2>&1')
print "Running install for %s"%(name,)
runCommand('{ ' + install + ' ;} 2>&1')
@@ -550,7 +573,7 @@ def buildLibraries():
os.makedirs(os.path.join(universal, 'usr', 'local', 'include'))
for recipe in LIBRARY_RECIPES:
- buildRecipe(recipe, universal, ('i386', 'ppc',))
+ buildRecipe(recipe, universal, ARCHLIST)
@@ -686,6 +709,9 @@ def patchFile(inPath, outPath):
data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later')
data = data.replace('$ARCHITECTURES', "i386, ppc")
data = data.replace('$INSTALL_SIZE', installSize())
+
+ # This one is not handy as a template variable
+ data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework')
fp = open(outPath, 'wb')
fp.write(data)
fp.close()
@@ -703,7 +729,10 @@ def patchScript(inPath, outPath):
def packageFromRecipe(targetDir, recipe):
curdir = os.getcwd()
try:
- pkgname = recipe['name']
+ # The major version (such as 2.5) is included in the pacakge name
+ # because haveing two version of python installed at the same time is
+ # common.
+ pkgname = '%s-%s'%(recipe['name'], getVersion())
srcdir = recipe.get('source')
pkgroot = recipe.get('topdir', srcdir)
postflight = recipe.get('postflight')
@@ -804,7 +833,7 @@ def makeMpkgPlist(path):
IFPkgFlagComponentDirectory="Contents/Packages",
IFPkgFlagPackageList=[
dict(
- IFPkgFlagPackageLocation='%s.pkg'%(item['name']),
+ IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
IFPkgFlagPackageSelection='selected'
)
for item in PKG_RECIPES
@@ -812,6 +841,7 @@ def makeMpkgPlist(path):
IFPkgFormatVersion=0.10000000149011612,
IFPkgFlagBackgroundScaling="proportional",
IFPkgFlagBackgroundAlignment="left",
+ IFPkgFlagAuthorizationAction="RootAuthorization",
)
writePlist(pl, path)
@@ -859,7 +889,7 @@ def buildInstaller():
else:
patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn))
- shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt'))
+ shutil.copy("../../LICENSE", os.path.join(rsrcDir, 'License.txt'))
def installSize(clear=False, _saved=[]):
@@ -990,7 +1020,7 @@ def main():
buildPythonDocs()
fn = os.path.join(WORKDIR, "_root", "Applications",
"MacPython %s"%(getVersion(),), "Update Shell Profile.command")
- shutil.copy("scripts/postflight.patch-profile", fn)
+ patchFile("scripts/postflight.patch-profile", fn)
os.chmod(fn, 0755)
folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%(
@@ -1005,7 +1035,7 @@ def main():
patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt'))
# Ditto for the license file.
- shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt'))
+ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt'))
fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
print >> fp, "# BUILD INFO"
diff --git a/Mac/BuildScript/resources/Welcome.rtf b/Mac/BuildScript/resources/Welcome.rtf
index cb65f09..d07e104 100644
--- a/Mac/BuildScript/resources/Welcome.rtf
+++ b/Mac/BuildScript/resources/Welcome.rtf
@@ -1,4 +1,4 @@
-{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf330
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0
@@ -12,4 +12,7 @@
\
MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, an applet builder), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\
\
-See the ReadMe file for more information.} \ No newline at end of file
+See the ReadMe file for more information.\
+\
+\
+This package will by default update your shell profile to ensure that this version of Python is on the search path of your shell. Please deselect the "Shell profile updater" package on the package customization screen if you want to avoid this modification. } \ No newline at end of file
diff --git a/Mac/BuildScript/scripts/postflight.framework b/Mac/BuildScript/scripts/postflight.framework
index 532e745..b796a10 100755
--- a/Mac/BuildScript/scripts/postflight.framework
+++ b/Mac/BuildScript/scripts/postflight.framework
@@ -4,7 +4,7 @@
#
PYVER="@PYVER@"
-FWK="/Library/Frameworks/Python.framework/Versions/@PYVER@/"
+FWK="/Library/Frameworks/Python.framework/Versions/@PYVER@"
"${FWK}/bin/python" -Wi -tt \
"${FWK}/lib/python${PYVER}/compileall.py" \
diff --git a/Mac/BuildScript/scripts/postflight.patch-profile b/Mac/BuildScript/scripts/postflight.patch-profile
index 48bf701..c42e11e 100755
--- a/Mac/BuildScript/scripts/postflight.patch-profile
+++ b/Mac/BuildScript/scripts/postflight.patch-profile
@@ -5,14 +5,27 @@ echo "of python is not early enough of the PATH of your shell."
echo "These changes will be effective only in shell windows that you open"
echo "after running this script."
-PYVER=@PYVER@
+PYVER=2.5
PYTHON_ROOT="/Library/Frameworks/Python.framework/Versions/Current"
+if [ `id -ur` = 0 ]; then
+ # Run from the installer, do some trickery to fetch the information
+ # we need.
+ theShell="`finger $USER | grep Shell: | head -1 | awk '{ print $NF }'`"
+
+else
+ theShell="${SHELL}"
+fi
+
# Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH.
-BSH="`basename "${SHELL}"`"
+BSH="`basename "${theShell}"`"
case "${BSH}" in
bash|ksh|sh|*csh)
- P="`${SHELL} -c 'echo $PATH'`"
+ if [ `id -ur` = 0 ]; then
+ 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'`
+ else
+ P="`(exec -l ${theShell} -c 'echo $PATH')`"
+ fi
;;
*)
echo "Sorry, I don't know how to patch $BSH shells"
@@ -42,10 +55,15 @@ case "${BSH}" in
echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc"
echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc"
echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc"
+ if [ `id -ur` = 0 ]; then
+ chown "${USER}" "${HOME}/.cshrc"
+ fi
exit 0
;;
bash)
- if [ -e "${HOME}/.profile" ]; then
+ if [ -e "${HOME}/.bash_profile" ]; then
+ PR="${HOME}/.bash_profile"
+ elif [ -e "${HOME}/.profile" ]; then
PR="${HOME}/.profile"
else
PR="${HOME}/.bash_profile"
@@ -66,6 +84,6 @@ echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}"
echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}"
echo 'export PATH' >> "${PR}"
if [ `id -ur` = 0 ]; then
- chown "${LOGNAME}" "${PR}"
+ chown "${USER}" "${PR}"
fi
exit 0
diff --git a/Mac/Demo/applescript.html b/Mac/Demo/applescript.html
index 014e2ad..5e4fac7 100644
--- a/Mac/Demo/applescript.html
+++ b/Mac/Demo/applescript.html
@@ -4,6 +4,10 @@
<h1>Using the Open Scripting Architecture from Python</h1>
<hr>
+<p><b>NOTE:</b> this document describes the OSA support that is shipped with
+the core python distribution. Most users are better of with the more
+userfriendly <a href="http://freespace.virgin.net/hamish.sanderson/appscript.html">appscript library</a>.
+
<p>OSA support in Python is still not 100% complete, but
there is already enough in place to allow you to do some nifty things
with other programs from your python program. </p>
@@ -355,4 +359,4 @@ man pages for more details.
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/Mac/Demo/calldll/readme b/Mac/Demo/calldll/readme
deleted file mode 100644
index 1e64dfe..0000000
--- a/Mac/Demo/calldll/readme
+++ /dev/null
@@ -1,48 +0,0 @@
-Preliminary notes/documentation for the calldll module, version 0.2.
-====================================================================
-
-Calldll allows you to call random C functions from python without writing any
-C code. It is mainly meant to call MacOS toolbox routines for which no Python
-wrapper module is available. It is also incomplete, in that only a few argument
-types are currently supported. Please let me know which other argument types
-you need, and/or whether you have any ideas on a general "escape" allowing people
-to pass anything.
-
-The module exports three functions:
-- symtable = getlibrary(libraryname)
- Get a reference to import library libraryname. "InterfaceLib" is the most commonly
- used one, containing most toolbox routines. The symbol table can be used
- to lookup routines to be passed to newcall: "symtable.WaitNextEvent" will
- return the address of routine WaitNextEvent. and so will "symtable['WaitNextEvent']".
- The symtable is a mapping, so you can use keys() and len(...) to inspect it.
-- symtable = getdiskfragment(file)
- Load the specified file (given by fsspec or filename) and return a reference to
- its symboltable.
-- callable = newcall(routine, returntype, [argtype, ...])
- Return a callable object. You specify the C routine to be called (as explained above),
- the type of the return value and the argument types. The resulting object can
- be called from Python code in the normal way, and typechecking on arguments is
- performed (but, of course, if you specify incorrect argument types in this call
- you may well crash your machine). Printing a callable will give you a description
- of the (C-) calling sequence.
-
-The C return value can be one of 'None', 'Byte', 'Short', 'Long', 'Pstring' (a pascal
-string returned by address, copied to a Python string), 'Cobject' (a wrapper around a void
-pointer), 'Handle' (a new handle, returned as a Res.Resource object) or 'OSErr' (which raises
-MacOS.Error if non-zero).
-
-Arguments can be any of 'InByte', 'InShort', 'InLong', 'InString' (a python string, with the
-address of the data passed to the C routine, so be careful!), 'InPstring' (a python string copied
-to a Str255 and passed by address), 'InCobject', 'InHandle', 'OutByte' (storage is allocated for
-a single byte, the address passed to C and the resulting value returned to Python), 'OutShort',
-'OutLong', 'OutPstring' (again: storage pre-allocated and the address passed to C), 'OutCobject'
-(storage for a void * is allocated, this void ** is passed to C and the resulting void * is
-encapsulated in the Cobject returned) or 'OutHandle' (ditto, which means that this is usually *not*
-what you use, you normally use 'InHandle' because most toolbox calls expect you to preallocate
-the handle).
-
-All values to be returned (from the return value and the Out arguments) are collected. If there
-aren't any None is returned, if there is one value this value is returned, if there are multiple
-values a tuple is returned.
-
-There is test code in testcalldll.py, and a minimal example in samplecalldll.py.
diff --git a/Mac/Demo/calldll/samplecalldll.py b/Mac/Demo/calldll/samplecalldll.py
deleted file mode 100644
index 3a5bb5c..0000000
--- a/Mac/Demo/calldll/samplecalldll.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Test calldll. Tell the user how often menus flash, and let her change it.
-#
-
-import calldll
-import sys
-
-# Obtain a reference to the library with the toolbox calls
-interfacelib = calldll.getlibrary('InterfaceLib')
-
-# Get the routines we need (see LowMem.h for details)
-LMGetMenuFlash = calldll.newcall(interfacelib.LMGetMenuFlash, 'Short')
-LMSetMenuFlash = calldll.newcall(interfacelib.LMSetMenuFlash, 'None', 'InShort')
-
-print "Menus currently flash",LMGetMenuFlash(),"times."
-print "How often would you like them to flash?",
-
-# Note: we use input(), so you can try passing non-integer objects
-newflash = input()
-LMSetMenuFlash(newflash)
-
-print "Okay, menus now flash", LMGetMenuFlash(),"times."
-
-sys.exit(1) # So the window stays on-screen
diff --git a/Mac/Demo/calldll/testcalldll.py b/Mac/Demo/calldll/testcalldll.py
deleted file mode 100644
index e0f6964..0000000
--- a/Mac/Demo/calldll/testcalldll.py
+++ /dev/null
@@ -1,132 +0,0 @@
-import calldll
-import macfs
-import sys
-import MacOS
-from Carbon import Res
-
-fss, ok = macfs.PromptGetFile("Show me calldll.ppc.slb")
-
-lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb')
-
-cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte',
- 'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte')
-cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort',
- 'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort')
-cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong',
- 'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong')
-
-cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString',
- 'InString', 'InString', 'InString', 'InString', 'InString', 'InString')
-
-cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong')
-
-cdll_N_pp = calldll.newcall(lib.cdll_N_pp, 'None', 'InPstring', 'OutPstring')
-
-cdll_N_bb = calldll.newcall(lib.cdll_N_bb, 'None', 'InByte', 'OutByte')
-cdll_N_hh = calldll.newcall(lib.cdll_N_hh, 'None', 'InShort', 'OutShort')
-cdll_N_ll = calldll.newcall(lib.cdll_N_ll, 'None', 'InLong', 'OutLong')
-cdll_N_sH = calldll.newcall(lib.cdll_N_sH, 'None', 'InString', 'InHandle')
-
-print 'Test cdll_b_bbbbbbbb'
-rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8)
-if rv == 36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_b_bbbbbbbb negative'
-rv = cdll_b_bbbbbbbb(-1, -2, -3, -4, -5, -6, -7, -8)
-if rv == -36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_h_hhhhhhhh'
-rv = cdll_h_hhhhhhhh(1, 2, 3, 4, 5, 6, 7, 8)
-if rv == 36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_h_hhhhhhhh negative'
-rv = cdll_h_hhhhhhhh(-1, -2, -3, -4, -5, -6, -7, -8)
-if rv == -36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_l_llllllll'
-rv = cdll_l_llllllll(1, 2, 3, 4, 5, 6, 7, 8)
-if rv == 36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_l_llllllll negative'
-rv = cdll_l_llllllll(-1, -2, -3, -4, -5, -6, -7, -8)
-if rv == -36:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_N_ssssssss'
-print 'Should print one two three four five six seven eight'
-rv = cdll_N_ssssssss('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight')
-if rv == None:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_o_l(0)'
-rv = cdll_o_l(0)
-if rv == None:
- print 'ok.'
-else:
- print 'Error, returned', rv
-
-print 'Test cdll_o_l(-100)'
-try:
- rv = cdll_o_l(-100)
- print 'Error, did not raise exception, returned', rv
-except MacOS.Error, arg:
- if arg[0] == -100:
- print 'ok.'
- else:
- print 'Error, returned incorrect exception arg:', arg[0]
-
-print 'Test cdll_N_pp'
-rv = cdll_N_pp('pascal string')
-if rv == 'Was: pascal string':
- print 'ok.'
-else:
- print 'Failed, returned', repr(rv)
-
-print 'Test cdll_N_bb'
-rv = cdll_N_bb(-100)
-if rv == -100:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_N_hh'
-rv = cdll_N_hh(-100)
-if rv == -100:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_N_ll'
-rv = cdll_N_ll(-100)
-if rv == -100:
- print 'ok.'
-else:
- print 'Failed, returned', rv
-
-print 'Test cdll_N_sH'
-h = Res.Resource('xyz')
-rv = cdll_N_sH('new data', h)
-if rv == None and h.data == 'new data':
- print 'ok.'
-else:
- print 'Failed, rv is', rv, 'and handle data is', repr(rv.data)
-sys.exit(1)
diff --git a/Mac/Demo/index.html b/Mac/Demo/index.html
index 443cce9..9e01e9f 100644
--- a/Mac/Demo/index.html
+++ b/Mac/Demo/index.html
@@ -3,15 +3,16 @@
<H1><IMG SRC="html.icons/python.gif">Macintosh Python crash course</H1>
<HR>
-This set of documents provides an introduction to various aspects of
+<p>This set of documents provides an introduction to various aspects of
Python programming on the Mac. It is assumed that the reader is
already familiar with Python and, to some extent, with MacOS Toolbox
programming. Other readers may find something interesting here too,
-your mileage may vary. <p>
+your mileage may vary. </p>
-There is a companion document <a href="using.html">Using Python on the Mac</a>
-which you should read before starting here: it explains the basics of using
-python on the Macintosh. <p>
+<p>As the previous paragraph reveals to the careful observer these examples
+are dated, most of them were writting before OSX and haven't been updated
+afterwards. They still show how to use the Carbon wrappers but aren't
+necessarily the best way to use the Carbon API's in OSX.</p>
Another set of Macintosh-savvy examples, more aimed at beginners, is
maintained by Joseph Strout, at Python Tidbits in <A
@@ -27,10 +28,9 @@ in PostScript and other forms, see the <a
href="http://www.python.org/doc/">documentation</a> section on the
webserver. <p>
-The W widget set by Just van Rossum, which is used by the Python IDE, does not
-have complete documentation as of this writing, but Corran Webster has
-documented most of it on his
-<A HREF="http://www.nevada.edu/~cwebster/Python/">Python Page</A>. <p>
+<p>The W widget set by Just van Rossum, does not have complete documentation as
+of this writing, but Corran Webster has documented most of it on his
+<A HREF="http://www.nevada.edu/~cwebster/Python/">Python Page</A>.</p>
There are also some documentation links, as well as other MacPython-related
pages, in the
diff --git a/Mac/IDLE/config-main.def b/Mac/IDLE/config-main.def
index 1cdc0c5..4691a85 100644
--- a/Mac/IDLE/config-main.def
+++ b/Mac/IDLE/config-main.def
@@ -71,7 +71,7 @@ name= IDLE Classic
[Keys]
default= 1
-name= IDLE Classic Mac
+name= IDLE Classic OSX
[History]
cyclic=1
diff --git a/Mac/Makefile.in b/Mac/Makefile.in
index 82514b2..11f1438 100644
--- a/Mac/Makefile.in
+++ b/Mac/Makefile.in
@@ -5,7 +5,7 @@
VERSION=@VERSION@
builddir = ..
srcdir=@srcdir@
-prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION)
+prefix=@prefix@
LIBDEST=$(prefix)/lib/python$(VERSION)
RUNSHARED=@RUNSHARED@
BUILDEXE=@BUILDEXEEXT@
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/MacOS.c
index ed86fd0..4eabb39 100644
--- a/Mac/Modules/macosmodule.c
+++ b/Mac/Modules/MacOS.c
@@ -375,6 +375,7 @@ MacOS_GetErrorString(PyObject *self, PyObject *args)
/* And try again... */
h = GetResource('Estr', err);
}
+ Py_DECREF(m);
}
}
/*
diff --git a/Mac/Modules/ae/_AEmodule.c b/Mac/Modules/ae/_AEmodule.c
index 68be3bf..fd6ebcc 100644
--- a/Mac/Modules/ae/_AEmodule.c
+++ b/Mac/Modules/ae/_AEmodule.c
@@ -829,21 +829,19 @@ static PyObject *AEDesc_get_type(AEDescObject *self, void *closure)
static PyObject *AEDesc_get_data(AEDescObject *self, void *closure)
{
+ PyObject *res;
+ Size size;
+ char *ptr;
+ OSErr err;
- PyObject *res;
- Size size;
- char *ptr;
- OSErr err;
-
- size = AEGetDescDataSize(&self->ob_itself);
- if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
- return NULL;
- if ( (ptr = PyString_AsString(res)) == NULL )
- return NULL;
- if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
- return PyMac_Error(err);
- return res;
-
+ size = AEGetDescDataSize(&self->ob_itself);
+ if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
+ return NULL;
+ if ( (ptr = PyString_AsString(res)) == NULL )
+ return NULL;
+ if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
+ return PyMac_Error(err);
+ return res;
}
#define AEDesc_set_data NULL
@@ -1431,14 +1429,11 @@ void init_AE(void)
PyObject *m;
PyObject *d;
-
-
- upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
- upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
-
+ upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
+ upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
m = Py_InitModule("_AE", AE_methods);
d = PyModule_GetDict(m);
diff --git a/Mac/PythonLauncher/FileSettings.m b/Mac/PythonLauncher/FileSettings.m
index fc3937b..ba375ba 100755
--- a/Mac/PythonLauncher/FileSettings.m
+++ b/Mac/PythonLauncher/FileSettings.m
@@ -245,12 +245,26 @@
if (value) with_terminal = [value boolValue];
}
+- (NSString*)_replaceSingleQuotes: (NSString*)string
+{
+ /* Replace all single-quotes by '"'"', that way shellquoting will
+ * be correct when the result value is delimited using single quotes.
+ */
+ NSArray* components = [string componentsSeparatedByString:@"'"];
+
+ return [components componentsJoinedByString:@"'\"'\"'"];
+}
+
- (NSString *)commandLineForScript: (NSString *)script
{
NSString *cur_interp = NULL;
+ NSString* script_dir = NULL;
char hashbangbuf[1024];
FILE *fp;
char *p;
+
+ script_dir = [script substringToIndex:
+ [script length]-[[script lastPathComponent] length]];
if (honourhashbang &&
(fp=fopen([script cString], "r")) &&
@@ -266,8 +280,9 @@
cur_interp = interpreter;
return [NSString stringWithFormat:
- @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s",
- cur_interp,
+ @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s",
+ [self _replaceSingleQuotes:script_dir],
+ [self _replaceSingleQuotes:cur_interp],
debug?" -d":"",
verbose?" -v":"",
inspect?" -i":"",
@@ -275,7 +290,7 @@
nosite?" -S":"",
tabs?" -t":"",
others,
- script,
+ [self _replaceSingleQuotes:script],
scriptargs,
with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
}
diff --git a/Mac/Tools/fixapplepython23.py b/Mac/Tools/fixapplepython23.py
index ef352ce..fb8645a 100644
--- a/Mac/Tools/fixapplepython23.py
+++ b/Mac/Tools/fixapplepython23.py
@@ -94,9 +94,19 @@ def main():
else:
do_apply = True
# First check OS version
+ if sys.byteorder == 'little':
+ # All intel macs are fine
+ print "fixapplypython23: no fix is needed on MacOSX on Intel"
+ sys.exit(0)
+
if gestalt.gestalt('sysv') < 0x1030:
print 'fixapplepython23: no fix needed on MacOSX < 10.3'
sys.exit(0)
+
+ if gestalt.gestalt('sysv') >= 0x1040:
+ print 'fixapplepython23: no fix needed on MacOSX >= 10.4'
+ sys.exit(0)
+
# Test that a framework Python is indeed installed
if not os.path.exists(MAKEFILE):
print 'fixapplepython23: Python framework does not appear to be installed (?), nothing fixed'