@@ -146,7 +146,14 @@ def _infer_env_bin_dir_for_conda_based_installations():
146146 # Match $CONDA_PREFIX/[Ll]ib/python3.X/site-packages/khiops/core/internals/runner.py
147147 else :
148148 conda_env_dir = current_file_path .parents [6 ]
149- env_bin_dir = os .path .join (str (conda_env_dir ), "bin" )
149+
150+ # Conda env binary dir is:
151+ # - on Windows: conda_env_dir\Library\bin
152+ # - on Linux/macOS: conda_env_dir\bin
153+ if platform .system () == "Windows" :
154+ env_bin_dir = os .path .join (str (conda_env_dir ), "Library" , "bin" )
155+ else :
156+ env_bin_dir = os .path .join (str (conda_env_dir ), "bin" )
150157
151158 return env_bin_dir
152159
@@ -168,7 +175,10 @@ def _check_conda_env_bin_dir(conda_env_bin_dir):
168175
169176 # Conda env dir is not equal to its root dir
170177 # Conda env bin dir exists, along with the `conda-meta` dir
178+ # Note: On Windows, Conda env bin dir equals conda env dir\Library\bin
171179 conda_env_dir_path = conda_env_bin_dir_path .parent
180+ if platform .system () == "Windows" :
181+ conda_env_dir_path = conda_env_dir_path .parent
172182 if (
173183 str (conda_env_dir_path ) != conda_env_dir_path .root # `.root` is an `str`
174184 and conda_env_bin_dir_path .is_dir ()
@@ -180,20 +190,25 @@ def _check_conda_env_bin_dir(conda_env_bin_dir):
180190
181191def _infer_khiops_installation_method (trace = False ):
182192 """Return the Khiops installation method"""
183- # We are in a conda environment if
184- # - if the CONDA_PREFIX environment variable exists and,
185- # - if MODL, MODL_Coclustering and mpiexec files exists in
186- # `$ CONDA_PREFIX/ bin`
187- #
188- # Note: The check that MODL and MODL_Coclustering are actually executable is done
193+ # We are in a Conda environment if
194+ # - the CONDA_PREFIX environment variable exists and,
195+ # - the khiops_env script exists within:
196+ # - `% CONDA_PREFIX\Library\ bin%` on Windows
197+ # - `$CONDA_PREFIX/bin` on Linux and MacOS
198+ # Note: The check that the Khiops binaries are actually executable is done
189199 # afterwards by the initializations method.
190- # We are in a conda env if the Khiops binaries exists within `$CONDA_PREFIX/bin`
191- if "CONDA_PREFIX" in os .environ and _khiops_env_file_exists (
192- os .path .join (os .environ ["CONDA_PREFIX" ], "bin" )
193- ):
194- installation_method = "conda"
195- # Otherwise, we choose between conda-based and local (default choice)
196- else :
200+ installation_method = "unknown"
201+ if "CONDA_PREFIX" in os .environ :
202+ conda_env_dir = os .environ ["CONDA_PREFIX" ]
203+ if platform .system () == "Windows" :
204+ conda_binary_dir = os .path .join (conda_env_dir , "Library" , "bin" )
205+ else :
206+ conda_binary_dir = os .path .join (conda_env_dir , "bin" )
207+ if _khiops_env_file_exists (conda_binary_dir ):
208+ installation_method = "conda"
209+ # Otherwise (installation_method is still "unknown"), we choose between
210+ # conda-based and local (default choice)
211+ if installation_method == "unknown" :
197212 env_bin_dir = _infer_env_bin_dir_for_conda_based_installations ()
198213 if trace :
199214 print (f"Environment binary dir: '{ env_bin_dir } '" )
0 commit comments