Fix Mac OS X Snow Leopard build

This commit is contained in:
rdb 2016-12-05 16:30:44 -05:00
parent 46c8990f40
commit 83507e413f
3 changed files with 42 additions and 2 deletions

View File

@ -38,7 +38,6 @@ import os
import sys
import random
import time
import importlib
__report_indent = 3
@ -61,6 +60,42 @@ def Functor(function, *args, **kArgs):
return functor
"""
try:
import importlib
except ImportError:
# Backward compatibility for Python 2.6.
def _resolve_name(name, package, level):
if not hasattr(package, 'rindex'):
raise ValueError("'package' not set to a string")
dot = len(package)
for x in xrange(level, 1, -1):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
raise ValueError("attempted relative import beyond top-level "
"package")
return "%s.%s" % (package[:dot], name)
def import_module(name, package=None):
if name.startswith('.'):
if not package:
raise TypeError("relative imports require the 'package' argument")
level = 0
for character in name:
if character != '.':
break
level += 1
name = _resolve_name(name[level:], package, level)
__import__(name)
return sys.modules[name]
imp = import_module('imp')
importlib = imp.new_module("importlib")
importlib._resolve_name = _resolve_name
importlib.import_module = import_module
sys.modules['importlib'] = importlib
class Functor:
def __init__(self, function, *args, **kargs):
assert callable(function), "function should be a callable obj"

View File

@ -4599,7 +4599,7 @@ if (GetTarget() == 'darwin' and PkgSkip("COCOA")==0 and PkgSkip("GL")==0 and not
if (PkgSkip('PANDAFX')==0):
TargetAdd('libpandagl.dll', input='libpandafx.dll')
TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'COCOA'])
TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'COCOA', 'CARBON'])
#
# DIRECTORY: panda/src/osxdisplay/

View File

@ -2002,6 +2002,11 @@ def SdkLocatePython(prefer_thirdparty_python=False):
SDK["PYTHONVERSION"] = "python" + ver
SDK["PYTHONEXEC"] = "/System/Library/Frameworks/Python.framework/Versions/" + ver + "/bin/python" + ver
# Avoid choosing the one in the thirdparty package dir.
PkgSetCustomLocation("PYTHON")
IncDirectory("PYTHON", py_fwx + "/include")
LibDirectory("PYTHON", "%s/usr/lib" % (SDK.get("MACOSX", "")))
if sys.version[:3] != ver:
print("Warning: building with Python %s instead of %s since you targeted a specific Mac OS X version." % (ver, sys.version[:3]))