xmipp3-installer 1.0.1__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.
- xmipp3_installer/__main__.py +1 -1
- xmipp3_installer/api_client/api_client.py +35 -34
- xmipp3_installer/api_client/assembler/installation_info_assembler.py +140 -145
- xmipp3_installer/application/cli/arguments/__init__.py +3 -2
- xmipp3_installer/application/cli/arguments/modes.py +112 -95
- xmipp3_installer/application/cli/arguments/params.py +63 -53
- xmipp3_installer/application/cli/cli.py +171 -190
- xmipp3_installer/application/cli/parsers/base_help_formatter.py +256 -235
- xmipp3_installer/application/cli/parsers/error_handler_parser.py +53 -53
- xmipp3_installer/application/cli/parsers/format.py +22 -22
- xmipp3_installer/application/cli/parsers/general_help_formatter.py +102 -84
- xmipp3_installer/application/cli/parsers/mode_help_formatter.py +144 -105
- xmipp3_installer/application/logger/__init__.py +5 -0
- xmipp3_installer/application/logger/errors.py +8 -8
- xmipp3_installer/application/logger/logger.py +218 -215
- xmipp3_installer/application/logger/predefined_messages.py +42 -35
- xmipp3_installer/application/user_interactions.py +6 -0
- xmipp3_installer/installer/constants/paths.py +6 -0
- xmipp3_installer/installer/handlers/cmake/cmake_handler.py +49 -53
- xmipp3_installer/installer/handlers/conda_handler.py +6 -6
- xmipp3_installer/installer/handlers/generic_package_handler.py +9 -9
- xmipp3_installer/installer/handlers/git_handler.py +152 -153
- xmipp3_installer/installer/handlers/shell_handler.py +87 -88
- xmipp3_installer/installer/handlers/versions_manager.py +20 -6
- xmipp3_installer/installer/installer_service.py +22 -8
- xmipp3_installer/installer/modes/mode_all_executor.py +61 -51
- xmipp3_installer/installer/modes/mode_clean/mode_clean_all_executor.py +44 -36
- xmipp3_installer/installer/modes/mode_clean/mode_clean_bin_executor.py +84 -74
- xmipp3_installer/installer/modes/mode_clean/mode_clean_executor.py +48 -34
- xmipp3_installer/installer/modes/mode_cmake/mode_cmake_executor.py +60 -47
- xmipp3_installer/installer/modes/mode_cmake/mode_compile_and_install_executor.py +52 -39
- xmipp3_installer/installer/modes/mode_cmake/mode_config_build_executor.py +68 -49
- xmipp3_installer/installer/modes/mode_config_executor.py +44 -33
- xmipp3_installer/installer/modes/mode_executor.py +14 -13
- xmipp3_installer/installer/modes/mode_get_sources_executor.py +121 -112
- xmipp3_installer/installer/modes/mode_git_executor.py +43 -31
- xmipp3_installer/installer/modes/mode_selector.py +6 -0
- xmipp3_installer/installer/modes/mode_sync/mode_add_model_executor.py +97 -83
- xmipp3_installer/installer/modes/mode_sync/mode_get_models_executor.py +53 -41
- xmipp3_installer/installer/modes/mode_sync/mode_sync_executor.py +41 -35
- xmipp3_installer/installer/modes/mode_sync/mode_test_executor.py +144 -77
- xmipp3_installer/installer/modes/mode_version_executor.py +161 -150
- xmipp3_installer/installer/orquestrator.py +24 -24
- xmipp3_installer/installer/urls.py +4 -3
- xmipp3_installer/repository/config.py +225 -227
- xmipp3_installer/repository/config_vars/__init__.py +5 -0
- xmipp3_installer/repository/config_vars/config_values_adapter.py +97 -91
- xmipp3_installer/repository/config_vars/default_values.py +24 -24
- xmipp3_installer/repository/config_vars/variables.py +9 -9
- xmipp3_installer/repository/invalid_config_line.py +17 -0
- xmipp3_installer/shared/file_operations.py +14 -12
- xmipp3_installer/shared/singleton.py +16 -17
- xmipp3_installer-1.1.0.dist-info/METADATA +86 -0
- xmipp3_installer-1.1.0.dist-info/RECORD +70 -0
- {xmipp3_installer-1.0.1.dist-info → xmipp3_installer-1.1.0.dist-info}/WHEEL +1 -1
- xmipp3_installer-1.0.1.dist-info/METADATA +0 -729
- xmipp3_installer-1.0.1.dist-info/RECORD +0 -70
- {xmipp3_installer-1.0.1.dist-info → xmipp3_installer-1.1.0.dist-info}/entry_points.txt +0 -0
- /xmipp3_installer-1.0.1.dist-info/LICENSE → /xmipp3_installer-1.1.0.dist-info/licenses/LICENSE.txt +0 -0
- {xmipp3_installer-1.0.1.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
|
-
|
|
13
|
-
|
|
14
|
-
### Returns a list of all the paths to be deleted.
|
|
19
|
+
"""
|
|
20
|
+
### Mode Clean Bin Executor.
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
@staticmethod
|
|
95
|
+
def __get_pycache_dirs() -> List[str]:
|
|
96
|
+
"""
|
|
97
|
+
### Returns a list of all the __pycache__ directories.
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
1
|
+
"""
|
|
2
|
+
### Mode Config Build Executor Module.
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
28
|
+
#### Params:
|
|
29
|
+
- cmake (str): Path to CMake executable.
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
def _is_empty(value: Optional[Union[bool, str]]) -> bool:
|
|
74
|
+
"""
|
|
75
|
+
### Checks if the given config value is empty.
|
|
57
76
|
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
#### Params:
|
|
78
|
+
- value (bool | str | None): Value to be checked.
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
#### Returns:
|
|
81
|
+
- (bool): True if it is empty, False otherwise.
|
|
82
|
+
"""
|
|
83
|
+
return not isinstance(value, bool) and not value
|