| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | import os |
| | import platform |
| | import shutil |
| |
|
| | import FreeCAD |
| |
|
| |
|
| | def get_python_exe() -> str: |
| | """Find Python. In preference order |
| | A) The value of the BaseApp/Preferences/PythonConsole/PathToPythonExecutable user preference |
| | B) The executable located in the same bin directory as FreeCAD and called "python3" |
| | C) The executable located in the same bin directory as FreeCAD and called "python" |
| | D) The result of a shutil search for your system's "python3" executable |
| | E) The result of a shutil search for your system's "python" executable""" |
| | prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/PythonConsole") |
| | python_exe = prefs.GetString("PathToPythonExecutable", "") |
| | fc_dir = FreeCAD.getHomePath() |
| | if not python_exe or not os.path.exists(python_exe): |
| | python_exe = os.path.join(fc_dir, "bin", "python3") |
| | if "Windows" in platform.system(): |
| | python_exe += ".exe" |
| |
|
| | if not python_exe or not os.path.exists(python_exe): |
| | python_exe = os.path.join(fc_dir, "bin", "python") |
| | if "Windows" in platform.system(): |
| | python_exe += ".exe" |
| |
|
| | if not python_exe or not os.path.exists(python_exe): |
| | python_exe = shutil.which("python3") |
| |
|
| | if not python_exe or not os.path.exists(python_exe): |
| | python_exe = shutil.which("python") |
| |
|
| | if not python_exe or not os.path.exists(python_exe): |
| | return "" |
| |
|
| | python_exe = python_exe.replace("/", os.path.sep) |
| | return python_exe |
| |
|