mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
WIP: Fix run_mypy on Windows via cmake
This commit is contained in:
parent
08249a8b06
commit
de551ccf51
1 changed files with 18 additions and 4 deletions
22
run_mypy.py
22
run_mypy.py
|
|
@ -8,12 +8,24 @@ import subprocess
|
||||||
def where(exe_name: str, search_path: str = os.getenv("PATH")) -> str:
|
def where(exe_name: str, search_path: str = os.getenv("PATH")) -> str:
|
||||||
if search_path is None:
|
if search_path is None:
|
||||||
search_path = ""
|
search_path = ""
|
||||||
paths = search_path.split(";" if sys.platform == "win32" else ":")
|
paths = search_path.split(os.pathsep)
|
||||||
for path in paths:
|
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)
|
candidate_path = os.path.join(path, exe_name)
|
||||||
if os.path.exists(candidate_path):
|
if os.path.exists(candidate_path):
|
||||||
return candidate_path
|
result = candidate_path
|
||||||
return ""
|
break
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def findModules(path):
|
def findModules(path):
|
||||||
|
|
@ -42,6 +54,8 @@ def main():
|
||||||
mypy_exe_name = "mypy.exe" if sys.platform == "win32" else "mypy"
|
mypy_exe_name = "mypy.exe" if sys.platform == "win32" else "mypy"
|
||||||
mypy_exe_dir = where(mypy_exe_name)
|
mypy_exe_dir = where(mypy_exe_name)
|
||||||
mypy_module = os.path.join(os.path.dirname(mypy_exe_dir), 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 = findModules("plugins")
|
||||||
plugins.sort()
|
plugins.sort()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue