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,9 @@
1
+ """
2
+ ### Mode Config Executor Module.
3
+
4
+ This module contains the class to manage the configuration file.
5
+ """
6
+
1
7
  import os
2
8
  from typing import Dict, Tuple
3
9
 
@@ -10,37 +16,42 @@ from xmipp3_installer.installer.modes import mode_executor
10
16
  from xmipp3_installer.repository import config
11
17
 
12
18
  class ModeConfigExecutor(mode_executor.ModeExecutor):
13
- def __init__(self, context: Dict):
14
- """
15
- ### Constructor.
16
-
17
- #### Params:
18
- - context (dict): Dictionary containing the installation context variables.
19
- """
20
- super().__init__(context)
21
- self.overwrite = context.pop(params.PARAM_OVERWRITE)
22
- self.config_values = {}
23
-
24
- def run(self) -> Tuple[int, str]:
25
- """
26
- ### Reads the config file and writes to it formatting properly with the appropiate values.
19
+ """
20
+ ### Mode Config Executor.
21
+
22
+ Manages the configuration file for the installation.
23
+ """
24
+
25
+ def __init__(self, context: Dict):
26
+ """
27
+ ### Constructor.
28
+
29
+ #### Params:
30
+ - context (dict): Dictionary containing the installation context variables.
31
+ """
32
+ super().__init__(context)
33
+ self.overwrite = context.pop(params.PARAM_OVERWRITE)
34
+ self.config_values = {}
35
+
36
+ def run(self) -> Tuple[int, str]:
37
+ """
38
+ ### Reads the config file and writes to it formatting properly with the appropiate values.
27
39
 
28
- #### Returns:
29
- - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
30
- """
31
- logger(predefined_messages.get_section_message("Managing config file"))
32
- action_message = (
33
- "Generating config file from scratch with default values..."
34
- if self.overwrite or not os.path.exists(paths.CONFIG_FILE) else
35
- "Reading config file..."
36
- )
37
- logger(action_message)
38
- try:
39
- file_handler = config.ConfigurationFileHandler()
40
- file_handler.write_config(overwrite=self.overwrite)
41
- except PermissionError as permission_error:
42
- return errors.IO_ERROR, str(permission_error)
43
- self.config_values = file_handler.values
44
- logger(predefined_messages.get_done_message())
45
- return 0, ""
46
-
40
+ #### Returns:
41
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
42
+ """
43
+ logger(predefined_messages.get_section_message("Managing config file"))
44
+ action_message = (
45
+ "Generating config file from scratch with default values..."
46
+ if self.overwrite or not os.path.exists(paths.CONFIG_FILE) else
47
+ "Reading config file..."
48
+ )
49
+ logger(action_message)
50
+ try:
51
+ file_handler = config.ConfigurationFileHandler()
52
+ file_handler.write_config(overwrite=self.overwrite)
53
+ except PermissionError as permission_error:
54
+ return errors.IO_ERROR, str(permission_error)
55
+ self.config_values = file_handler.values
56
+ logger(predefined_messages.get_done_message())
57
+ return 0, ""
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Executor Module.
3
+
4
+ This module contains the base executor interface for installer modes.
5
+ """
6
+
1
7
  from abc import ABC, abstractmethod
2
8
  from typing import Dict, Tuple
3
9
 
@@ -5,34 +11,29 @@ from xmipp3_installer.application.logger.logger import logger
5
11
  from xmipp3_installer.installer.constants import paths
6
12
 
7
13
  class ModeExecutor(ABC):
8
- """
9
- ### Base executor interface for installer modes.
10
- """
14
+ """### Base executor interface for installer modes."""
15
+
11
16
  def __init__(self, context: Dict):
12
17
  """
13
- ### Constructor.
18
+ ### Constructor.
14
19
 
15
- #### Params:
16
- - context (dict): Dictionary containing the installation context variables.
17
- """
20
+ #### Params:
21
+ - context (dict): Dictionary containing the installation context variables.
22
+ """
18
23
  super().__init__()
19
24
  self.context = context
20
25
  self._set_executor_config()
21
26
  self.__configure_logger()
22
27
 
23
28
  def _set_executor_config(self):
24
- """
25
- ### Sets the specific executor params for this mode.
26
- """
29
+ """### Sets the specific executor params for this mode."""
27
30
  self.logs_to_file = False
28
31
  self.prints_with_substitution = False
29
32
  self.prints_banner_on_exit = False
30
33
  self.sends_installation_info = False
31
34
 
32
35
  def __configure_logger(self):
