mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
makepanda: improve Python location code on Linux and macOS, support Python 3.x builds on macOS, drop use of pythonX-config
This commit is contained in:
parent
2de6c85fc9
commit
92dab31d80
@ -840,7 +840,7 @@ if (COMPILER=="GCC"):
|
|||||||
if not RTDIST:
|
if not RTDIST:
|
||||||
# We don't link anything in the SDK with libpython.
|
# We don't link anything in the SDK with libpython.
|
||||||
python_lib = ""
|
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("OPENSSL", "openssl", ("ssl", "crypto"), ("openssl/ssl.h", "openssl/crypto.h"))
|
||||||
SmartPkgEnable("ZLIB", "zlib", ("z"), "zlib.h")
|
SmartPkgEnable("ZLIB", "zlib", ("z"), "zlib.h")
|
||||||
@ -6825,7 +6825,7 @@ deps: {DEPENDS}
|
|||||||
|
|
||||||
def MakeInstallerLinux():
|
def MakeInstallerLinux():
|
||||||
if not RUNTIME and not PkgSkip("PYTHON"):
|
if not RUNTIME and not PkgSkip("PYTHON"):
|
||||||
PYTHONV = SDK["PYTHONVERSION"]
|
PYTHONV = SDK["PYTHONVERSION"].rstrip('dmu')
|
||||||
else:
|
else:
|
||||||
PYTHONV = "python"
|
PYTHONV = "python"
|
||||||
PV = PYTHONV.replace("python", "")
|
PV = PYTHONV.replace("python", "")
|
||||||
@ -6980,8 +6980,13 @@ def MakeInstallerOSX():
|
|||||||
oscmd(cmdstr)
|
oscmd(cmdstr)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
dmg_name = "Panda3D-" + VERSION
|
||||||
|
if not SDK["PYTHONVERSION"].startswith("python2."):
|
||||||
|
dmg_name += '-py' + SDK["PYTHONVERSION"][6:9]
|
||||||
|
dmg_name += ".dmg"
|
||||||
|
|
||||||
import compileall
|
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("dstroot")): oscmd("rm -rf dstroot")
|
||||||
if (os.path.exists("Panda3D-rw.dmg")): oscmd('rm -f Panda3D-rw.dmg')
|
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)
|
oscmd("cp -R " + GetOutputDir() + "/bin/" + base + " " + binname)
|
||||||
|
|
||||||
if PkgSkip("PYTHON")==0:
|
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/usr/local/bin")
|
||||||
oscmd("mkdir -p dstroot/pythoncode/Developer/Panda3D/panda3d")
|
oscmd("mkdir -p dstroot/pythoncode/Developer/Panda3D/panda3d")
|
||||||
oscmd("mkdir -p dstroot/pythoncode/Library/Python/%s/site-packages" % PV)
|
oscmd("mkdir -p dstroot/pythoncode/Library/Python/%s/site-packages" % PV)
|
||||||
@ -7177,7 +7182,7 @@ def MakeInstallerOSX():
|
|||||||
dist.close()
|
dist.close()
|
||||||
|
|
||||||
oscmd('hdiutil create Panda3D-rw.dmg -volname "Panda3D SDK %s" -srcfolder dstroot/Panda3D' % (VERSION))
|
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')
|
oscmd('rm -f Panda3D-rw.dmg')
|
||||||
|
|
||||||
def MakeInstallerFreeBSD():
|
def MakeInstallerFreeBSD():
|
||||||
|
@ -1928,6 +1928,8 @@ def SdkLocatePython(prefer_thirdparty_python=False):
|
|||||||
SDK["PYTHONEXEC"] = os.path.realpath(sys.executable)
|
SDK["PYTHONEXEC"] = os.path.realpath(sys.executable)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
abiflags = getattr(sys, 'abiflags', '')
|
||||||
|
|
||||||
if GetTarget() == 'windows':
|
if GetTarget() == 'windows':
|
||||||
sdkdir = GetThirdpartyBase() + "/win-python"
|
sdkdir = GetThirdpartyBase() + "/win-python"
|
||||||
|
|
||||||
@ -1992,26 +1994,28 @@ def SdkLocatePython(prefer_thirdparty_python=False):
|
|||||||
SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"]
|
SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"]
|
||||||
|
|
||||||
elif GetTarget() == 'darwin':
|
elif GetTarget() == 'darwin':
|
||||||
# On Mac OS X, use the system Python framework.
|
# On macOS, search for the Python framework directory matching the
|
||||||
py_fwx = SDK.get("MACOSX", "") + "/System/Library/Frameworks/Python.framework/Versions/Current"
|
# version number of our current Python version.
|
||||||
|
sysroot = SDK.get("MACOSX", "")
|
||||||
|
version = sysconfig.get_python_version()
|
||||||
|
|
||||||
if not os.path.islink(py_fwx):
|
py_fwx = "{0}/System/Library/Frameworks/Python.framework/Versions/{1}".format(sysroot, version)
|
||||||
exit("Could not locate Python installation at %s" % (py_fwx))
|
|
||||||
|
|
||||||
ver = os.path.basename(os.readlink(py_fwx))
|
if not os.path.exists(py_fwx):
|
||||||
py_fwx = SDK.get("MACOSX", "") + "/System/Library/Frameworks/Python.framework/Versions/%s" % ver
|
# Fall back to looking on the system.
|
||||||
|
py_fwx = "/Library/Frameworks/Python.framework/Versions/" + version
|
||||||
|
|
||||||
SDK["PYTHON"] = py_fwx + "/Headers"
|
if not os.path.exists(py_fwx):
|
||||||
SDK["PYTHONVERSION"] = "python" + ver
|
exit("Could not locate Python installation at %s" % (py_fwx))
|
||||||
SDK["PYTHONEXEC"] = "/System/Library/Frameworks/Python.framework/Versions/" + ver + "/bin/python" + ver
|
|
||||||
|
|
||||||
# Avoid choosing the one in the thirdparty package dir.
|
SDK["PYTHON"] = py_fwx + "/Headers"
|
||||||
PkgSetCustomLocation("PYTHON")
|
SDK["PYTHONVERSION"] = "python" + version + abiflags
|
||||||
IncDirectory("PYTHON", py_fwx + "/include")
|
SDK["PYTHONEXEC"] = py_fwx + "/bin/python" + version
|
||||||
LibDirectory("PYTHON", "%s/usr/lib" % (SDK.get("MACOSX", "")))
|
|
||||||
|
|
||||||
if sys.version[:3] != ver:
|
# Avoid choosing the one in the thirdparty package dir.
|
||||||
print("Warning: building with Python %s instead of %s since you targeted a specific Mac OS X version." % (ver, sys.version[:3]))
|
PkgSetCustomLocation("PYTHON")
|
||||||
|
IncDirectory("PYTHON", py_fwx + "/include")
|
||||||
|
LibDirectory("PYTHON", "%s/usr/lib" % (sysroot))
|
||||||
|
|
||||||
#elif GetTarget() == 'windows':
|
#elif GetTarget() == 'windows':
|
||||||
# SDK["PYTHON"] = os.path.dirname(sysconfig.get_python_inc())
|
# SDK["PYTHON"] = os.path.dirname(sysconfig.get_python_inc())
|
||||||
@ -2020,13 +2024,13 @@ def SdkLocatePython(prefer_thirdparty_python=False):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
SDK["PYTHON"] = sysconfig.get_python_inc()
|
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)
|
SDK["PYTHONEXEC"] = os.path.realpath(sys.executable)
|
||||||
|
|
||||||
if CrossCompiling():
|
if CrossCompiling():
|
||||||
# We need a version of Python we can run.
|
# We need a version of Python we can run.
|
||||||
SDK["PYTHONEXEC"] = sys.executable
|
SDK["PYTHONEXEC"] = sys.executable
|
||||||
host_version = "python" + sysconfig.get_python_version()
|
host_version = "python" + sysconfig.get_python_version() + abiflags
|
||||||
if SDK["PYTHONVERSION"] != host_version:
|
if SDK["PYTHONVERSION"] != host_version:
|
||||||
exit("Host Python version (%s) must be the same as target Python version (%s)!" % (host_version, SDK["PYTHONVERSION"]))
|
exit("Host Python version (%s) must be the same as target Python version (%s)!" % (host_version, SDK["PYTHONVERSION"]))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user