makepanda: Fix various issues building with Python 3.10

This commit is contained in:
rdb 2020-09-12 22:49:46 +02:00
parent 306c0fce0f
commit 54ffc534fb
2 changed files with 26 additions and 15 deletions

View File

@ -225,10 +225,13 @@ def MakeInstallerNSIS(version, file, title, installdir, runtime=False, compresso
# Are we shipping a version of Python? # Are we shipping a version of Python?
if os.path.isfile(os.path.join(outputdir, "python", "python.exe")): if os.path.isfile(os.path.join(outputdir, "python", "python.exe")):
py_dlls = glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9].dll")) \ py_dlls = glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9].dll")) \
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9]_d.dll")) + glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9]_d.dll")) \
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9][0-9].dll")) \
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9][0-9]_d.dll"))
assert py_dlls assert py_dlls
py_dll = os.path.basename(py_dlls[0]) py_dll = os.path.basename(py_dlls[0])
pyver = py_dll[6] + "." + py_dll[7] py_dllver = py_dll.strip(".DHLNOPTY_dhlnopty")
pyver = py_dllver[0] + '.' + py_dllver[1:]
if GetTargetArch() != 'x64': if GetTargetArch() != 'x64':
pyver += '-32' pyver += '-32'
@ -864,7 +867,7 @@ def MakeInstallerFreeBSD(version, runtime=False, python_versions=[], **kwargs):
oscmd("rm -f %s/tmp/python_dep" % outputdir) oscmd("rm -f %s/tmp/python_dep" % outputdir)
if "PYTHONVERSION" in SDK: if "PYTHONVERSION" in SDK:
pyver_nodot = SDK["PYTHONVERSION"][6:9:2] pyver_nodot = SDK["PYTHONVERSION"][6:].replace('.', '')
else: else:
pyver_nodot = "%d%d" % (sys.version_info[:2]) pyver_nodot = "%d%d" % (sys.version_info[:2])

View File

@ -2169,9 +2169,11 @@ def SdkLocatePython(prefer_thirdparty_python=False):
# Determine which version it is by checking which dll is in the directory. # Determine which version it is by checking which dll is in the directory.
if (GetOptimize() <= 2): if (GetOptimize() <= 2):
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9]_d.dll") py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9]_d.dll") + \
glob.glob(SDK["PYTHON"] + "/python[0-9][0-9][0-9]_d.dll")
else: else:
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9].dll") py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9].dll") + \
glob.glob(SDK["PYTHON"] + "/python[0-9][0-9][0-9].dll")
if len(py_dlls) == 0: if len(py_dlls) == 0:
exit("Could not find the Python dll in %s." % (SDK["PYTHON"])) exit("Could not find the Python dll in %s." % (SDK["PYTHON"]))
@ -2179,24 +2181,29 @@ def SdkLocatePython(prefer_thirdparty_python=False):
exit("Found multiple Python dlls in %s." % (SDK["PYTHON"])) exit("Found multiple Python dlls in %s." % (SDK["PYTHON"]))
py_dll = os.path.basename(py_dlls[0]) py_dll = os.path.basename(py_dlls[0])
ver = py_dll[6] + "." + py_dll[7] py_dllver = py_dll.strip(".DHLNOPTY_dhlnopty")
ver = py_dllver[0] + '.' + py_dllver[1:]
SDK["PYTHONVERSION"] = "python" + ver SDK["PYTHONVERSION"] = "python" + ver
os.environ["PYTHONHOME"] = SDK["PYTHON"] os.environ["PYTHONHOME"] = SDK["PYTHON"]
if sys.version[:3] != ver: running_ver = '%d.%d' % sys.version_info[:2]
Warn("running makepanda with Python %s, but building Panda3D with Python %s." % (sys.version[:3], ver)) if ver != running_ver:
Warn("running makepanda with Python %s, but building Panda3D with Python %s." % (running_ver, ver))
elif CrossCompiling() or (prefer_thirdparty_python and os.path.isdir(os.path.join(GetThirdpartyDir(), "python"))): elif CrossCompiling() or (prefer_thirdparty_python and os.path.isdir(os.path.join(GetThirdpartyDir(), "python"))):
tp_python = os.path.join(GetThirdpartyDir(), "python") tp_python = os.path.join(GetThirdpartyDir(), "python")
if GetTarget() == 'darwin': if GetTarget() == 'darwin':
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].dylib") py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].dylib") + \
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].dylib")
else: else:
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].so") py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].so") + \
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].so")
if len(py_libs) == 0: if len(py_libs) == 0:
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].a") py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].a") + \
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].a")
if len(py_libs) == 0: if len(py_libs) == 0:
exit("Could not find the Python library in %s." % (tp_python)) exit("Could not find the Python library in %s." % (tp_python))
@ -2204,7 +2211,8 @@ def SdkLocatePython(prefer_thirdparty_python=False):
exit("Found multiple Python libraries in %s." % (tp_python)) exit("Found multiple Python libraries in %s." % (tp_python))
py_lib = os.path.basename(py_libs[0]) py_lib = os.path.basename(py_libs[0])
SDK["PYTHONVERSION"] = "python" + py_lib[9] + "." + py_lib[11] py_libver = py_lib.strip('.abdhilnopsty')
SDK["PYTHONVERSION"] = "python" + py_libver
SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"] SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"]
SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"] SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"]
@ -2250,9 +2258,9 @@ def SdkLocatePython(prefer_thirdparty_python=False):
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"]))
if GetVerbose(): if GetVerbose():
print("Using Python %s build located at %s" % (SDK["PYTHONVERSION"][6:9], SDK["PYTHON"])) print("Using Python %s build located at %s" % (SDK["PYTHONVERSION"][6:], SDK["PYTHON"]))
else: else:
print("Using Python %s" % (SDK["PYTHONVERSION"][6:9])) print("Using Python %s" % (SDK["PYTHONVERSION"][6:]))
def SdkLocateVisualStudio(version=(10,0)): def SdkLocateVisualStudio(version=(10,0)):
if (GetHost() != "windows"): return if (GetHost() != "windows"): return
@ -3578,7 +3586,7 @@ def GetCurrentPythonVersionInfo():
from distutils.sysconfig import get_python_lib from distutils.sysconfig import get_python_lib
return { return {
"version": SDK["PYTHONVERSION"][6:9], "version": SDK["PYTHONVERSION"][6:],
"soabi": GetPythonABI(), "soabi": GetPythonABI(),
"ext_suffix": GetExtensionSuffix(), "ext_suffix": GetExtensionSuffix(),
"executable": sys.executable, "executable": sys.executable,