@@ -57,6 +57,9 @@ class InstallOptions:
5757 # Required tools
5858 git_path : str = ''
5959 cmake_path : str = ''
60+ python_path : str = ''
61+
62+ # Test tools
6063 java_path : str = ''
6164
6265 # Optional tools
@@ -121,6 +124,7 @@ class InstallOptions:
121124 "sanitizer" : "Sanitizer to use for the build. Leave empty for no sanitizer. (ASan, UBSan, MSan, TSan)" ,
122125 "git_path" : "Path to the git executable, if not in system PATH." ,
123126 "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." ,
124128 "java_path" : "Path to the java executable, if not in system PATH." ,
125129 "ninja_path" : "Path to the ninja executable. Leave empty to download it automatically." ,
126130 "mrdocs_src_dir" : "MrDocs source directory." ,
@@ -504,8 +508,11 @@ def cmake_workflow(self, src_dir, build_type, build_dir, install_dir, extra_args
504508 config_args .extend (["-DCMAKE_C_COMPILER=" + self .options .cc ,
505509 "-DCMAKE_CXX_COMPILER=" + self .options .cxx ])
506510
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+
509516 # "OptimizedDebug" is not a valid build type. We interpret it as a special case
510517 # where the build type is Debug and optimizations are enabled.
511518 # This is equivalent to RelWithDebInfo on Unix, but ensures
@@ -630,7 +637,7 @@ def check_compilers(self):
630637 raise FileNotFoundError (f"{ option } executable not found at { getattr (self .options , option )} ." )
631638
632639 def check_tools (self ):
633- tools = ["git" , "cmake" ]
640+ tools = ["git" , "cmake" , "python" ]
634641 for tool in tools :
635642 self .check_tool (tool )
636643
@@ -1156,7 +1163,8 @@ def create_cmake_presets(self):
11561163 if cxx_flags :
11571164 new_preset ["cacheVariables" ]['CMAKE_CXX_FLAGS' ] = cxx_flags .strip ()
11581165
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
11601168
11611169 # Update cache variables path prefixes with their relative equivalents
11621170 mrdocs_src_dir_parent = os .path .dirname (self .options .mrdocs_src_dir )
0 commit comments