Skip to content

Commit

Permalink
WIP: Fix run_mypy on Windows via cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
LipuFei committed Jul 9, 2018
1 parent 08249a8 commit de551cc
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions run_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@
def where(exe_name: str, search_path: str = os.getenv("PATH")) -> str:
if search_path is None:
search_path = ""
paths = search_path.split(";" if sys.platform == "win32" else ":")
for path in paths:
paths = search_path.split(os.pathsep)
result = ""
print(" -> sys.executable location: %s" % sys.executable)
sys_exec_dir = os.path.dirname(sys.executable)
root_dir = os.path.dirname(sys_exec_dir)
paths += [sys_exec_dir,
os.path.join(root_dir, "bin"),
os.path.join(root_dir, "scripts"),
]
paths = set(paths)

for path in sorted(paths):
print(" -> Searching %s" % path)
candidate_path = os.path.join(path, exe_name)
if os.path.exists(candidate_path):
return candidate_path
return ""
result = candidate_path
break
return result


def findModules(path):
Expand Down Expand Up @@ -42,6 +54,8 @@ def main():
mypy_exe_name = "mypy.exe" if sys.platform == "win32" else "mypy"
mypy_exe_dir = where(mypy_exe_name)
mypy_module = os.path.join(os.path.dirname(mypy_exe_dir), mypy_exe_name)
print("Found mypy exe path: %s" % mypy_exe_dir)
print("Found mypy module path: %s" % mypy_module)

plugins = findModules("plugins")
plugins.sort()
Expand Down

0 comments on commit de551cc

Please sign in to comment.