Skip to content

Commit

Permalink
Add safeguard in `runner:_infer_env_bin_dir_for_conda_based_installat…
Browse files Browse the repository at this point in the history
…ions` for unexpected folders hierarchy
  • Loading branch information
Thierry RAMORASOAVINA committed Sep 4, 2024
1 parent 4332345 commit aca549f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions khiops/core/internals/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,17 @@ def _infer_env_bin_dir_for_conda_based_installations():
assert reference_file is not None
# Windows: Match %CONDA_PREFIX%\Lib\site-packages\khiops\__init__.py
if platform.platform() == "Windows":
conda_env_dir = Path(reference_file).parents[3]
if len(Path(reference_file).parents) >= 4:
conda_env_dir = Path(reference_file).parents[3]
else:
conda_env_dir = Path(reference_file).parents[0]
# Linux/macOS:
# Match $CONDA_PREFIX/[Ll]ib/python3.X/site-packages/khiops/__init__.py
else:
conda_env_dir = Path(reference_file).parents[4]
if len(Path(reference_file).parents) >= 5:
conda_env_dir = Path(reference_file).parents[4]
else:
conda_env_dir = Path(reference_file).parents[0]
env_bin_dir = os.path.join(conda_env_dir.as_posix(), "bin")
return env_bin_dir

Expand Down

0 comments on commit aca549f

Please sign in to comment.