xmipp3-installer 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. xmipp3_installer/__main__.py +1 -1
  2. xmipp3_installer/api_client/api_client.py +35 -34
  3. xmipp3_installer/api_client/assembler/installation_info_assembler.py +140 -145
  4. xmipp3_installer/application/cli/arguments/__init__.py +3 -2
  5. xmipp3_installer/application/cli/arguments/modes.py +112 -95
  6. xmipp3_installer/application/cli/arguments/params.py +63 -53
  7. xmipp3_installer/application/cli/cli.py +171 -190
  8. xmipp3_installer/application/cli/parsers/base_help_formatter.py +256 -235
  9. xmipp3_installer/application/cli/parsers/error_handler_parser.py +53 -53
  10. xmipp3_installer/application/cli/parsers/format.py +22 -22
  11. xmipp3_installer/application/cli/parsers/general_help_formatter.py +102 -84
  12. xmipp3_installer/application/cli/parsers/mode_help_formatter.py +144 -105
  13. xmipp3_installer/application/logger/__init__.py +5 -0
  14. xmipp3_installer/application/logger/errors.py +8 -8
  15. xmipp3_installer/application/logger/logger.py +218 -215
  16. xmipp3_installer/application/logger/predefined_messages.py +42 -35
  17. xmipp3_installer/application/user_interactions.py +6 -0
  18. xmipp3_installer/installer/constants/paths.py +6 -1
  19. xmipp3_installer/installer/handlers/cmake/cmake_handler.py +49 -53
  20. xmipp3_installer/installer/handlers/conda_handler.py +6 -6
  21. xmipp3_installer/installer/handlers/generic_package_handler.py +9 -9
  22. xmipp3_installer/installer/handlers/git_handler.py +152 -153
  23. xmipp3_installer/installer/handlers/shell_handler.py +87 -88
  24. xmipp3_installer/installer/handlers/versions_manager.py +20 -6
  25. xmipp3_installer/installer/installer_service.py +22 -8
  26. xmipp3_installer/installer/modes/mode_all_executor.py +61 -51
  27. xmipp3_installer/installer/modes/mode_clean/mode_clean_all_executor.py +44 -36
  28. xmipp3_installer/installer/modes/mode_clean/mode_clean_bin_executor.py +84 -74
  29. xmipp3_installer/installer/modes/mode_clean/mode_clean_executor.py +48 -34
  30. xmipp3_installer/installer/modes/mode_cmake/mode_cmake_executor.py +60 -47
  31. xmipp3_installer/installer/modes/mode_cmake/mode_compile_and_install_executor.py +52 -39
  32. xmipp3_installer/installer/modes/mode_cmake/mode_config_build_executor.py +68 -49
  33. xmipp3_installer/installer/modes/mode_config_executor.py +44 -33
  34. xmipp3_installer/installer/modes/mode_executor.py +14 -13
  35. xmipp3_installer/installer/modes/mode_get_sources_executor.py +121 -112
  36. xmipp3_installer/installer/modes/mode_git_executor.py +43 -31
  37. xmipp3_installer/installer/modes/mode_selector.py +6 -0
  38. xmipp3_installer/installer/modes/mode_sync/mode_add_model_executor.py +97 -83
  39. xmipp3_installer/installer/modes/mode_sync/mode_get_models_executor.py +53 -41
  40. xmipp3_installer/installer/modes/mode_sync/mode_sync_executor.py +41 -35
  41. xmipp3_installer/installer/modes/mode_sync/mode_test_executor.py +144 -77
  42. xmipp3_installer/installer/modes/mode_version_executor.py +161 -150
  43. xmipp3_installer/installer/orquestrator.py +24 -24
  44. xmipp3_installer/installer/urls.py +4 -3
  45. xmipp3_installer/repository/config.py +225 -227
  46. xmipp3_installer/repository/config_vars/__init__.py +5 -0
  47. xmipp3_installer/repository/config_vars/config_values_adapter.py +97 -91
  48. xmipp3_installer/repository/config_vars/default_values.py +24 -24
  49. xmipp3_installer/repository/config_vars/variables.py +9 -9
  50. xmipp3_installer/repository/invalid_config_line.py +17 -0
  51. xmipp3_installer/shared/file_operations.py +14 -12
  52. xmipp3_installer/shared/singleton.py +16 -17
  53. xmipp3_installer-1.1.0.dist-info/METADATA +86 -0
  54. xmipp3_installer-1.1.0.dist-info/RECORD +70 -0
  55. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/WHEEL +1 -1
  56. xmipp3_installer-1.0.0.dist-info/METADATA +0 -729
  57. xmipp3_installer-1.0.0.dist-info/RECORD +0 -70
  58. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/entry_points.txt +0 -0
  59. /xmipp3_installer-1.0.0.dist-info/LICENSE → /xmipp3_installer-1.1.0.dist-info/licenses/LICENSE.txt +0 -0
  60. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,10 @@
