@@ -542,14 +542,14 @@ def _build_status_message(self):
542542 assert (
543543 os .path .basename (Path (__file__ ).parents [2 ]) == "khiops"
544544 ), "Please fix the `Path.parents` in this method "
545- library_root_dir = Path (__file__ ).parents [2 ]
545+ library_root_dir_path = Path (__file__ ).parents [2 ]
546546
547547 status_msg = "Khiops Python library settings\n "
548548 status_msg += f"version : { khiops .__version__ } \n "
549549 status_msg += f"runner class : { self .__class__ .__name__ } \n "
550550 status_msg += f"root temp dir : { self .root_temp_dir } \n "
551551 status_msg += f"sample datasets dir : { samples_dir_path } \n "
552- status_msg += f"library root dir : { library_root_dir } \n "
552+ status_msg += f"library root dir : { library_root_dir_path } \n "
553553
554554 error_list = []
555555
@@ -1127,7 +1127,7 @@ def _initialize_khiops_version(self):
11271127 stacklevel = 3 ,
11281128 )
11291129
1130- def _detect_library_installation_incompatibilities (self , library_root_dir ):
1130+ def _detect_library_installation_incompatibilities (self , library_root_dir_path ):
11311131 """Detects known incompatible installations of this library
11321132 in the 3 installation modes see `_infer_khiops_installation_method`
11331133 (binary+pip, conda, conda-based)
@@ -1137,7 +1137,7 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11371137
11381138 Parameters
11391139 ----------
1140- library_root_dir : PosixPath
1140+ library_root_dir_path : PosixPath
11411141 path to this current library
11421142
11431143
@@ -1172,10 +1172,18 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11721172 )
11731173 warning_list .append (warning )
11741174
1175+ # Store in separate variable(s) to abstract over the path casing on Windows
1176+ library_root_dir = str (library_root_dir_path )
1177+ conda_prefix = os .environ ["CONDA_PREFIX" ]
1178+ if platform .system () == "Windows" :
1179+ # warning : paths are case-insensitive under Windows
1180+ library_root_dir = library_root_dir .lower ()
1181+ conda_prefix = conda_prefix .lower ()
11751182 # the conda environment must match the library installation
1176- if not str ( library_root_dir ) .startswith (os . environ [ "CONDA_PREFIX" ] ):
1183+ if not library_root_dir .startswith (conda_prefix ):
11771184 error = (
1178- f"Khiops Python library installation path '{ library_root_dir } ' "
1185+ f"Khiops Python library installation "
1186+ f"path '{ library_root_dir_path } ' "
11791187 "does not match the current Conda environment "
11801188 f"'{ os .environ ['CONDA_PREFIX' ]} '. "
11811189 "Either deactivate the current Conda environment "
@@ -1184,9 +1192,14 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11841192 "Go to https://khiops.org for instructions.\n "
11851193 )
11861194 error_list .append (error )
1195+ # Store in separate variable to abstract over the path casing on Windows
1196+ khiops_path = self .khiops_path
1197+ if platform .system () == "Windows" :
1198+ # warning : paths are case-insensitive under Windows
1199+ khiops_path = khiops_path .lower ()
11871200 # the khiops executable path must also match the conda environment one
11881201 # meaning khiops core was installed using conda
1189- if not self . khiops_path .startswith (os . environ [ "CONDA_PREFIX" ] ):
1202+ if not khiops_path .startswith (conda_prefix ):
11901203 error = (
11911204 f"Khiops binary path '{ self .khiops_path } ' "
11921205 "does not match the current Conda environment "
@@ -1226,11 +1239,19 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
12261239 # no further check cannot be performed)
12271240 base_dir = _infer_base_dir_for_conda_based_or_pip_installations ()
12281241 if len (base_dir ) > 0 :
1242+ # Store in separate variable(s) to abstract over
1243+ # the path casing on Windows
1244+ base_prefix = sys .base_prefix
1245+ sys_prefix = sys .prefix
1246+ if platform .system () == "Windows" :
1247+ # warning : paths are case-insensitive under Windows
1248+ base_prefix = base_prefix .lower ()
1249+ sys_prefix = sys_prefix .lower ()
12291250 # within a virtual env, sys.prefix is set to the virtual env folder
12301251 # whereas sys.base_prefix remains unchanged.
12311252 # Please be aware that if a python executable of a virtual env is used
12321253 # the corresponding virtual env is activated and sys.prefix updated
1233- if sys . base_prefix != sys . prefix :
1254+ if base_prefix != sys_prefix :
12341255 # the python executable location
12351256 # (within the virtual env or the conda-based env)
12361257 # must match the library installation
@@ -1240,18 +1261,22 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
12401261 # Under Windows, there are two cases :
12411262 (
12421263 # for conda-based installations python is inside 'base_dir'
1243- str (Path (sys .executable ).parents [0 ]) != base_dir
1264+ # warning : paths are case-insensitive under Windows
1265+ str (Path (sys .executable .lower ()).parents [0 ])
1266+ != base_dir .lower ()
12441267 and
12451268 # for 'binary+pip' installations (within a virtual env)
12461269 # python is inside 'base_dir'/Scripts
1247- str (Path (sys .executable ).parents [1 ]) != base_dir
1270+ # warning : paths are case-insensitive under Windows
1271+ str (Path (sys .executable .lower ()).parents [1 ])
1272+ != base_dir .lower ()
12481273 )
12491274 # Under Linux or MacOS a bin/ folder exists
12501275 or str (Path (sys .executable ).parents [1 ]) != base_dir
12511276 ):
12521277 error = (
12531278 "Khiops Python library installation path "
1254- f"'{ library_root_dir } ' "
1279+ f"'{ library_root_dir_path } ' "
12551280 "does not match the current python environment "
12561281 f"('{ sys .executable } '). "
12571282 "Go to https://khiops.org for instructions "
@@ -1260,14 +1285,22 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
12601285 )
12611286 error_list .append (error )
12621287 else :
1288+ # Store in separate variable(s) to abstract
1289+ # over the path casing on Windows
1290+ sys_executable = sys .executable
1291+ base_prefix = sys .base_prefix
1292+ if platform .system () == "Windows" :
1293+ # warning : paths are case-insensitive under Windows
1294+ sys_executable = sys_executable .lower ()
1295+ base_prefix = base_prefix .lower ()
12631296 # the installation is not within a virtual env
12641297 # (sys.base_prefix == sys.prefix)
1265- if not sys . executable . startswith (sys . base_prefix ):
1298+ if not sys_executable . startswith (base_prefix ):
12661299 # the executable is not the expected one
12671300 # (the system-wide python)
12681301 error = (
12691302 "Khiops Python library installed in "
1270- f"'{ library_root_dir } ' "
1303+ f"'{ library_root_dir_path } ' "
12711304 "is run with an unexpected executable "
12721305 f"'{ sys .executable } '. "
12731306 "The system-wide python located in "
@@ -1281,14 +1314,19 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
12811314 # fetch the 'User site' site-packages path
12821315 # which is already adapted for each OS (Windows, MacOS, Linux)
12831316 user_site_packages_dir = site .getusersitepackages ()
1284- if not str (library_root_dir ).startswith (user_site_packages_dir ):
1317+ library_root_dir = str (library_root_dir_path )
1318+ if platform .system () == "Windows" :
1319+ # warning : paths are case-insensitive under Windows
1320+ library_root_dir = library_root_dir .lower ()
1321+ user_site_packages_dir = user_site_packages_dir .lower ()
1322+ if not library_root_dir .startswith (user_site_packages_dir ):
12851323 # the library is not installed on the 'User site'
1286- if not str ( library_root_dir ) .startswith (sys . base_prefix ):
1324+ if not library_root_dir .startswith (base_prefix ):
12871325 # the library is supposed to be installed system-wide,
12881326 # but it seems that the location is wrong
12891327 error = (
12901328 "Khiops Python library installation path "
1291- f"'{ library_root_dir } ' "
1329+ f"'{ library_root_dir_path } ' "
12921330 "does not match the system-wide Python prefix in "
12931331 f"'{ sys .base_prefix } '. "
12941332 "Go to https://khiops.org for instructions "
@@ -1303,10 +1341,10 @@ def _build_status_message(self):
13031341 # Call the parent's method
13041342 status_msg , error_list , warning_list = super ()._build_status_message ()
13051343
1306- library_root_dir = Path (__file__ ).parents [2 ]
1344+ library_root_dir_path = Path (__file__ ).parents [2 ]
13071345
13081346 installation_errors , installation_warnings = (
1309- self ._detect_library_installation_incompatibilities (library_root_dir )
1347+ self ._detect_library_installation_incompatibilities (library_root_dir_path )
13101348 )
13111349
13121350 # Build the messages for install type and mpi
0 commit comments