Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions automake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
14 changes: 8 additions & 6 deletions devtoolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import re
import sys
import subprocess
import excons


_VarsCache = {}
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions envext/automake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]

Expand Down
6 changes: 3 additions & 3 deletions envext/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)]

Expand Down
4 changes: 2 additions & 2 deletions tools/houdini.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"'
Expand All @@ -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":
Expand Down
22 changes: 12 additions & 10 deletions tools/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ")
Expand Down Expand Up @@ -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])
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions tools/maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
15 changes: 10 additions & 5 deletions tools/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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\.]+m?)\.so", out.decode("ascii") if sys.version_info.major >= 3 else out)
if m is not None:
return m.group(1)
return None
Expand Down Expand Up @@ -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
Expand All @@ -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, ('<current>' if spec is None else spec)), tool="python")
Expand Down Expand Up @@ -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()
Expand Down