1
+ """
2
+ ### Mode Clean Bin Executor Module.
3
+
4
+ This module contains the class to clean compiled binaries and related files.
5
+ """
6
+
7
+ import fnmatch
1
8
  import glob
2
9
  import os
3
10
  import pathlib
@@ -9,86 +16,89 @@ from xmipp3_installer.installer.constants import paths
9
16
  from xmipp3_installer.installer.modes.mode_clean import mode_clean_executor
10
17
 
11
18
  class ModeCleanBinExecutor(mode_clean_executor.ModeCleanExecutor):
12
- def _get_paths_to_delete(self) -> List[str]:
13
- """
14
- ### Returns a list of all the paths to be deleted.
19
+ """
20
+ ### Mode Clean Bin Executor.
15
21
 
16
- #### Returns:
17
- - (list(str)): List containing all the paths to delete.
18
- """
19
- dblite_files = glob.glob(
20
- "**/*.dblite",
21
- recursive=True
22
- )
23
- return [
24
- *dblite_files,
25
- *ModeCleanBinExecutor.__get_compilation_files(),
26
- *ModeCleanBinExecutor.__get_empty_dirs(),
27
- *ModeCleanBinExecutor.__get_pycache_dirs(),
28
- paths.BUILD_PATH
29
- ]
22
+ Cleans compiled binaries and related files.
23
+ """
30
24
 
