@@ -1076,12 +1076,31 @@ def _initialize_khiops_version(self):
10761076 error_msg += f"\n stderr: { stderr } " if stderr else ""
10771077 raise KhiopsRuntimeError (error_msg )
10781078
1079+ # Khiops core version
10791080 self ._khiops_version = KhiopsVersion (khiops_version_str )
10801081
1081- # Warn if the khiops version does not match the Khiops Python library version
1082- # Note: Currently the check is very strict. It may be loosened in the future
1083- # (major.minor.patch must be the same)
1082+ # Library version
10841083 compatible_khiops_version = khiops .get_compatible_khiops_version ()
1084+
1085+ operating_system = platform .system ()
1086+ installation_method = _infer_khiops_installation_method ()
1087+
1088+ # Fail immediately if the major versions differ
1089+ # Note: the installation status will not show at all
1090+ if self .khiops_version .major != compatible_khiops_version .major :
1091+ raise KhiopsRuntimeError (
1092+ f"Major version '{ self .khiops_version .major } ' of the Khiops "
1093+ "executables does not match the Khiops Python library major version "
1094+ f"'{ compatible_khiops_version .major } '. "
1095+ "To avoid any compatibility error, "
1096+ "please update either the Khiops "
1097+ f"executables package for your '{ operating_system } ' operating "
1098+ "system, or the Khiops Python library, "
1099+ f"according to your '{ installation_method } ' environment. "
1100+ "See https://khiops.org for more information." ,
1101+ )
1102+
1103+ # Warn if the khiops version does not match the Khiops Python library version
10851104 # KhiopsVersion implements the equality operator, which however also
10861105 # takes pre-release tags into account.
10871106 # The restriction here does not apply to pre-release tags
@@ -1094,8 +1113,6 @@ def _initialize_khiops_version(self):
10941113 compatible_khiops_version .minor ,
10951114 compatible_khiops_version .patch ,
10961115 ):
1097- operating_system = platform .system ()
1098- installation_method = _infer_khiops_installation_method ()
10991116 warnings .warn (
11001117 f"Version '{ self ._khiops_version } ' of the Khiops executables "
11011118 "does not match the Khiops Python library version "
@@ -1160,8 +1177,9 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11601177 f"Khiops Python library installation path '{ library_root_dir } ' "
11611178 "does not match the current Conda environment "
11621179 f"'{ os .environ ['CONDA_PREFIX' ]} '. "
1163- "Please install the Khiops Python library "
1164- "in the current Conda environment. "
1180+ "Either deactivate the current Conda environment "
1181+ "or use the Khiops Python library "
1182+ "belonging to the current Conda environment. "
11651183 "Go to https://khiops.org for instructions.\n "
11661184 )
11671185 error_list .append (error )
@@ -1172,7 +1190,7 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11721190 f"Khiops binary path '{ self .khiops_path } ' "
11731191 "does not match the current Conda environment "
11741192 f"'{ os .environ ['CONDA_PREFIX' ]} '. "
1175- "Please install the Khiops binary "
1193+ "We recommend installing the Khiops binary "
11761194 "in the current Conda environment. "
11771195 "Go to https://khiops.org for instructions.\n "
11781196 )
0 commit comments