Fix build issues on OSX 10.6 (issue 6802)
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
index 3b31b04..6021283 100644
--- a/Lib/plat-mac/aepack.py
+++ b/Lib/plat-mac/aepack.py
@@ -58,7 +58,11 @@
# Some python types we need in the packer:
#
AEDescType = AE.AEDescType
-FSSType = Carbon.File.FSSpecType
+try:
+ FSSType = Carbon.File.FSSpecType
+except AttributeError:
+ class FSSType:
+ pass
FSRefType = Carbon.File.FSRefType
AliasType = Carbon.File.AliasType
diff --git a/Lib/plat-mac/applesingle.py b/Lib/plat-mac/applesingle.py
index f6c605f..13962f6 100644
--- a/Lib/plat-mac/applesingle.py
+++ b/Lib/plat-mac/applesingle.py
@@ -119,8 +119,13 @@
if not hasattr(infile, 'read'):
if isinstance(infile, Carbon.File.Alias):
infile = infile.ResolveAlias()[0]
- if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
- infile = infile.as_pathname()
+
+ if hasattr(Carbon.File, "FSSpec"):
+ if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
+ infile = infile.as_pathname()
+ else:
+ if isinstance(infile, Carbon.File.FSRef):
+ infile = infile.as_pathname()
infile = open(infile, 'rb')
asfile = AppleSingle(infile, verbose=verbose)
diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py
index 3480226..f137411 100644
--- a/Lib/plat-mac/buildtools.py
+++ b/Lib/plat-mac/buildtools.py
@@ -15,7 +15,10 @@
import MacOS
import macostools
import macresource
-import EasyDialogs
+try:
+ import EasyDialogs
+except ImportError:
+ EasyDialogs = None
import shutil
@@ -67,9 +70,13 @@
rsrcname=None, others=[], raw=0, progress="default", destroot=""):
if progress == "default":
- progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
- progress.label("Compiling...")
- progress.inc(0)
+ if EasyDialogs is None:
+ print "Compiling %s"%(os.path.split(filename)[1],)
+ process = None
+ else:
+ progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
+ progress.label("Compiling...")
+ progress.inc(0)
# check for the script name being longer than 32 chars. This may trigger a bug
# on OSX that can destroy your sourcefile.
if '#' in os.path.split(filename)[1]:
@@ -119,7 +126,11 @@
if MacOS.runtimemodel == 'macho':
raise BuildError, "No updating yet for MachO applets"
if progress:
- progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
+ if EasyDialogs is None:
+ print "Updating %s"%(os.path.split(filename)[1],)
+ progress = None
+ else:
+ progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
else:
progress = None
if not output:
diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py
index f02453b..d693c87 100644
--- a/Lib/plat-mac/macresource.py
+++ b/Lib/plat-mac/macresource.py
@@ -77,52 +77,38 @@
def open_pathname(pathname, verbose=0):
"""Open a resource file given by pathname, possibly decoding an
AppleSingle file"""
+ # No resource fork. We may be on OSX, and this may be either
+ # a data-fork based resource file or a AppleSingle file
+ # from the CVS repository.
try:
- refno = Res.FSpOpenResFile(pathname, 1)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
except Res.Error, arg:
- if arg[0] in (-37, -39):
- # No resource fork. We may be on OSX, and this may be either
- # a data-fork based resource file or a AppleSingle file
- # from the CVS repository.
- try:
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- except Res.Error, arg:
- if arg[0] != -199:
- # -199 is "bad resource map"
- raise
- else:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- else:
+ if arg[0] != -199:
+ # -199 is "bad resource map"
raise
- return refno
+ else:
+ return refno
+ # Finally try decoding an AppleSingle file
+ pathname = _decode(pathname, verbose=verbose)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
def resource_pathname(pathname, verbose=0):
"""Return the pathname for a resource file (either DF or RF based).
If the pathname given already refers to such a file simply return it,
otherwise first decode it."""
+ # No resource fork. We may be on OSX, and this may be either
+ # a data-fork based resource file or a AppleSingle file
+ # from the CVS repository.
try:
- refno = Res.FSpOpenResFile(pathname, 1)
- Res.CloseResFile(refno)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
except Res.Error, arg:
- if arg[0] in (-37, -39):
- # No resource fork. We may be on OSX, and this may be either
- # a data-fork based resource file or a AppleSingle file
- # from the CVS repository.
- try:
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- except Res.Error, arg:
- if arg[0] != -199:
- # -199 is "bad resource map"
- raise
- else:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- else:
+ if arg[0] != -199:
+ # -199 is "bad resource map"
raise
+ else:
+ return refno
+ # Finally try decoding an AppleSingle file
+ pathname = _decode(pathname, verbose=verbose)
return pathname
def open_error_resource():
diff --git a/Lib/test/test_aepack.py b/Lib/test/test_aepack.py
index 5d4ab3e..f4ea25b 100755
--- a/Lib/test/test_aepack.py
+++ b/Lib/test/test_aepack.py
@@ -60,6 +60,9 @@
import Carbon.File
except:
return
+
+ if not hasattr(Carbon.File, "FSSpec"):
+ return
o = Carbon.File.FSSpec(os.curdir)
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
@@ -70,6 +73,8 @@
import Carbon.File
except:
return
+ if not hasattr(Carbon.File, "FSSpec"):
+ return
o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)