31
- def _get_confirmation_keyword(self) -> str:
32
- """
33
- ### Returns the keyword needed to be introduced by the user to confirm an operation.
25
+ @property
26
+ def confirmation_keyword(self) -> str:
27
+ """### Property containineg the keyword to confirm the cleaning operation."""
28
+ return "y"
29
+
30
+ @staticmethod
31
+ def _get_paths_to_delete() -> List[str]:
32
+ """
33
+ ### Returns a list of all the paths to be deleted.
34
34
 
35
- #### Returns:
36
- - (str): Confirmation keyword.
37
- """
38
- return "y"
39
-
40
- def _get_confirmation_message(self) -> str:
41
- """
42
- ### Returns message to be printed when asking for user confirmation.
35
+ #### Returns:
36
+ - (list(str)): List containing all the paths to delete.
37
+ """
38
+ dblite_files = glob.glob(
39
+ "**/*.dblite",
40
+ recursive=True
41
+ )
42
+ return [
43
+ *dblite_files,
44
+ *ModeCleanBinExecutor.__get_compilation_files(),
45
+ *ModeCleanBinExecutor.__get_empty_dirs(),
46
+ *ModeCleanBinExecutor.__get_pycache_dirs(),
47
+ paths.BUILD_PATH,
48
+ paths.BINARIES_PATH
49
+ ]
50
+
51
+ def _get_confirmation_message(self) -> str:
52
+ """
53
+ ### Returns message to be printed when asking for user confirmation.
43
54
 
44
- #### Returns:
45
- - (str): Confirmation message.
46
- """
47
- return '\n'.join([
48
- logger.yellow(f"WARNING: This will DELETE from {paths.SOURCES_PATH} all *.so, *.os and *.o files. Also the *.pyc and *.dblite files"),
49
- logger.yellow(f"If you are sure you want to do this, type '{self._get_confirmation_keyword()}' (case sensitive):")
50
- ])
51
-
52
- @staticmethod
53
- def __get_compilation_files():
54
- """
55
- ### Returns a list of all the compilation-related files.
55
+ #### Returns:
56
+ - (str): Confirmation message.
57
+ """
58
+ return '\n'.join([
59
+ logger.yellow(f"WARNING: This will DELETE from {paths.SOURCES_PATH} all *.so, *.os and *.o files. Also the *.pyc and *.dblite files"),
60
+ logger.yellow(f"If you are sure you want to do this, type '{self.confirmation_keyword}' (case sensitive):")
61
+ ])
62
+
63
+ @staticmethod
64
+ def __get_compilation_files():
65
+ """
66
+ ### Returns a list of all the compilation-related files.
56
67
 
57
- #### Returns:
58
- - (list(str)): List containing all the paths to compilation-related files.
59
- """
60
- compilation_files = []
61
- for root, _, files in os.walk(paths.SOURCES_PATH):
62
- for pattern in ['*.so', '*.os', '*.o']:
63
- for filename in glob.fnmatch.filter(files, pattern):
64
- compilation_files.append(os.path.join(root, filename))
65
- return compilation_files
68
+ #### Returns:
69
+ - (list(str)): List containing all the paths to compilation-related files.
70
+ """
71
+ compilation_files = []
72
+ for root, _, files in os.walk(paths.SOURCES_PATH):
73
+ for pattern in ['*.so', '*.os', '*.o']:
74
+ for filename in fnmatch.filter(files, pattern):
75
+ compilation_files.append(os.path.join(root, filename))
76
+ return compilation_files
66
77
 
67
- @staticmethod
68
- def __get_empty_dirs() -> List[str]:
69
- """
70
- ### Returns a list with all the empty directories inside the programs folder.
78
+ @staticmethod
79
+ def __get_empty_dirs() -> List[str]:
80
+ """
81
+ ### Returns a list with all the empty directories inside the programs folder.
71
82
 
72
- #### Returns:
73
- - (list(str)): List containing the paths to all the empty directories.
74
- """
75
- empty_dirs = []
76
- for root, dirs, files in os.walk(os.path.join(
77
- paths.SOURCES_PATH, constants.XMIPP, "applications", "programs"
78
- )):
79
- if not len(dirs) and not len(files):
80
- empty_dirs.append(root)
81
- return empty_dirs
83
+ #### Returns:
84
+ - (list(str)): List containing the paths to all the empty directories.
85
+ """
86
+ empty_dirs = []
87
+ for root, dirs, files in os.walk(os.path.join(
88
+ paths.SOURCES_PATH, constants.XMIPP, "applications", "programs"
89
+ )):
90
+ if not len(dirs) and not len(files):
91
+ empty_dirs.append(root)
92
+ return empty_dirs
82
93
 
83
- @staticmethod
84
- def __get_pycache_dirs() -> List[str]:
85
- """
86
- ### Returns a list of all the __pycache__ directories.
94
+ @staticmethod
95
+ def __get_pycache_dirs() -> List[str]:
96
+ """
97
+ ### Returns a list of all the __pycache__ directories.
87
98
 
88
- #### Returns:
89
- - (list(str)): List containing all the paths to __pycache__ directories.
90
- """
91
- return [
92
- str(path) for path in pathlib.Path().rglob('__pycache__')
93
- ]
94
-
99
+ #### Returns:
100
+ - (list(str)): List containing all the paths to __pycache__ directories.
101
+ """
102
+ return [
103
+ str(path) for path in pathlib.Path().rglob('__pycache__')
104
+ ]
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Clean Executor Module.
3
+
4
+ This module contains the base class for executors that clean compiled binaries.
5
+ """
6
+
1
7
  from abc import abstractmethod
2
8
  from typing import Tuple, List
3
9
 
@@ -9,37 +15,45 @@ from xmipp3_installer.installer.modes import mode_executor
9
15
  from xmipp3_installer.shared import file_operations
10
16
 
11
17
  class ModeCleanExecutor(mode_executor.ModeExecutor):
