mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
makepanda: Stop using deprecated distutils (#1549)
Just duplicating locations.py from direct. It's a bit ugly, but makepanda is getting phased out anyways. Co-authored-by: rdb <git@rdb.name>
This commit is contained in:
parent
ad8882123b
commit
521cad206d
@ -9,9 +9,9 @@
|
|||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
import os, sys, platform
|
import os, sys, platform
|
||||||
from distutils.sysconfig import get_python_lib
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from makepandacore import *
|
from makepandacore import *
|
||||||
|
from locations import get_python_lib
|
||||||
|
|
||||||
|
|
||||||
MIME_INFO = (
|
MIME_INFO = (
|
||||||
|
32
makepanda/locations.py
Normal file
32
makepanda/locations.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
__all__ = [
|
||||||
|
'get_python_inc',
|
||||||
|
'get_config_var',
|
||||||
|
'get_python_version',
|
||||||
|
'PREFIX',
|
||||||
|
'get_python_lib',
|
||||||
|
'get_config_vars',
|
||||||
|
]
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info < (3, 12):
|
||||||
|
from distutils.sysconfig import *
|
||||||
|
else:
|
||||||
|
from sysconfig import *
|
||||||
|
|
||||||
|
PREFIX = get_config_var('prefix')
|
||||||
|
|
||||||
|
def get_python_inc(plat_specific=False):
|
||||||
|
path_name = 'platinclude' if plat_specific else 'include'
|
||||||
|
return get_path(path_name)
|
||||||
|
|
||||||
|
def get_python_lib(plat_specific=False, standard_lib=False):
|
||||||
|
if standard_lib:
|
||||||
|
path_name = 'stdlib'
|
||||||
|
if plat_specific:
|
||||||
|
path_name = 'plat' + path_name
|
||||||
|
elif plat_specific:
|
||||||
|
path_name = 'platlib'
|
||||||
|
else:
|
||||||
|
path_name = 'purelib'
|
||||||
|
return get_path(path_name)
|
@ -1032,7 +1032,7 @@ def MakeInstallerAndroid(version, **kwargs):
|
|||||||
shutil.copy(os.path.join(source_dir, base), target)
|
shutil.copy(os.path.join(source_dir, base), target)
|
||||||
|
|
||||||
# Copy the Python standard library to the .apk as well.
|
# Copy the Python standard library to the .apk as well.
|
||||||
from distutils.sysconfig import get_python_lib
|
from locations import get_python_lib
|
||||||
stdlib_source = get_python_lib(False, True)
|
stdlib_source = get_python_lib(False, True)
|
||||||
stdlib_target = os.path.join("apkroot", "lib", "python{0}.{1}".format(*sys.version_info))
|
stdlib_target = os.path.join("apkroot", "lib", "python{0}.{1}".format(*sys.version_info))
|
||||||
copy_python_tree(stdlib_source, stdlib_target)
|
copy_python_tree(stdlib_source, stdlib_target)
|
||||||
|
@ -23,11 +23,12 @@ except:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
from makepandacore import *
|
from makepandacore import *
|
||||||
from distutils.util import get_platform
|
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from sysconfig import get_platform
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
##
|
##
|
||||||
## PARSING THE COMMAND LINE OPTIONS
|
## PARSING THE COMMAND LINE OPTIONS
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import sys,os,time,stat,string,re,getopt,fnmatch,threading,signal,shutil,platform,glob,getpass,signal
|
import sys,os,time,stat,string,re,getopt,fnmatch,threading,signal,shutil,platform,glob,getpass,signal
|
||||||
import subprocess
|
import subprocess
|
||||||
from distutils import sysconfig
|
import locations
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
import pickle
|
import pickle
|
||||||
@ -2250,7 +2250,7 @@ def SdkLocatePython(prefer_thirdparty_python=False):
|
|||||||
# On macOS, search for the Python framework directory matching the
|
# On macOS, search for the Python framework directory matching the
|
||||||
# version number of our current Python version.
|
# version number of our current Python version.
|
||||||
sysroot = SDK.get("MACOSX", "")
|
sysroot = SDK.get("MACOSX", "")
|
||||||
version = sysconfig.get_python_version()
|
version = locations.get_python_version()
|
||||||
|
|
||||||
py_fwx = "{0}/System/Library/Frameworks/Python.framework/Versions/{1}".format(sysroot, version)
|
py_fwx = "{0}/System/Library/Frameworks/Python.framework/Versions/{1}".format(sysroot, version)
|
||||||
|
|
||||||
@ -2275,19 +2275,19 @@ def SdkLocatePython(prefer_thirdparty_python=False):
|
|||||||
LibDirectory("PYTHON", py_fwx + "/lib")
|
LibDirectory("PYTHON", py_fwx + "/lib")
|
||||||
|
|
||||||
#elif GetTarget() == 'windows':
|
#elif GetTarget() == 'windows':
|
||||||
# SDK["PYTHON"] = os.path.dirname(sysconfig.get_python_inc())
|
# SDK["PYTHON"] = os.path.dirname(locations.get_python_inc())
|
||||||
# SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version()
|
# SDK["PYTHONVERSION"] = "python" + locations.get_python_version()
|
||||||
# SDK["PYTHONEXEC"] = sys.executable
|
# SDK["PYTHONEXEC"] = sys.executable
|
||||||
|
|
||||||
else:
|
else:
|
||||||
SDK["PYTHON"] = sysconfig.get_python_inc()
|
SDK["PYTHON"] = locations.get_python_inc()
|
||||||
SDK["PYTHONVERSION"] = "python" + sysconfig.get_python_version() + abiflags
|
SDK["PYTHONVERSION"] = "python" + locations.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() + abiflags
|
host_version = "python" + locations.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"]))
|
||||||
|
|
||||||
@ -3514,7 +3514,7 @@ def GetExtensionSuffix():
|
|||||||
return '.so'
|
return '.so'
|
||||||
|
|
||||||
def GetPythonABI():
|
def GetPythonABI():
|
||||||
soabi = sysconfig.get_config_var('SOABI')
|
soabi = locations.get_config_var('SOABI')
|
||||||
if soabi:
|
if soabi:
|
||||||
return soabi
|
return soabi
|
||||||
|
|
||||||
@ -3523,16 +3523,16 @@ def GetPythonABI():
|
|||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
return soabi
|
return soabi
|
||||||
|
|
||||||
debug_flag = sysconfig.get_config_var('Py_DEBUG')
|
debug_flag = locations.get_config_var('Py_DEBUG')
|
||||||
if (debug_flag is None and hasattr(sys, 'gettotalrefcount')) or debug_flag:
|
if (debug_flag is None and hasattr(sys, 'gettotalrefcount')) or debug_flag:
|
||||||
soabi += 'd'
|
soabi += 'd'
|
||||||
|
|
||||||
malloc_flag = sysconfig.get_config_var('WITH_PYMALLOC')
|
malloc_flag = locations.get_config_var('WITH_PYMALLOC')
|
||||||
if malloc_flag is None or malloc_flag:
|
if malloc_flag is None or malloc_flag:
|
||||||
soabi += 'm'
|
soabi += 'm'
|
||||||
|
|
||||||
if sys.version_info < (3, 3):
|
if sys.version_info < (3, 3):
|
||||||
usize = sysconfig.get_config_var('Py_UNICODE_SIZE')
|
usize = locations.get_config_var('Py_UNICODE_SIZE')
|
||||||
if (usize is None and sys.maxunicode == 0x10ffff) or usize == 4:
|
if (usize is None and sys.maxunicode == 0x10ffff) or usize == 4:
|
||||||
soabi += 'u'
|
soabi += 'u'
|
||||||
|
|
||||||
@ -3648,14 +3648,13 @@ def GetCurrentPythonVersionInfo():
|
|||||||
if PkgSkip("PYTHON"):
|
if PkgSkip("PYTHON"):
|
||||||
return
|
return
|
||||||
|
|
||||||
from distutils.sysconfig import get_python_lib
|
|
||||||
return {
|
return {
|
||||||
"version": SDK["PYTHONVERSION"][6:].rstrip('dmu'),
|
"version": SDK["PYTHONVERSION"][6:].rstrip('dmu'),
|
||||||
"soabi": GetPythonABI(),
|
"soabi": GetPythonABI(),
|
||||||
"ext_suffix": GetExtensionSuffix(),
|
"ext_suffix": GetExtensionSuffix(),
|
||||||
"executable": sys.executable,
|
"executable": sys.executable,
|
||||||
"purelib": get_python_lib(False),
|
"purelib": locations.get_python_lib(False),
|
||||||
"platlib": get_python_lib(True),
|
"platlib": locations.get_python_lib(True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
Generates a wheel (.whl) file from the output of makepanda.
|
Generates a wheel (.whl) file from the output of makepanda.
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
from distutils.util import get_platform
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -13,10 +12,11 @@ import zipfile
|
|||||||
import hashlib
|
import hashlib
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
from distutils.sysconfig import get_config_var
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from makepandacore import ColorText, LocateBinary, GetExtensionSuffix, SetVerbose, GetVerbose, GetMetadataValue
|
from makepandacore import ColorText, LocateBinary, GetExtensionSuffix, SetVerbose, GetVerbose, GetMetadataValue
|
||||||
from base64 import urlsafe_b64encode
|
from base64 import urlsafe_b64encode
|
||||||
|
from locations import get_config_var
|
||||||
|
from sysconfig import get_platform
|
||||||
|
|
||||||
|
|
||||||
def get_abi_tag():
|
def get_abi_tag():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user