@@ -57,6 +57,9 @@ class InstallOptions:
57
57
# Required tools
58
58
git_path : str = ''
59
59
cmake_path : str = ''
60
+ python_path : str = ''
61
+
62
+ # Test tools
60
63
java_path : str = ''
61
64
62
65
# Optional tools
@@ -121,6 +124,7 @@ class InstallOptions:
121
124
"sanitizer" : "Sanitizer to use for the build. Leave empty for no sanitizer. (ASan, UBSan, MSan, TSan)" ,
122
125
"git_path" : "Path to the git executable, if not in system PATH." ,
123
126
"cmake_path" : "Path to the cmake executable, if not in system PATH." ,
127
+ "python_path" : "Path to the python executable, if not in system PATH." ,
124
128
"java_path" : "Path to the java executable, if not in system PATH." ,
125
129
"ninja_path" : "Path to the ninja executable. Leave empty to download it automatically." ,
126
130
"mrdocs_src_dir" : "MrDocs source directory." ,
@@ -504,8 +508,11 @@ def cmake_workflow(self, src_dir, build_type, build_dir, install_dir, extra_args
504
508
config_args .extend (["-DCMAKE_C_COMPILER=" + self .options .cc ,
505
509
"-DCMAKE_CXX_COMPILER=" + self .options .cxx ])
506
510
507
- if self .is_windows ():
508
- config_args .extend (["-DPYTHON_EXECUTABLE=" + sys .executable ])
511
+ # If the cmake script happens to look for the python executable, we
512
+ # already provide it on windows because it's often not in PATH.
513
+ if self .is_windows () and self .options .python_path :
514
+ config_args .extend (["-DPYTHON_EXECUTABLE=" + self .options .python_path ])
515
+
509
516
# "OptimizedDebug" is not a valid build type. We interpret it as a special case
510
517
# where the build type is Debug and optimizations are enabled.
511
518
# This is equivalent to RelWithDebInfo on Unix, but ensures
@@ -630,7 +637,7 @@ def check_compilers(self):
630
637
raise FileNotFoundError (f"{ option } executable not found at { getattr (self .options , option )} ." )
631
638
632
639
def check_tools (self ):
633
- tools = ["git" , "cmake" ]
640
+ tools = ["git" , "cmake" , "python" ]
634
641
for tool in tools :
635
642
self .check_tool (tool )
636
643
@@ -1156,7 +1163,8 @@ def create_cmake_presets(self):
1156
1163
if cxx_flags :
1157
1164
new_preset ["cacheVariables" ]['CMAKE_CXX_FLAGS' ] = cxx_flags .strip ()
1158
1165
1159
- new_preset ["cacheVariables" ]["PYTHON_EXECUTABLE" ] = sys .executable
1166
+ if self .is_windows () and self .options .python_path :
1167
+ new_preset ["cacheVariables" ]["PYTHON_EXECUTABLE" ] = self .options .python_path
1160
1168
1161
1169
# Update cache variables path prefixes with their relative equivalents
1162
1170
mrdocs_src_dir_parent = os .path .dirname (self .options .mrdocs_src_dir )
0 commit comments