6868from easybuild .tools .hooks import START , END , load_hooks , run_hook
6969from easybuild .tools .modules import modules_tool
7070from easybuild .tools .options import set_up_configuration , use_color
71+ from easybuild .tools .output import create_progress_bar
7172from easybuild .tools .robot import check_conflicts , dry_run , missing_deps , resolve_dependencies , search_easyconfigs
7273from easybuild .tools .package .utilities import check_pkg_support
7374from easybuild .tools .parallelbuild import submit_jobs
7475from easybuild .tools .repository .repository import init_repository
7576from easybuild .tools .testing import create_test_report , overall_test_report , regtest , session_state
76- from rich . progress import Progress , TextColumn , BarColumn , TimeElapsedColumn
77+
7778
7879_log = None
7980
@@ -99,29 +100,35 @@ def find_easyconfigs_by_specs(build_specs, robot_path, try_to_generate, testing=
99100 return [(ec_file , generated )]
100101
101102
102- def build_and_install_software (ecs , init_session_state , exit_on_failure = True , progress = None ):
103+ def build_and_install_software (ecs , init_session_state , exit_on_failure = True , progress_bar = None ):
103104 """
104105 Build and install software for all provided parsed easyconfig files.
105106
106107 :param ecs: easyconfig files to install software with
107108 :param init_session_state: initial session state, to use in test reports
108109 :param exit_on_failure: whether or not to exit on installation failure
110+ :param progress_bar: progress bar to use to report progress
109111 """
110112 # obtain a copy of the starting environment so each build can start afresh
111113 # we shouldn't use the environment from init_session_state, since relevant env vars might have been set since
112114 # e.g. via easyconfig.handle_allowed_system_deps
113115 init_env = copy .deepcopy (os .environ )
114116
115117 # Initialize progress bar with overall installation task
116- if progress :
117- task_id = progress .add_task ("" , total = len (ecs ))
118+ if progress_bar :
119+ task_id = progress_bar .add_task ("" , total = len (ecs ))
120+ else :
121+ task_id = None
122+
118123 res = []
119124 for ec in ecs :
120- if progress :
121- progress .update (task_id , description = ec ['short_mod_name' ])
125+
126+ if progress_bar :
127+ progress_bar .update (task_id , description = ec ['short_mod_name' ])
128+
122129 ec_res = {}
123130 try :
124- (ec_res ['success' ], app_log , err ) = build_and_install_one (ec , init_env , progressbar = progress ,
131+ (ec_res ['success' ], app_log , err ) = build_and_install_one (ec , init_env , progress_bar = progress_bar ,
125132 task_id = task_id )
126133 ec_res ['log_file' ] = app_log
127134 if not ec_res ['success' ]:
@@ -527,18 +534,12 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
527534 # build software, will exit when errors occurs (except when testing)
528535 if not testing or (testing and do_build ):
529536 exit_on_failure = not (options .dump_test_report or options .upload_test_report )
530- # Create progressbar around software to install
531- progress_bar = Progress (
532- TextColumn ("[bold blue]Installing {task.description} ({task.completed:.0f}/{task.total})" ),
533- BarColumn (),
534- "[progress.percentage]{task.percentage:>3.1f}%" ,
535- "•" ,
536- TimeElapsedColumn ()
537- )
537+
538+ progress_bar = create_progress_bar ()
538539 with progress_bar :
539- ecs_with_res = build_and_install_software (
540- ordered_ecs , init_session_state , exit_on_failure = exit_on_failure ,
541- progress = progress_bar )
540+ ecs_with_res = build_and_install_software (ordered_ecs , init_session_state ,
541+ exit_on_failure = exit_on_failure ,
542+ progress_bar = progress_bar )
542543 else :
543544 ecs_with_res = [(ec , {}) for ec in ordered_ecs ]
544545
0 commit comments