diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5798259328..564ee8e4e9 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -840,7 +840,7 @@ if (COMPILER=="GCC"): if not RTDIST: # We don't link anything in the SDK with libpython. python_lib = "" - SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"), tool = SDK["PYTHONVERSION"] + "-config") + SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h")) SmartPkgEnable("OPENSSL", "openssl", ("ssl", "crypto"), ("openssl/ssl.h", "openssl/crypto.h")) SmartPkgEnable("ZLIB", "zlib", ("z"), "zlib.h") @@ -6825,7 +6825,7 @@ deps: {DEPENDS} def MakeInstallerLinux(): if not RUNTIME and not PkgSkip("PYTHON"): - PYTHONV = SDK["PYTHONVERSION"] + PYTHONV = SDK["PYTHONVERSION"].rstrip('dmu') else: PYTHONV = "python" PV = PYTHONV.replace("python", "") @@ -6980,8 +6980,13 @@ def MakeInstallerOSX(): oscmd(cmdstr) return + dmg_name = "Panda3D-" + VERSION + if not SDK["PYTHONVERSION"].startswith("python2."): + dmg_name += '-py' + SDK["PYTHONVERSION"][6:9] + dmg_name += ".dmg" + import compileall - if (os.path.isfile("Panda3D-%s.dmg" % VERSION)): oscmd("rm -f Panda3D-%s.dmg" % VERSION) + if (os.path.isfile(dmg_name)): oscmd("rm -f %s" % dmg_name) if (os.path.exists("dstroot")): oscmd("rm -rf dstroot") if (os.path.exists("Panda3D-rw.dmg")): oscmd('rm -f Panda3D-rw.dmg') @@ -7022,7 +7027,7 @@ def MakeInstallerOSX(): oscmd("cp -R " + GetOutputDir() + "/bin/" + base + " " + binname) if PkgSkip("PYTHON")==0: - PV = SDK["PYTHONVERSION"].replace("python", "") + PV = SDK["PYTHONVERSION"][6:9] oscmd("mkdir -p dstroot/pythoncode/usr/local/bin") oscmd("mkdir -p dstroot/pythoncode/Developer/Panda3D/panda3d") oscmd("mkdir -p dstroot/pythoncode/Library/Python/%s/site-packages" % PV) @@ -7177,7 +7182,7 @@ def MakeInstallerOSX(): dist.close() oscmd('hdiutil create Panda3D-rw.dmg -volname "Panda3D SDK %s" -srcfolder dstroot/Panda3D' % (VERSION)) - oscmd('hdiutil convert Panda3D-rw.dmg -format UDBZ -o Panda3D-%s.dmg' % (VERSION)) + oscmd('hdiutil convert Panda3D-rw.dmg -format UDBZ -o %s' % (dmg_name)) oscmd('rm -f Panda3D-rw.dmg') def MakeInstallerFreeBSD(): diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 24f3614337..60b38927d4 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1928,6 +1928,8 @@ def SdkLocatePython(prefer_thirdparty_python=False): SDK["PYTHONEXEC"] = os.path.realpath(sys.executable) return + abiflags = getattr(sys, 'abiflags', '') + if GetTarget() == 'windows': sdkdir = GetThirdpartyBase() + "/win-python" @@ -1992,26 +1994,28 @@ def SdkLocatePython(prefer_thirdparty_python=False): SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"] elif GetTarget() == 'darwin': - # On Mac OS X, use the system Python framework. - py_fwx = SDK.get("MACOSX", "") + "/System/Library/Frameworks/Python.framework/Versions/Current" + # On macOS, search for the Python framework directory matching the + # version number of our current Python version. + sysroot = SDK.get("MACOSX", "") + version = sysconfig.get_python_version() - if not os.path.islink(py_fwx): - exit("Could not locate Python installation at %s" % (py_fwx)) + py_fwx = "{0}/System/Library/Frameworks/Python.framework/Versions/{1}".format(sysroot, version) - ver = os.path.basename(os.readlink(py_fwx)) - py_fwx = SDK.get("MACOSX", "") + "/System/Library/Frameworks/Python.framework/Versions/%s" % ver + if not os.path.exists(py_fwx): + # Fall back to looking on the system. + py_fwx = "/Library/Frameworks/Python.framework/Versions/" + version - SDK["PYTHON"] = py_fwx + "/Headers" - SDK["PYTHONVERSION"] = "python" + ver - SDK["PYTHONEXEC"] = "/System/Library/Frameworks/Python.framework/Versions/" + ver + "/bin/python" + ver + if not os.path.exists(py_fwx): + exit("Could not locate Python installation at %s" % (py_fwx)) - # Avoid choosing the one in the thirdparty package dir. - PkgSetCustomLocation("PYTHON") - IncDirectory("PYTHON", py_fwx + "/include") - LibDirectory("PYTHON", "%s/usr/lib" % (SDK.get("MACOSX", ""))) + SDK["PYTHON"] = py_fwx + "/Headers" + SDK["PYTHONVERSION"] = "python" + version + abiflags + SDK["PYTHONEXEC"] = py_fwx + "/bin/python" + version - 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])) + # Avoid choosing the one in the thirdparty package dir. + PkgSetCustomLocation("PYTHON") + IncDirectory("PYTHON", py_fwx + "/include") + LibDirectory("PYTHON", "%s/usr/lib" % (sysroot)) #elif GetTarget() == 'windows': # SDK["PYTHON"] = os.path.dirname(sysconfig.get_python_inc()) @@ -2020,13 +2024,13 @@ def SdkLocatePython(prefer_thirdparty_python=False): else: SDK["PYTHON"] = sysconfig.get_python_inc() - SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version() + SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version() + abiflags SDK["PYTHONEXEC"] = os.path.realpath(sys.executable) if CrossCompiling(): # We need a version of Python we can run. SDK["PYTHONEXEC"] = sys.executable - host_version = "python" + sysconfig.get_python_version() + host_version = "python" + sysconfig.get_python_version() + abiflags if SDK["PYTHONVERSION"] != host_version: exit("Host Python version (%s) must be the same as target Python version (%s)!" % (host_version, SDK["PYTHONVERSION"]))