fix conftest
@@ -169,25 +169,32 @@ def _get_tool(name, version):
# True = tool not available, test error
# (path, env) = tool available
cached = _cached_tools.setdefault(name, {}).get(version)
- if cached is None:
+ if cached is not None:
+ return cached
+ result = _get_individual_tool(name, version)
+ _cached_tools[name][version] = result
+ return result
+
+
+def _get_individual_tool(name, version):
tool = tools_locations.get(name, {})
if tool.get("disabled"):
- _cached_tools[name][version] = False
return False
tool_platform = platform.system()
if tool.get("platform", tool_platform) != tool_platform:
- _cached_tools[name][version] = None, None
return None, None
- exe = tool.get("exe", name)
version = version or tool.get("default")
tool_version = tool.get(version)
if tool_version is not None:
assert isinstance(tool_version, dict)
if tool_version.get("disabled"):
- _cached_tools[name][version] = False
return False
+ if name == "visual_studio":
+ if vswhere(): # TODO: Missing version detection
+ return None, None
+
tool_path = tool_version.get("path", {}).get(tool_platform)
# To allow to skip for a platform, we can put the path to None
# "cmake": { "3.23": {
@@ -196,12 +203,9 @@ def _get_tool(name, version):
# 'Linux': None}}
# }
if tool_path is None:
- _cached_tools[name][version] = False
return False
-
else:
if version is not None: # if the version is specified, it should be in the conf
- _cached_tools[name][version] = True
return True
tool_path = None
@@ -213,22 +217,18 @@ def _get_tool(name, version):
cached = tool_path, tool_env
# Check this particular tool is installed
- if name == "visual_studio":
- if not vswhere(): # TODO: Missing version detection
- cached = True
- else: # which based detection
old_environ = None
if tool_path is not None:
old_environ = dict(os.environ)
os.environ["PATH"] = tool_path + os.pathsep + os.environ["PATH"]
- if not which(exe): # TODO: This which doesn't detect version either
+ exe = tool.get("exe", name)
+ exe_found = which(exe) # TODO: This which doesn't detect version either
+ if not exe_found:
cached = True
if old_environ is not None:
os.environ.clear()
os.environ.update(old_environ)
- _cached_tools[name][version] = cached
-
return cached
