From 8054dacd54d76b0fec09ec21dee9298207223ac6 Mon Sep 17 00:00:00 2001 From: efrizal Date: Thu, 24 Nov 2022 15:14:18 +0900 Subject: [PATCH 1/3] decode bytes to str --- tools/python.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/python.py b/tools/python.py index 95ef884..ca2f0d1 100644 --- a/tools/python.py +++ b/tools/python.py @@ -42,7 +42,7 @@ def _GetPythonVersionOSX(pythonPath): # i.e. with-python=/System/Library/Frameworks/Python.framework p = subprocess.Popen("ls -l %s/Versions | grep Current" % pythonPath, shell=True, stdout=subprocess.PIPE) out, _ = p.communicate() - m = re.search(r"Current\s+->\s+(%s/Versions/)?([0-9\.]+)" % pythonPath, out) + m = re.search(r"Current\s+->\s+(%s/Versions/)?([0-9\.]+)" % pythonPath, out.decode("ascii") if sys.version_info.major >= 3 else out) if m is not None: return m.group(2) return None @@ -63,7 +63,7 @@ def _GetPythonVersionUNIX(pythonPath): # i.e. with-python=/usr/local/bin/python p = subprocess.Popen("ldd %s | grep libpython" % pythonPath, shell=True, stdout=subprocess.PIPE) out, _ = p.communicate() - m = re.search(r"libpython([0-9\.]+)\.so", out) + m = re.search(r"libpython([0-9\.]+)\.so", out.decode("ascii") if sys.version_info.major >= 3 else out) if m is not None: return m.group(1) return None From f2b130c312e47fa640bf58277ac2f8d91b5e7fcc Mon Sep 17 00:00:00 2001 From: efrizal Date: Tue, 21 Feb 2023 15:46:49 +0900 Subject: [PATCH 2/3] use list comprehension in favor for python 3 --- __init__.py | 11 +++++------ automake.py | 4 ++-- cmake.py | 4 ++-- config.py | 2 +- devtoolset.py | 14 ++++++++------ envext/automake.py | 6 +++--- envext/cmake.py | 6 +++--- tools/houdini.py | 4 ++-- tools/llvm.py | 22 ++++++++++++---------- tools/python.py | 13 +++++++++---- 10 files changed, 47 insertions(+), 39 deletions(-) diff --git a/__init__.py b/__init__.py index d222a2c..89c4be0 100644 --- a/__init__.py +++ b/__init__.py @@ -127,7 +127,7 @@ def preserve_targets(targets): if targets is not None: _targets = SCons.Script.COMMAND_LINE_TARGETS[:] if isinstance(targets, anystring): - SCons.Script.COMMAND_LINE_TARGETS = filter(lambda x: len(x)>0, map(lambda y: y.strip(), targets.split(" "))) + SCons.Script.COMMAND_LINE_TARGETS = [x.strip() for x in targets.split(" ") if len(x.strip()) > 0] else: SCons.Script.COMMAND_LINE_TARGETS = targets else: @@ -433,7 +433,7 @@ def Which(target): texp = re.compile(target) if "PATH" in os.environ: - paths = filter(lambda x: len(x) > 0, map(lambda x: x.strip(), os.environ["PATH"].split(pathsplit))) + paths = [x.strip() for x in os.environ["PATH"].split(pathsplit) if len(x.strip()) > 0] for path in paths: for item in glob(joinpath(path, "*")): if os.path.isdir(item): @@ -523,7 +523,7 @@ def SetRPath(env, settings, relpath=None, rpaths=None): rpath = "'%s'" % ":".join(all_rpaths) env.Append(LINKFLAGS=" -Wl,-rpath,%s,--enable-new-dtags" % rpath) else: - rpath = ",".join(map(lambda x: "-rpath,%s" % x, all_rpaths)) + rpath = ",".join(["-rpath,%s" % x for x in all_rpaths]) env.Append(LINKFLAGS=" -Wl,%s" % rpath) def Build32(): @@ -838,7 +838,7 @@ def NormalizedRelativePath(path, baseDirectory): return os.path.relpath(path, baseDirectory).replace("\\", "/") def NormalizedRelativePaths(paths, baseDirectory): - return map(lambda x: NormalizedRelativePath(x, baseDirectory), paths) + return [NormalizedRelativePath(x, baseDirectory) for x in paths] def MakeBaseEnv(noarch=None, output_dir="."): global bld_dir, out_dir, mode_dir, arch_dir, mscver, gccver, no_arch, warnl, ext_types @@ -1655,8 +1655,7 @@ def DeclareTargets(env, prjs): if prereqs: penv.Depends(obj, prereqs) - #progress_nodes = set(map(lambda x: abspath(str(x[0])), objs)) - progress_nodes = set(map(lambda x: abspath(str(x)), objs)) + progress_nodes = set([abspath(str(x)) for x in objs]) if alias != prj: if not alias in help_targets: diff --git a/automake.py b/automake.py index 5b817b6..e753d57 100644 --- a/automake.py +++ b/automake.py @@ -83,7 +83,7 @@ def Configure(name, topdir=None, opts=None): relpath = os.path.relpath(topdir, bld) cmd = "cd \"%s\"; %s/configure " % (bld, relpath) - for k, v in opts.iteritems(): + for k, v in excons.iteritems(opts): if type(v) == bool: if v: cmd += "%s " % k @@ -257,7 +257,7 @@ def ExternalLibRequire(configOpts, name, libnameFunc=None, definesFunc=None, ext if req is not None: defines = ("" if definesFunc is None else definesFunc(rv["static"])) if defines: - extraflags = " ".join(map(lambda x: "-D%s" % x, defines)) + extraflags = " ".join(["-D%s" % x for x in defines]) configOpts["CPPFLAGS"] = "%s %s" % (os.environ.get("CPPFLAGS", ""), extraflags) if flagName is None: diff --git a/cmake.py b/cmake.py index d1a63f2..3e66246 100644 --- a/cmake.py +++ b/cmake.py @@ -134,7 +134,7 @@ def Configure(name, topdir=None, opts=None, min_mscver=None, flags=None): cmd += flags if not flags.endswith(" "): cmd += " " - for k, v in opts.iteritems(): + for k, v in excons.iteritems(opts): cmd += "-D%s=%s " % (k, ("\"%s\"" % v if isinstance(v, excons.anystring) else v)) cmd += "-DCMAKE_INSTALL_PREFIX=\"%s\" " % excons.OutputBaseDirectory() if sys.platform != "win32": @@ -279,7 +279,7 @@ def ExternalLibRequire(configOpts, name, libnameFunc=None, definesFunc=None, ext if req is not None: defines = ("" if definesFunc is None else definesFunc(rv["static"])) if defines: - extraflags = " ".join(map(lambda x: "-D%s" % x, defines)) + extraflags = " ".join(["-D%s" % x for x in defines]) configOpts["CMAKE_CPP_FLAGS"] = "%s %s" % (configOpts.get("CMAKE_CPP_FLAGS", ""), extraflags) if varPrefix is None: diff --git a/config.py b/config.py index 5e2ac64..f9b732d 100644 --- a/config.py +++ b/config.py @@ -47,7 +47,7 @@ def HasChanged(name, opts): def Write(name, opts): with io.open(GetPath(name), "w", newline="\n", encoding="UTF-8") as f: - for k, v in opts.iteritems(): + for k, v in excons.iteritems(opts): f.write("%s %s\n" % (k, v)) f.write("\n") diff --git a/devtoolset.py b/devtoolset.py index 68c900c..bfab642 100644 --- a/devtoolset.py +++ b/devtoolset.py @@ -27,6 +27,7 @@ import re import sys import subprocess +import excons _VarsCache = {} @@ -44,20 +45,21 @@ def GetDevtoolsetEnv(toolsetver, merge=False): p = subprocess.Popen("scl enable %s env" % toolsetname, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = p.communicate() if p.returncode == 0: - lines = filter(lambda y: toolsetname in y, map(lambda x: x.strip(), out.split("\n"))) - matches = filter(lambda y: y is not None, map(lambda x: re.match("^([^=]+)=(.*)$", x), lines)) - ret = dict([(m.group(1), filter(lambda w: toolsetname in w, m.group(2).split(os.pathsep))) for m in matches]) + out_dcd = out.decode("ascii").split("\n") if sys.version_info.major > 2 else out.split("\n") + lines = [x.strip() for x in out_dcd if toolsetname in x] + matches = [re.match("^([^=]+)=(.*)$", x) for x in lines if x is not None] + ret = dict([(m.group(1), [x for x in m.group(2).split(os.pathsep) if toolsetname in x]) for m in matches]) else: print("Invalid devtoolset: %s (%s)" % (toolsetname, toolsetver)) sys.exit(1) _VarsCache[toolsetname] = ret if ret: env = {} - for k, v in ret.iteritems(): + for k, v in excons.iteritems(ret): if merge: _v = os.environ.get(k, None) if _v is not None: - vals = filter(lambda y: len(y) > 0, map(lambda x: x.strip(), _v.split(os.pathsep))) + vals = [x.strip() for x in _v.split(os.pathsep) if len(x) > 0] v.extend(vals) env[k] = os.pathsep.join(v) return env @@ -72,6 +74,6 @@ def GetGCCFullVer(toolsetver): p = subprocess.Popen(["gcc", "-dumpversion"], env=_env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = p.communicate() if p.returncode == 0: - return out.strip() + return out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip() else: return None diff --git a/envext/automake.py b/envext/automake.py index 6b180bd..d9fe326 100644 --- a/envext/automake.py +++ b/envext/automake.py @@ -115,12 +115,12 @@ def SetupEnvironment(env, settings): with io.open(cfgc, "r", encoding="UTF-8", newline="\n") as f: try: d = eval(f.read()) # pylint: disable=eval-used - for k, v in d.iteritems(): + for k, v in excons.iteritems(d): if not k in opts or opts[k] != v: doconf = True break if not doconf: - for k, v in opts.iteritems(): + for k, v in excons.iteritems(opts): if not k in d: doconf = True break @@ -158,7 +158,7 @@ def SetupEnvironment(env, settings): bins.extend(cout) expected_outputs = settings.get("automake-outputs", []) - expected_outputs = map(lambda x: (x if os.path.isabs(x) else (excons.OutputBaseDirectory() + "/" + x)), expected_outputs) + expected_outputs = [(x if os.path.isabs(x) else (excons.OutputBaseDirectory() + "/" + x)) for x in expected_outputs] actual_outputs = automake.Outputs(name) bout = list(set(actual_outputs).union(set(expected_outputs))) + [automake.OutputsCachePath(name)] diff --git a/envext/cmake.py b/envext/cmake.py index 85cb2eb..50ba9e0 100644 --- a/envext/cmake.py +++ b/envext/cmake.py @@ -90,12 +90,12 @@ def SetupEnvironment(env, settings): with io.open(cfgc, "r", encoding="UTF-8", newline="\n") as f: try: d = eval(f.read()) # pylint: disable=eval-used - for k, v in d.iteritems(): + for k, v in excons.iteritems(d): if not k in opts or opts[k] != v: doconf = True break if not doconf: - for k, v in opts.iteritems(): + for k, v in excons.iteritems(opts): if not k in d: doconf = True break @@ -121,7 +121,7 @@ def SetupEnvironment(env, settings): bins.extend(cout) expected_outputs = settings.get("cmake-outputs", []) - expected_outputs = map(lambda x: (x if os.path.isabs(x) else (excons.OutputBaseDirectory() + "/" + x)), expected_outputs) + expected_outputs = [(x if os.path.isabs(x) else (excons.OutputBaseDirectory() + "/" + x)) for x in expected_outputs] actual_outputs = cmake.Outputs(name) bout = list(set(actual_outputs).union(set(expected_outputs))) + [cmake.OutputsCachePath(name)] diff --git a/tools/houdini.py b/tools/houdini.py index bff7289..e60bfe8 100644 --- a/tools/houdini.py +++ b/tools/houdini.py @@ -195,7 +195,7 @@ def Require(env): cmd = "\"%s\" -c" % hcustom p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate() - ccflags = out.strip() + ccflags = out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip() if not "DLLEXPORT" in ccflags: if sys.platform == "win32": ccflags += ' /DDLLEXPORT="__declspec(dllexport)"' @@ -209,7 +209,7 @@ def Require(env): cmd = "\"%s\" -m" % hcustom p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate() - linkflags = out.strip() + linkflags = out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip() if sys.platform == "win32": linkflags = re.sub(r"-link\s+", "", linkflags) elif sys.platform != "darwin": diff --git a/tools/llvm.py b/tools/llvm.py index 17ff31c..9334dbc 100644 --- a/tools/llvm.py +++ b/tools/llvm.py @@ -30,7 +30,7 @@ def _CleanList(lst): - return filter(lambda x: len(x) > 0, map(lambda y: y.strip(), lst)) + return [x.strip() for x in lst if len(x.strip()) > 0] def _FlagsToList(flags): spl1 = flags.split(" ") @@ -116,7 +116,7 @@ def GetLLVMConfig(components=None): p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: - llvm_cfg["version_str"] = out.strip() + llvm_cfg["version_str"] = out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip() spl = llvm_cfg["version_str"].split(".") llvm_cfg["version_major"] = int(spl[0]) llvm_cfg["version_minor"] = int(spl[1]) @@ -130,7 +130,7 @@ def GetLLVMConfig(components=None): p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: - cppflags = out.strip() + cppflags = out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip() llvm_cfg["cppflags"] = " " + " ".join(filter(lambda x: not _IsIncludeFlag(x), _FlagsToList(cppflags))) else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") @@ -140,7 +140,7 @@ def GetLLVMConfig(components=None): p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: - cxxflags = _FlagsToList(out.strip()) + cxxflags = _FlagsToList(out.decode("ascii").strip() if sys.version_info.major > 2 else out.strip()) if sys.platform != "win32": llvm_cfg["rtti"] = (not "-fno-rtti" in cxxflags) llvm_cfg["exceptions"] = (not "-fno-exceptions" in cxxflags) @@ -160,10 +160,11 @@ def GetLLVMConfig(components=None): excons.WarnOnce("'components' should either be a string or a list of strings.", tool="llvm") p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() - if p.returncode == 0: + if p.returncode == 0: libs = [] - for l in out.split("\n"): - lst = map(_LibName, (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))) + out_dcd = out.decode("ascii").split("\n") if sys.version_info.major > 2 else out.split("\n") + for l in out_dcd: + lst = [_LibName(x) for x in (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))] libs.extend(lst) llvm_cfg["libs"] = libs else: @@ -175,8 +176,9 @@ def GetLLVMConfig(components=None): out, _ = p.communicate() if p.returncode == 0: libs = [] - for l in out.split("\n"): - lst = map(_LibName, (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))) + out_dcd = out.decode("ascii").split("\n") if sys.version_info.major > 2 else out.split("\n") + for l in out_dcd: + lst = [_LibName(x) for x in (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))] libs.extend(lst) llvm_cfg["syslibs"] = libs else: @@ -199,7 +201,7 @@ def Require(min_version=None, require_rtti=False, require_exceptions=False, comp rmaj, rmin = None, None if isinstance(min_version, excons.anystring): try: - rmaj, rmin = map(int, min_version.split(".")) + rmaj, rmin = [int(x) for x in min_version.split(".")] except Exception as e: # pylint: disable=broad-except excons.WarnOnce("Invalid version requirement '%s' (%s). Skip version check." % (min_version, e), tool="llvm") elif type(min_version) in (list, tuple): diff --git a/tools/python.py b/tools/python.py index ca2f0d1..41ffd77 100644 --- a/tools/python.py +++ b/tools/python.py @@ -63,7 +63,7 @@ def _GetPythonVersionUNIX(pythonPath): # i.e. with-python=/usr/local/bin/python p = subprocess.Popen("ldd %s | grep libpython" % pythonPath, shell=True, stdout=subprocess.PIPE) out, _ = p.communicate() - m = re.search(r"libpython([0-9\.]+)\.so", out.decode("ascii") if sys.version_info.major >= 3 else out) + m = re.search(r"libpython([0-9\.]+m?)\.so", out.decode("ascii") if sys.version_info.major >= 3 else out) if m is not None: return m.group(1) return None @@ -209,7 +209,7 @@ def _GetPythonSpec(specString): if spec is None: specErr += "\n" - excons.PrintOnce("Invalid python specification \"%s\".%sAborting build." % (specErr, specString), tool="python") + excons.PrintOnce("[1] Invalid python specification \"%s\".%sAborting build." % (specErr, specString), tool="python") sys.exit(1) # check setup validity @@ -219,24 +219,29 @@ def _GetPythonSpec(specString): if fwdir is None: # directly linking version specific framework if not os.path.isdir(incdir) or not os.path.isfile(fw): + excons.PrintOnce("Cannot find incdir '%s' or fw '%s'" % (incdir, fw), tool="python") spec = None else: if not os.path.isdir(incdir) or not os.path.isdir(fwdir): + excons.PrintOnce("Cannot find incdir '%s' or fwdir '%s'" % (incdir, fwdir), tool="python") spec = None else: ver, incdir, libdir, lib = spec if not os.path.isdir(incdir) or not os.path.isdir(libdir): + excons.PrintOnce("Cannot find incdir '%s' or libdir '%s'" % (incdir, libdir), tool="python") spec = None else: if plat == "win32": if not os.path.isfile(excons.joinpath(libdir, "%s.lib" % lib)): + excons.PrintOnce("Cannot find '%s'" % (excons.joinpath(libdir, "%s.lib" % lib)), tool="python") spec = None else: if not os.path.isfile(os.path.join(libdir, "lib%s.so" % lib)): + excons.PrintOnce("Cannot find '%s'" % os.path.join(libdir, "lib%s.so" % lib), tool="python") spec = None if spec is None: - excons.PrintOnce("Invalid python specification \"%s\". Aborting build." % specString, tool="python") + excons.PrintOnce("[2] Invalid python specification \"%s\". Aborting build." % specString, tool="python") sys.exit(1) excons.PrintOnce("Resolved python for \"%s\": %s" % (specString, ('' if spec is None else spec)), tool="python") @@ -389,7 +394,7 @@ def CythonGenerate(e, pyx, h=None, c=None, incdirs=None, cpp=False, cte=None, di cteflags = "".join([" -E %s=%s" % (k, v) for k, v in cte.items()]) dirflags = "".join([" --directive %s=%s" % (k, v) for k, v in directives.items()]) - cmd = _cython + " " + " ".join(map(lambda x: "-I %s" % x, incdirs)) + (" --cplus" if cpp else "") + cteflags + dirflags + " --embed-positions -o $TARGET $SOURCE" + cmd = _cython + " " + " ".join(["-I %s" % x for x in incdirs]) + (" --cplus" if cpp else "") + cteflags + dirflags + " --embed-positions -o $TARGET $SOURCE" # Command seems to fail if PATH and PYTHONPATH are not set ec = e.Clone() From 146c229ceb9af6d6f8c22c42d2210027e832bf26 Mon Sep 17 00:00:00 2001 From: efrizal Date: Wed, 22 Feb 2023 16:04:58 +0900 Subject: [PATCH 3/3] update minimum gcc and msc ver for maya --- tools/maya.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/maya.py b/tools/maya.py index eadbd91..b1b2fe1 100644 --- a/tools/maya.py +++ b/tools/maya.py @@ -43,13 +43,15 @@ "2018": "14.0", "2019": "14.0", "2020": "14.1", - "2022": "14.2" + "2022": "14.2", + "2023": "14.2", } _maya_gccver = { "2019": "6", "2020": "6", - "2022": "6" + "2022": "7", + "2023": "7" } def GetOptionsString():