12
- def run(self) -> Tuple[int, str]:
13
- """
14
- ### Deletes the compiled binaries.
15
-
16
- #### Returns:
17
- - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
18
- """
19
- if not self.__get_confirmation():
20
- return errors.INTERRUPTED_ERROR, ""
21
- file_operations.delete_paths(self._get_paths_to_delete())
22
- logger(predefined_messages.get_done_message())
23
- return 0, ""
24
-
25
- def __get_confirmation(self) -> bool:
26
- """
27
- ### Asks the user for confirmation.
28
-
29
- #### Returns:
30
- - (bool): True if the user confirms, False otherwise.
31
- """
32
- logger(self._get_confirmation_message())
33
- return user_interactions.get_user_confirmation(self._get_confirmation_keyword())
34
-
35
- @abstractmethod
36
- def _get_paths_to_delete(self) -> List[str]:
37
- """Get paths to delete method to be implemented by the inheriting classes."""
38
-
39
- @abstractmethod
40
- def _get_confirmation_message(self) -> str:
41
- """Get confirmation message method to be implemented by the inheriting classes."""
42
-
43
- @abstractmethod
44
- def _get_confirmation_keyword(self) -> str:
45
- """Get confirmation keyword method to be implemented by the inheriting classes."""
18
+ """
19
+ ### Mode Clean Executor.
20
+
21
+ Base class for executors that clean compiled binaries.
22
+ """
23
+
24
+ def run(self) -> Tuple[int, str]:
25
+ """
26
+ ### Deletes the compiled binaries.
27
+
28
+ #### Returns:
29
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
30
+ """
31
+ if not self.__get_confirmation():
32
+ return errors.INTERRUPTED_ERROR, ""
33
+ file_operations.delete_paths(self.__class__._get_paths_to_delete())
34
+ logger(predefined_messages.get_done_message())
35
+ return 0, ""
36
+
37
+ def __get_confirmation(self) -> bool:
38
+ """
39
+ ### Asks the user for confirmation.
40
+
41
+ #### Returns:
42
+ - (bool): True if the user confirms, False otherwise.
43
+ """
44
+ logger(self._get_confirmation_message())
45
+ return user_interactions.get_user_confirmation(self.confirmation_keyword)
46
+
47
+ @property
48
+ @abstractmethod
49
+ def confirmation_keyword(self) -> str:
50
+ """### Confirmation keyword propery to be defined by inheriting classes."""
51
+
52
+ @staticmethod
53
+ @abstractmethod
54
+ def _get_paths_to_delete() -> List[str]:
55
+ """Get paths to delete method to be implemented by the inheriting classes."""
56
+
57
+ @abstractmethod
58
+ def _get_confirmation_message(self) -> str:
59
+ """Get confirmation message method to be implemented by the inheriting classes."""
@@ -1,55 +1,68 @@
1
- import shutil
1
+ """
2
+ ### Mode CMake Executor Module.
3
+
4
+ This module contains the base class for executors that run CMake commands.
5
+ """
6
+
2
7
  from abc import abstractmethod
3
- from typing import Dict, Tuple, Optional
8
+ from typing import Dict, Optional, Tuple
4
9
 
5
10
  from xmipp3_installer.application.cli.arguments import params
6
11
  from xmipp3_installer.application.logger import errors
12
+ from xmipp3_installer.installer.handlers.cmake import cmake_handler
7
13
  from xmipp3_installer.installer.modes import mode_executor
8
14
  from xmipp3_installer.repository.config_vars import variables
9
15
 
10
16
  class ModeCMakeExecutor(mode_executor.ModeExecutor):