33
- """
34
- ### Configures the logger according to the specified config.
35
- """
36
+ """### Configures the logger according to the specified config."""
36
37
  if self.logs_to_file:
37
38
  logger.start_log_file(paths.LOG_FILE)
38
39
  if self.prints_with_substitution:
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Get Sources Executor Module.
3
+
4
+ This module contains the class to clone or update Xmipp source repositories.
5
+ """
6
+
1
7
  import os
2
8
  from typing import Dict, Tuple, Optional
3
9
 
@@ -10,123 +16,126 @@ from xmipp3_installer.installer.modes import mode_executor
10
16
  from xmipp3_installer.installer.handlers import git_handler, versions_manager, shell_handler
11
17
 
12
18
  class ModeGetSourcesExecutor(mode_executor.ModeExecutor):
13
- def __init__(self, context: Dict):
14
- """
15
- ### Constructor.
16
-
17
- #### Params:
18
- - context (dict): Dictionary containing the installation context variables.
19
- - substitute (bool): Optional. If True, printed text will be substituted with the next message.
20
- """
21
- super().__init__(context)
22
- self.substitute = not context[params.PARAM_KEEP_OUTPUT]
23
- self.target_branch = context.pop(params.PARAM_BRANCH)
24
- versions: versions_manager.VersionsManager = context[constants.VERSIONS_CONTEXT_KEY]
25
- self.xmipp_tag_name = versions.xmipp_version_name
26
- self.source_versions: Dict = versions.sources_versions
27
-
28
- def run(self) -> Tuple[int, str]:
29
- """
30
- ### Executes the given git command into all xmipp source repositories.
19
+ """
20
+ ### Mode Get Sources Executor.
21
+
22
+ Clones or updates Xmipp source repositories.
23
+ """
24
+
25
+ def __init__(self, context: Dict):
26
+ """
27
+ ### Constructor.
28
+
29
+ #### Params:
30
+ - context (dict): Dictionary containing the installation context variables.
31
+ - substitute (bool): Optional. If True, printed text will be substituted with the next message.
32
+ """
33
+ super().__init__(context)
34
+ self.substitute = not context[params.PARAM_KEEP_OUTPUT]
35
+ self.target_branch = context.pop(params.PARAM_BRANCH)
36
+ versions: versions_manager.VersionsManager = context[constants.VERSIONS_CONTEXT_KEY]
37
+ self.xmipp_tag_name = versions.xmipp_version_name
38
+ self.source_versions: Dict = versions.sources_versions
39
+
40
+ def run(self) -> Tuple[int, str]:
41
+ """
42
+ ### Clones or updates Xmipp source repositories.
43
+
44
+ #### Returns:
45
+ - (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
46
+ """
47
+ logger(predefined_messages.get_section_message("Getting Xmipp sources"))
48
+ for source in constants.XMIPP_SOURCES:
49
+ ret_code, output = self.__get_source(source)
50
+ if ret_code:
51
+ return errors.SOURCE_CLONE_ERROR, output
52
+ return 0, ""
53
+
54
+ def _set_executor_config(self):
55
+ """### Sets the specific executor params for this mode."""
56
+ super()._set_executor_config()
57
+ self.prints_with_substitution = True
58
+
59
+ def __select_ref_to_clone(self, source_name: str, source_repo: str) -> Optional[str]:
60
+ """
61
+ ### Selects the reference to clone from the source.
31
62
 
32
- #### Returns:
33
- - (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
34
- """
35
- logger(predefined_messages.get_section_message("Getting Xmipp sources"))
36
- for source in constants.XMIPP_SOURCES:
37
- ret_code, output = self.__get_source(source)
38
- if ret_code:
39
- return errors.SOURCE_CLONE_ERROR, output
40
- return 0, ""
41
-
42
- def _set_executor_config(self):
43
- """
44
- ### Sets the specific executor params for this mode.
45
- """
46
- super()._set_executor_config()
47
- self.prints_with_substitution = True
48
-
49
- def __select_ref_to_clone(self, source_name: str, source_repo: str) -> str:
50
- """
51
- ### Selects the reference to clone from the source.
63
+ #### Params:
64
+ - source_name (str): Name of the source to clone.
65
+ - source_repo (str): URL of the source's repository.
52
66
 
53
- #### Params:
54
- - source_name (str): Name of the source to clone.
55
- - source_repo (str): URL of the source's repository.
67
+ #### Returns:
68
+ - (str | None): The reference name to clone or None if no suitable ref was found.
69
+ """
70
+ current_branch = git_handler.get_current_branch()
71
+ tag_name = None
72
+ if (
73
+ not current_branch or
74
+ current_branch in {constants.MASTER_BRANCHNAME, self.xmipp_tag_name}
75
+ ):
76
+ tag_name = self.source_versions.get(source_name)
77
+ return git_handler.get_clonable_branch(source_repo, self.target_branch, tag_name)
78
+
79
+ def __get_source(self, source_name: str) -> Tuple[int, str]:
80
+ """
81
+ ### Gets the given source.
82
+
83
+ It is cloned if it does not already exist locally.
56
84
 
57
- #### Returns:
58
- - (str): The reference name to clone.
59
- """
60
- current_branch = git_handler.get_current_branch()
61
- tag_name = None
62
- if (
63
- not current_branch or
64
- current_branch == constants.MASTER_BRANCHNAME or
65
- current_branch == self.xmipp_tag_name
66
- ):
67
- tag_name = self.source_versions.get(source_name)
68
- return git_handler.get_clonable_branch(source_repo, self.target_branch, tag_name)
69
-
70
- def __run_source_command(self, source_name: str, source_repo: str, target_branch: Optional[str]) -> Tuple[int, str]:
71
- """
72
- ### Executes git clone/checkout commands for a source repository.
73
-
74
- If the source already exists locally:
75
- - If target_branch is specified, checks out that branch.
76
- - If no target_branch, returns success without changes.
77
-
78
- If the source doesn't exist:
79
- - Clones the repository with the specified branch.
80
- - If no branch specified, clones with default branch.
85
+ #### Params:
86
+ - source_name (str): Name of the source to clone.
81
87
 
82
- #### Params:
83
- - source_name (str): Name of the source repository.
84
- - source_repo (str): URL of the git repository to clone from.
85
- - target_branch (str | None): Branch or tag to checkout/clone.
88
+ #### Returns:
89
+ - (tuple(int, str)): Tuple containing the return code and the text output produced by the command.
90
+ """
91
+ repo_url = f"{urls.I2PC_REPOSITORY_URL}{source_name}"
92
+ logger(f"Cloning {source_name}...", substitute=self.substitute)
93
+ logger(predefined_messages.get_working_message(), substitute=self.substitute)
86
94
 
