Skip to content

Commit 54ffc53

Browse files
committed
makepanda: Fix various issues building with Python 3.10
1 parent 306c0fc commit 54ffc53

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

makepanda/makepackage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,13 @@ def MakeInstallerNSIS(version, file, title, installdir, runtime=False, compresso
225225
# Are we shipping a version of Python?
226226
if os.path.isfile(os.path.join(outputdir, "python", "python.exe")):
227227
py_dlls = glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9].dll")) \
228-
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9]_d.dll"))
228+
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9]_d.dll")) \
229+
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9][0-9].dll")) \
230+
+ glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9][0-9]_d.dll"))
229231
assert py_dlls
230232
py_dll = os.path.basename(py_dlls[0])
231-
pyver = py_dll[6] + "." + py_dll[7]
233+
py_dllver = py_dll.strip(".DHLNOPTY_dhlnopty")
234+
pyver = py_dllver[0] + '.' + py_dllver[1:]
232235

233236
if GetTargetArch() != 'x64':
234237
pyver += '-32'
@@ -864,7 +867,7 @@ def MakeInstallerFreeBSD(version, runtime=False, python_versions=[], **kwargs):
864867
oscmd("rm -f %s/tmp/python_dep" % outputdir)
865868

866869
if "PYTHONVERSION" in SDK:
867-
pyver_nodot = SDK["PYTHONVERSION"][6:9:2]
870+
pyver_nodot = SDK["PYTHONVERSION"][6:].replace('.', '')
868871
else:
869872
pyver_nodot = "%d%d" % (sys.version_info[:2])
870873

makepanda/makepandacore.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,42 +2169,50 @@ def SdkLocatePython(prefer_thirdparty_python=False):
21692169

21702170
# Determine which version it is by checking which dll is in the directory.
21712171
if (GetOptimize() <= 2):
2172-
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9]_d.dll")
2172+
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9]_d.dll") + \
2173+
glob.glob(SDK["PYTHON"] + "/python[0-9][0-9][0-9]_d.dll")
21732174
else:
2174-
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9].dll")
2175+
py_dlls = glob.glob(SDK["PYTHON"] + "/python[0-9][0-9].dll") + \
2176+
glob.glob(SDK["PYTHON"] + "/python[0-9][0-9][0-9].dll")
21752177

21762178
if len(py_dlls) == 0:
21772179
exit("Could not find the Python dll in %s." % (SDK["PYTHON"]))
21782180
elif len(py_dlls) > 1:
21792181
exit("Found multiple Python dlls in %s." % (SDK["PYTHON"]))
21802182

21812183
py_dll = os.path.basename(py_dlls[0])
2182-
ver = py_dll[6] + "." + py_dll[7]
2184+
py_dllver = py_dll.strip(".DHLNOPTY_dhlnopty")
2185+
ver = py_dllver[0] + '.' + py_dllver[1:]
21832186

21842187
SDK["PYTHONVERSION"] = "python" + ver
21852188
os.environ["PYTHONHOME"] = SDK["PYTHON"]
21862189

2187-
if sys.version[:3] != ver:
2188-
Warn("running makepanda with Python %s, but building Panda3D with Python %s." % (sys.version[:3], ver))
2190+
running_ver = '%d.%d' % sys.version_info[:2]
2191+
if ver != running_ver:
2192+
Warn("running makepanda with Python %s, but building Panda3D with Python %s." % (running_ver, ver))
21892193

21902194
elif CrossCompiling() or (prefer_thirdparty_python and os.path.isdir(os.path.join(GetThirdpartyDir(), "python"))):
21912195
tp_python = os.path.join(GetThirdpartyDir(), "python")
21922196

21932197
if GetTarget() == 'darwin':
2194-
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].dylib")
2198+
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].dylib") + \
2199+
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].dylib")
21952200
else:
2196-
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].so")
2201+
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].so") + \
2202+
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].so")
21972203

21982204
if len(py_libs) == 0:
2199-
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].a")
2205+
py_libs = glob.glob(tp_python + "/lib/libpython[0-9].[0-9].a") + \
2206+
glob.glob(tp_python + "/lib/libpython[0-9].[0-9][0-9].a")
22002207

22012208
if len(py_libs) == 0:
22022209
exit("Could not find the Python library in %s." % (tp_python))
22032210
elif len(py_libs) > 1:
22042211
exit("Found multiple Python libraries in %s." % (tp_python))
22052212

22062213
py_lib = os.path.basename(py_libs[0])
2207-
SDK["PYTHONVERSION"] = "python" + py_lib[9] + "." + py_lib[11]
2214+
py_libver = py_lib.strip('.abdhilnopsty')
2215+
SDK["PYTHONVERSION"] = "python" + py_libver
22082216
SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"]
22092217
SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"]
22102218

@@ -2250,9 +2258,9 @@ def SdkLocatePython(prefer_thirdparty_python=False):
22502258
exit("Host Python version (%s) must be the same as target Python version (%s)!" % (host_version, SDK["PYTHONVERSION"]))
22512259

22522260
if GetVerbose():
2253-
print("Using Python %s build located at %s" % (SDK["PYTHONVERSION"][6:9], SDK["PYTHON"]))
2261+
print("Using Python %s build located at %s" % (SDK["PYTHONVERSION"][6:], SDK["PYTHON"]))
22542262
else:
2255-
print("Using Python %s" % (SDK["PYTHONVERSION"][6:9]))
2263+
print("Using Python %s" % (SDK["PYTHONVERSION"][6:]))
22562264

22572265
def SdkLocateVisualStudio(version=(10,0)):
22582266
if (GetHost() != "windows"): return
@@ -3578,7 +3586,7 @@ def GetCurrentPythonVersionInfo():
35783586

35793587
from distutils.sysconfig import get_python_lib
35803588
return {
3581-
"version": SDK["PYTHONVERSION"][6:9],
3589+
"version": SDK["PYTHONVERSION"][6:],
35823590
"soabi": GetPythonABI(),
35833591
"ext_suffix": GetExtensionSuffix(),
35843592
"executable": sys.executable,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy