From 2fcacd1bab1226ea0571c5d925daf6028a862f96 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 25 Dec 2021 11:51:10 +0100 Subject: [PATCH] makepanda: Replace references to deprecated distutils module distutils is deprecated as of Python 3.10 (see PEP 632) and will be removed in Python 3.12. --- makepanda/installpanda.py | 4 ++-- makepanda/makepackage.py | 4 ++-- makepanda/makepanda.py | 6 +++++- makepanda/makepandacore.py | 11 +++++------ makepanda/makewheel.py | 3 +-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/makepanda/installpanda.py b/makepanda/installpanda.py index fda6793375..a60ed4e66b 100644 --- a/makepanda/installpanda.py +++ b/makepanda/installpanda.py @@ -10,7 +10,7 @@ import os import sys -from distutils.sysconfig import get_python_lib +import sysconfig from optparse import OptionParser from makepandacore import * @@ -141,7 +141,7 @@ def GetLibDir(): # If Python is installed into /usr/lib64, it's probably safe # to assume that we should install there as well. - python_lib = get_python_lib(1) + python_lib = sysconfig.get_path("platlib") if python_lib.startswith('/usr/lib64/') or \ python_lib.startswith('/usr/local/lib64/'): return "lib64" diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index ef075772b3..613cbd6e07 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -6,6 +6,7 @@ import shutil import glob import re import subprocess +import sysconfig from makepandacore import * from installpanda import * @@ -910,8 +911,7 @@ def MakeInstallerAndroid(version, **kwargs): shutil.copy(os.path.join(source_dir, base), target) # Copy the Python standard library to the .apk as well. - from distutils.sysconfig import get_python_lib - stdlib_source = get_python_lib(False, True) + stdlib_source = sysconfig.get_path("stdlib") stdlib_target = os.path.join("apkroot", "lib", "python{0}.{1}".format(*sys.version_info)) copy_python_tree(stdlib_source, stdlib_target) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 71dab3f7d7..94a89519c8 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -21,6 +21,7 @@ try: import threading import signal import shutil + import sysconfig import plistlib import queue except KeyboardInterrupt: @@ -30,7 +31,10 @@ except: print("Please install the development package of Python and try again.") exit(1) -from distutils.util import get_platform +if sys.version_info >= (3, 10): + from sysconfig import get_platform +else: + from distutils.util import get_platform from makepandacore import * try: diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 9680c1c083..ab74b12352 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -6,7 +6,6 @@ ######################################################################## import configparser -from distutils import sysconfig import fnmatch import getpass import glob @@ -18,6 +17,7 @@ import shutil import signal import subprocess import sys +import sysconfig import threading import _thread as thread import time @@ -2187,12 +2187,12 @@ def SdkLocatePython(prefer_thirdparty_python=False): LibDirectory("PYTHON", py_fwx + "/lib") #elif GetTarget() == 'windows': - # SDK["PYTHON"] = os.path.dirname(sysconfig.get_python_inc()) + # SDK["PYTHON"] = os.path.dirname(sysconfig.get_path("include")) # SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version() # SDK["PYTHONEXEC"] = sys.executable else: - SDK["PYTHON"] = sysconfig.get_python_inc() + SDK["PYTHON"] = sysconfig.get_path("include") SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version() + abiflags SDK["PYTHONEXEC"] = os.path.realpath(sys.executable) @@ -3471,14 +3471,13 @@ def GetCurrentPythonVersionInfo(): if PkgSkip("PYTHON"): return - from distutils.sysconfig import get_python_lib return { "version": SDK["PYTHONVERSION"][6:].rstrip('dmu'), "soabi": GetPythonABI(), "ext_suffix": GetExtensionSuffix(), "executable": sys.executable, - "purelib": get_python_lib(False), - "platlib": get_python_lib(True), + "purelib": sysconfig.get_path("purelib"), + "platlib": sysconfig.get_path("platlib"), } diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index 65a68ec5e8..a85b8e1e27 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -11,8 +11,7 @@ import tempfile import subprocess import time import struct -from distutils.util import get_platform -from distutils.sysconfig import get_config_var +from sysconfig import get_platform, get_config_var from optparse import OptionParser from base64 import urlsafe_b64encode from makepandacore import LocateBinary, GetExtensionSuffix, SetVerbose, GetVerbose, GetMetadataValue, CrossCompiling, GetThirdpartyDir, SDK, GetStrip