87
- #### Returns:
88
- - (tuple(int, str)): Tuple containing the return code and the text output produced by the command.
89
- """
90
- source_path = paths.get_source_path(source_name)
91
- if os.path.exists(source_path):
92
- if not target_branch:
93
- return 0, ""
94
- return shell_handler.run_shell_command(
95
- f"git checkout {target_branch}",
96
- cwd=source_path
97
- )
98
-
99
- branch_str = (
100
- f"{params.PARAMS[params.PARAM_BRANCH][params.LONG_VERSION]} {target_branch}"
101
- if target_branch else ""
102
- )
103
- return shell_handler.run_shell_command(f"git clone{branch_str} {source_repo}.git", cwd=paths.SOURCES_PATH)
104
-
105
- def __get_source(self, source_name: str) -> Tuple[int, str]:
106
- """
107
- ### Gets the given source.
108
-
109
- It is cloned if it does not already exist locally.
95
+ clone_branch = self.__select_ref_to_clone(source_name, repo_url)
96
+ if self.target_branch and not clone_branch:
97
+ warning_message = "\n".join([
98
+ logger.yellow(f"Warning: branch \'{self.target_branch}\' does not exist for repository with url {repo_url}"),
99
+ logger.yellow("Falling back to repository's default branch.")
100
+ ])
101
+ logger(warning_message, substitute=self.substitute)
102
+
103
+ ret_code, output = _run_source_command(source_name, repo_url, clone_branch)
104
+ if not ret_code:
105
+ logger(predefined_messages.get_done_message(), substitute=self.substitute)
106
+ return ret_code, output
110
107
 
111
- #### Params:
112
- - source_name (str): Name of the source to clone.
108
+ def _run_source_command(source_name: str, source_repo: str, target_branch: Optional[str]) -> Tuple[int, str]:
109
+ """
110
+ ### Executes git clone/checkout commands for a source repository.
111
+
112
+ If the source already exists locally:
113
+ - If target_branch is specified, checks out that branch.
114
+ - If no target_branch, returns success without changes.
115
+
116
+ If the source doesn't exist:
117
+ - Clones the repository with the specified branch.
118
+ - If no branch specified, clones with default branch.
113
119
 
114
- #### Returns:
115
- - (tuple(int, str)): Tuple containing the return code and the text output produced by the command.
116
- """
117
- repo_url = f"{urls.I2PC_REPOSITORY_URL}{source_name}"
118
- logger(f"Cloning {source_name}...", substitute=self.substitute)
119
- logger(predefined_messages.get_working_message(), substitute=self.substitute)
120
+ #### Params:
121
+ - source_name (str): Name of the source repository.
122
+ - source_repo (str): URL of the git repository to clone from.
123
+ - target_branch (str | None): Branch or tag to checkout/clone.
120
124
 
121
- clone_branch = self.__select_ref_to_clone(source_name, repo_url)
122
- if self.target_branch and not clone_branch:
123
- warning_message = logger.yellow("\n".join([
124
- f"Warning: branch \'{self.target_branch}\' does not exist for repository with url {repo_url}.",
125
- "Falling back to repository's default branch."
126
- ]))
127
- logger(warning_message, substitute=self.substitute)
128
-
129
- ret_code, output = self.__run_source_command(source_name, repo_url, clone_branch)
130
- if not ret_code:
131
- logger(predefined_messages.get_done_message(), substitute=self.substitute)
132
- return ret_code, output
125
+ #### Returns:
126
+ - (tuple(int, str)): Tuple containing the return code and the text output produced by the command.
127
+ """
128
+ source_path = paths.get_source_path(source_name)
129
+ if os.path.exists(source_path):
130
+ if not target_branch:
131
+ return 0, ""
132
+ return shell_handler.run_shell_command(
133
+ f"git checkout {target_branch}",
134
+ cwd=source_path
135
+ )
136
+
137
+ branch_str = (
138
+ f"{params.PARAMS[params.PARAM_BRANCH][params.LONG_VERSION]} {target_branch}"
139
+ if target_branch else ""
140
+ )
141
+ return shell_handler.run_shell_command(f"git clone{branch_str} {source_repo}.git", cwd=paths.SOURCES_PATH)
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Git Executor Module.
3
+
4
+ This module contains the class to execute git commands on all Xmipp source repositories.
5
+ """
6
+
1
7
  from typing import Dict, Tuple
2
8
 
3
9
  from xmipp3_installer.application.cli.arguments import params
@@ -8,34 +14,40 @@ from xmipp3_installer.installer.modes import mode_executor
8
14
  from xmipp3_installer.installer.handlers import git_handler
9
15
 
10
16
  class ModeGitExecutor(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
- command_param_list = context.pop(params.PARAM_GIT_COMMAND)
20
- self.command = ' '.join(command_param_list)
21
-
22
- def run(self) -> Tuple[int, str]:
23
- """
24
- ### Executes the given git command into all xmipp source repositories.
25
-
26
- #### Returns:
27
- - (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
28
- """
29
- logger(f"Running command 'git {self.command}' for all xmipp sources...")
30
-
31
- for source in [constants.XMIPP, *constants.XMIPP_SOURCES]:
32
- logger("\n" + logger.blue(
33
- f"Running command for {source} in path {paths.get_source_path(source)}..."
34
- ))
35
- ret_code, output = git_handler.execute_git_command_for_source(
36
- self.command, source
37
- )
38
- if ret_code:
39
- return ret_code, output
40
-
41
- return 0, ""
17
+ """
18
+ ### Mode Git Executor.
19
+
20
+ Executes git commands on all Xmipp source repositories.
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
+ command_param_list = context.pop(params.PARAM_GIT_COMMAND)
32
+ self.command = ' '.join(command_param_list)
33
+
34
+ def run(self) -> Tuple[int, str]:
35
+ """
36
+ ### Executes the given git command into all xmipp source repositories.
37
+
38
+ #### Returns:
39
+ - (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
40
+ """
41
+ logger(f"Running command 'git {self.command}' for all xmipp sources...")
42
+
43
+ for source in [constants.XMIPP, *constants.XMIPP_SOURCES]:
44
+ logger("\n" + logger.blue(
45
+ f"Running command for {source} in path {paths.get_source_path(source)}..."
46
+ ))
47
+ ret_code, output = git_handler.execute_git_command_for_source(
48
+ self.command, source
49
+ )
50
+ if ret_code:
51
+ return ret_code, output
52
+
53
+ return 0, ""
@@ -1,3 +1,9 @@
1
+ """
2
+ ### Mode Selector Module.
3
+
4
+ This module maps command-line modes to their corresponding executor classes.
5
+ """
6
+
1
7
  from xmipp3_installer.application.cli.arguments import modes
2
8
  from xmipp3_installer.installer.modes import (
3
9
  mode_config_executor, mode_version_executor, mode_git_executor,