11
- def __init__(self, context: Dict):
12
- """
13
- ### Constructor.
14
-
15
- #### Params:
16
- - context (dict): Dictionary containing the installation context variables.
17
- """
18
- super().__init__(context)
19
- self.substitute = not context[params.PARAM_KEEP_OUTPUT]
20
- self.cmake = context[variables.CMAKE]
21
- self.build_type = context[variables.BUILD_TYPE]
22
-
23
- def run(self) -> Tuple[int, str]:
24
- """
25
- ### Runs the CMake config with the appropiate params.
26
-
27
- #### Returns:
28
- - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
29
- """
30
- cmake = self.__get_cmake_executable()
31
- if not cmake:
32
- return errors.CMAKE_ERROR, "CMake installation not found."
33
- return self._run_cmake_mode(cmake)
34
-
35
- def _set_executor_config(self):
36
- """
37
- ### Sets the specific executor params for this mode.
38
- """
39
- super()._set_executor_config()
40
- self.logs_to_file = True
41
- self.prints_with_substitution = True
42
-
43
- def __get_cmake_executable(self) -> Optional[str]:
44
- """
45
- ### Returns the path to the CMake executable to be used.
46
-
47
- #### Returns:
48
- - (str | None): Path to the CMake executable. None if it was not found.
49
- """
50
- return self.cmake or shutil.which("cmake")
51
-
52
- @abstractmethod
53
- def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
54
- """Run CMake mode method to be implemented by inheriting classes."""
55
-
17
+ """
18
+ ### Mode CMake Executor.
19
+
20
+ Base class for executors that run CMake commands.
21
+ """
22
+
23
+ def __init__(self, context: Dict):
24
+ """
25
+ ### Constructor.
26
+
27
+ #### Params:
28
+ - context (dict): Dictionary containing the installation context variables.
29
+ """
30
+ super().__init__(context)
31
+ self.substitute = not context[params.PARAM_KEEP_OUTPUT]
32
+ self.cmake = context[variables.CMAKE]
33
+ self.build_type = context[variables.BUILD_TYPE]
34
+
35
+ def run(self) -> Tuple[int, str]:
36
+ """
37
+ ### Runs the CMake config with the appropiate params.
38
+
39
+ #### Returns:
40
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
41
+ """
42
+ cmake = self.__get_cmake_executable()
43
+ if not cmake:
44
+ return errors.CMAKE_ERROR, "CMake installation not found."
45
+ return self._run_cmake_mode(cmake)
46
+
47
+ def _set_executor_config(self):
48
+ """### Sets the specific executor params for this mode."""
49
+ super()._set_executor_config()
50
+ self.logs_to_file = True
51
+ self.prints_with_substitution = True
52
+
53
+ def __get_cmake_executable(self) -> Optional[str]:
54
+ """
55
+ ### Returns the path to the CMake executable to be used.
56
+
57
+ #### Returns:
58
+ - (str | None): Path to the CMake executable. None if it was not found.
59
+ """
60
+ return self.cmake or cmake_handler.get_cmake_path()
61
+
62
+ @staticmethod
63
+ def _get_error_code(ret_code, mode_error_code):
64
+ return ret_code if ret_code == errors.INTERRUPTED_ERROR else mode_error_code
65
+
66
+ @abstractmethod
67
+ def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
68
+ """Run CMake mode method to be implemented by inheriting classes."""
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Compile And Install Executor Module.
3
+
4
+ This module contains the class to compile and install using CMake.
5
+ """
6
+
1
7
  from typing import Tuple, Dict
2
8
 
3
9
  from xmipp3_installer.application.cli.arguments import params
@@ -8,42 +14,49 @@ from xmipp3_installer.installer.handlers import shell_handler
8
14
  from xmipp3_installer.installer.modes.mode_cmake import mode_cmake_executor
9
15
 
10
16
  class ModeCompileAndInstallExecutor(mode_cmake_executor.ModeCMakeExecutor):
11
- def __init__(self, context: Dict):
12
- """
13
- ### Constructor.
14
-
15
- #### Params:
16
- - context (dict): Dictionary containing the installation context variables.
17
- """
18
- super().__init__(context)
19
- self.jobs = context[params.PARAM_JOBS]
20
-
21
- def _set_executor_config(self):
22
- """
23
- ### Sets the specific executor params for this mode.
24
- """
25
- super()._set_executor_config()
26
- self.prints_banner_on_exit = True
27
-
28
- def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
29
- """
30
- ### Runs the CMake compilation & installation with the appropiate params.
31
-
32
- #### Params:
33
- - cmake (str): Path to CMake executable.
34
-
35
- #### Returns:
36
- - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
37
- """
38
- logger(predefined_messages.get_section_message("Compiling with CMake"))
39
- cmd = f"{cmake} --build {paths.BUILD_PATH} --config {self.build_type} -j {self.jobs}"
40
- if shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute):
41
- return errors.CMAKE_COMPILE_ERROR, ""
42
-
43
- installation_section_message = predefined_messages.get_section_message("Installing with CMake")
44
- logger(f"\n{installation_section_message}")
45
- cmd = f"{cmake} --install {paths.BUILD_PATH} --config {self.build_type}"
46
- if shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute):
47
- return errors.CMAKE_INSTALL_ERROR, ""
48
- return 0, ""
49
-
17
+ """
18
+ ### Mode Compile And Install Executor.
19
+
20
+ Compiles and installs using CMake with the appropriate parameters.
21
+ """
22
+
23
+ def __init__(self, context: Dict):
24
+ """
25
+ ### Constructor.
26
+
27
+ #### Params:
28
+ - context (dict): Dictionary containing the installation context variables.
29
+ """
30
+ super().__init__(context)
31
+ self.jobs = context[params.PARAM_JOBS]
32
+
33
+ def _set_executor_config(self):
34
+ """### Sets the specific executor params for this mode."""
35
+ super()._set_executor_config()
36
+ self.prints_banner_on_exit = True
37
+
38
+ def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
39
+ """
40
+ ### Runs the CMake compilation & installation with the appropiate params.
41
+
42
+ #### Params:
43
+ - cmake (str): Path to CMake executable.
44
+
45
+ #### Returns:
46
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
47
+ """
48
+ logger(predefined_messages.get_section_message("Compiling with CMake"))
49
+ cmd = f"{cmake} --build {paths.BUILD_PATH} --config {self.build_type} -j {self.jobs}"
50
+ ret_code = shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute)
51
+ if ret_code:
52
+ return self._get_error_code(ret_code, errors.CMAKE_COMPILE_ERROR), ""
53
+ logger(predefined_messages.get_done_message(), substitute=self.substitute)
54
+
55
+ installation_section_message = predefined_messages.get_section_message("Installing with CMake")
56
+ logger(f"\n{installation_section_message}")
57
+ cmd = f"{cmake} --install {paths.BUILD_PATH} --config {self.build_type}"
58
+ ret_code = shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute)
59
+ if ret_code:
60
+ return self._get_error_code(ret_code, errors.CMAKE_INSTALL_ERROR), ""
61
+ logger(predefined_messages.get_done_message(), substitute=self.substitute)
62
+ return 0, ""
@@ -1,64 +1,83 @@
1
- from typing import Tuple, List, Optional, Union
1
+ """
2
+ ### Mode Config Build Executor Module.
2
3
 
3
- from xmipp3_installer.application.logger import predefined_messages, errors
4
+ This module contains the class to configure the build using CMake.
5
+ """
6
+
7
+ from typing import List, Optional, Tuple, Union, cast
8
+
9
+ from xmipp3_installer.application.logger import errors, predefined_messages
4
10
  from xmipp3_installer.application.logger.logger import logger
5
11
  from xmipp3_installer.installer.constants import paths
6
12
  from xmipp3_installer.installer.handlers import shell_handler
13
+ from xmipp3_installer.installer.handlers.cmake import cmake_handler
7
14
  from xmipp3_installer.installer.modes.mode_cmake import mode_cmake_executor
8
15
  from xmipp3_installer.repository.config_vars import variables
9
16
 
10
17
  class ModeConfigBuildExecutor(mode_cmake_executor.ModeCMakeExecutor):
11
- def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
12
- """
13
- ### Runs the CMake config with the appropiate params.
18
+ """
19
+ ### Mode Config Build Executor.
20
+
21
+ Configures the build using CMake with the appropriate parameters.
22
+ """
23
+
24
+ def _run_cmake_mode(self, cmake: str) -> Tuple[int, str]:
25
+ """
26
+ ### Runs the CMake config with the appropiate params.
14
27
 
15
- #### Params:
16
- - cmake (str): Path to CMake executable.
28
+ #### Params:
29
+ - cmake (str): Path to CMake executable.
17
30
 
18
- #### Returns:
19
- - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
20
- """
21
- logger(predefined_messages.get_section_message("Configuring with CMake"))
22
- cmd = f"{cmake} -S . -B {paths.BUILD_PATH} -DCMAKE_BUILD_TYPE={self.build_type} {self.__get_cmake_vars()}"
23
- if shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute):
24
- return errors.CMAKE_CONFIGURE_ERROR, ""
25
- return 0, ""
26
-
27
- def __get_cmake_vars(self) -> str:
28
- """
29
- ### Returns the CMake variables required for the configuration step.
31
+ #### Returns:
32
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
33
+ """
34
+ logger(predefined_messages.get_section_message("Configuring with CMake"))
35
+ cmd = f"{cmake} -S . -B {paths.BUILD_PATH} -DCMAKE_BUILD_TYPE={self.build_type} {self.__get_cmake_vars()}"
36
+ ret_code = shell_handler.run_shell_command_in_streaming(cmd, show_output=True, substitute=self.substitute)
37
+ if ret_code:
38
+ return self._get_error_code(ret_code, errors.CMAKE_CONFIGURE_ERROR), ""
39
+ logger(predefined_messages.get_done_message(), substitute=self.substitute)
40
+ return 0, ""
41
+
42
+ def __get_cmake_vars(self) -> str:
43
+ """
44
+ ### Returns the CMake variables required for the configuration step.
30
45
 
