5050from easybuild .framework .easyconfig .easyconfig import clean_up_easyconfigs
5151from easybuild .framework .easyconfig .easyconfig import fix_deprecated_easyconfigs , verify_easyconfig_filename
5252from easybuild .framework .easyconfig .style import cmdline_easyconfigs_style_check
53- from easybuild .framework .easyconfig .tools import categorize_files_by_type , dep_graph
53+ from easybuild .framework .easyconfig .tools import categorize_files_by_type , dep_graph , det_copy_ec_specs
5454from easybuild .framework .easyconfig .tools import det_easyconfig_paths , dump_env_script , get_paths_for
5555from easybuild .framework .easyconfig .tools import parse_easyconfigs , review_pr , run_contrib_checks , skip_available
5656from easybuild .framework .easyconfig .tweak import obtain_ec_for , tweak
5757from easybuild .tools .config import find_last_log , get_repository , get_repositorypath , build_option
5858from easybuild .tools .containers .common import containerize
5959from easybuild .tools .docs import list_software
60- from easybuild .tools .filetools import adjust_permissions , cleanup , copy_file , copy_files , dump_index , load_index
61- from easybuild .tools .filetools import read_file , register_lock_cleanup_signal_handlers , write_file
62- from easybuild .tools .github import check_github , close_pr , new_branch_github , find_easybuild_easyconfig
63- from easybuild .tools .github import install_github_token , list_prs , new_pr , new_pr_from_branch , merge_pr
60+ from easybuild .tools .filetools import adjust_permissions , cleanup , copy_files , dump_index , load_index
61+ from easybuild .tools .filetools import locate_files , read_file , register_lock_cleanup_signal_handlers , write_file
62+ from easybuild .tools .github import check_github , close_pr , find_easybuild_easyconfig
63+ from easybuild .tools .github import install_github_token , list_prs , merge_pr , new_branch_github , new_pr
64+ from easybuild .tools .github import new_pr_from_branch
6465from easybuild .tools .github import sync_branch_with_develop , sync_pr_with_develop , update_branch , update_pr
6566from easybuild .tools .hooks import START , END , load_hooks , run_hook
6667from easybuild .tools .modules import modules_tool
@@ -303,12 +304,9 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
303304 eb_file = find_easybuild_easyconfig ()
304305 orig_paths .append (eb_file )
305306
306- if len (orig_paths ) == 1 :
307- # if only one easyconfig file is specified, use current directory as target directory
308- target_path = os .getcwd ()
309- elif orig_paths :
310- # last path is target when --copy-ec is used, so remove that from the list
311- target_path = orig_paths .pop () if options .copy_ec else None
307+ if options .copy_ec :
308+ # figure out list of files to copy + target location (taking into account --from-pr)
309+ orig_paths , target_path = det_copy_ec_specs (orig_paths , options .from_pr )
312310
313311 categorized_paths = categorize_files_by_type (orig_paths )
314312
@@ -321,17 +319,17 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
321319 # determine paths to easyconfigs
322320 determined_paths = det_easyconfig_paths (categorized_paths ['easyconfigs' ])
323321
324- if (options .copy_ec and not tweaked_ecs_paths ) or options .fix_deprecated_easyconfigs or options .show_ec :
322+ # only copy easyconfigs here if we're not using --try-* (that's handled below)
323+ copy_ec = options .copy_ec and not tweaked_ecs_paths
324+
325+ if copy_ec or options .fix_deprecated_easyconfigs or options .show_ec :
325326
326327 if options .copy_ec :
327- if len (determined_paths ) == 1 :
328- copy_file (determined_paths [0 ], target_path )
329- print_msg ("%s copied to %s" % (os .path .basename (determined_paths [0 ]), target_path ), prefix = False )
330- elif len (determined_paths ) > 1 :
331- copy_files (determined_paths , target_path )
332- print_msg ("%d file(s) copied to %s" % (len (determined_paths ), target_path ), prefix = False )
333- else :
334- raise EasyBuildError ("One of more files to copy should be specified!" )
328+ # at this point some paths may still just be filenames rather than absolute paths,
329+ # so try to determine full path for those too via robot search path
330+ paths = locate_files (orig_paths , robot_path )
331+
332+ copy_files (paths , target_path , target_single_file = True , allow_empty = False , verbose = True )
335333
336334 elif options .fix_deprecated_easyconfigs :
337335 fix_deprecated_easyconfigs (determined_paths )
@@ -361,7 +359,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
361359 if options .regtest or options .aggregate_regtest :
362360 _log .info ("Running regression test" )
363361 # fallback: easybuild-easyconfigs install path
364- regtest_ok = regtest ([path [ 0 ] for path in paths ] or easyconfigs_pkg_paths , modtool )
362+ regtest_ok = regtest ([x for ( x , _ ) in paths ] or easyconfigs_pkg_paths , modtool )
365363 if not regtest_ok :
366364 _log .info ("Regression test failed (partially)!" )
367365 sys .exit (31 ) # exit -> 3x1t -> 31
@@ -429,8 +427,9 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
429427 if tweaked_ecs_in_all_ecs :
430428 # Clean them, then copy them
431429 clean_up_easyconfigs (tweaked_ecs_in_all_ecs )
432- copy_files (tweaked_ecs_in_all_ecs , target_path )
433- print_msg ("%d file(s) copied to %s" % (len (tweaked_ecs_in_all_ecs ), target_path ), prefix = False )
430+ copy_files (tweaked_ecs_in_all_ecs , target_path , allow_empty = False , verbose = True )
431+
432+ clean_exit (logfile , eb_tmpdir , testing )
434433
435434 # creating/updating PRs
436435 if pr_options :
0 commit comments