31
- #### Returns:
32
- - (str): String containing all required CMake variables
33
- """
34
- return " ".join([
35
- f"-D{variable_key}={self.context[variable_key]}" for variable_key
36
- in self.__get_config_vars() if not self.__is_empty(self.context[variable_key])
37
- ])
38
-
39
- def __get_config_vars(self) -> List[str]:
40
- """
41
- ### Returns all non-internal config variable keys.
46
+ #### Returns:
47
+ - (str): String containing all required CMake variables
48
+ """
49
+ non_empty_variables = [
50
+ (
51
+ variable_key,
52
+ cast(Union[str, bool], self.context[variable_key])
53
+ ) for variable_key in _get_non_internal_config_vars()
54
+ if not _is_empty(self.context[variable_key])
55
+ ]
56
+ return cmake_handler.get_cmake_params(non_empty_variables)
57
+
58
+ def _get_non_internal_config_vars() -> List[str]:
59
+ """
60
+ ### Returns all non-internal config variable keys.
42
61
 
43
- #### Returns:
44
- - (list(str)): A list containing all non-internal config variable keys.
45
- """
46
- all_config_var_keys = [
47
- config_var for variable_section in variables.CONFIG_VARIABLES.values()
48
- for config_var in variable_section
49
- ]
50
- non_internal_keys = list(set(all_config_var_keys) - set(variables.INTERNAL_LOGIC_VARS))
51
- non_internal_keys.sort() # To keep order consistency
52
- return non_internal_keys
62
+ #### Returns:
63
+ - (list(str)): A list containing all non-internal config variable keys.
64
+ """
65
+ all_config_var_keys = [
66
+ config_var for variable_section in variables.CONFIG_VARIABLES.values()
67
+ for config_var in variable_section
68
+ ]
69
+ non_internal_keys = list(set(all_config_var_keys) - set(variables.INTERNAL_LOGIC_VARS))
70
+ non_internal_keys.sort() # To keep order consistency
71
+ return non_internal_keys
53
72
 
54
- def __is_empty(self, value: Optional[Union[bool, str]]) -> bool:
55
- """
56
- ### Checks if the given config value is empty.
73
+ def _is_empty(value: Optional[Union[bool, str]]) -> bool:
74
+ """
75
+ ### Checks if the given config value is empty.
57
76
 
58
- #### Params:
59
- - value (bool | str | None): Value to be checked.
77
+ #### Params:
78
+ - value (bool | str | None): Value to be checked.
60
79
 
61
- #### Returns:
62
- - (bool): True if it is empty, False otherwise.
63
- """
64
- return value is None or value == ""
80
+ #### Returns:
81
+ - (bool): True if it is empty, False otherwise.
82
+ """
83
+ return not isinstance(value, bool) and not value